1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "base/callback_forward.h" 12 #include "base/macros.h" 13 #include "chrome/browser/supervised_user/supervised_user_error_page/supervised_user_error_page.h" 14 #include "url/gurl.h" 15 16 namespace content { 17 class WebContents; 18 } // namespace content 19 20 class Profile; 21 22 // This class is used by SupervisedUserNavigationObserver to handle requests 23 // from supervised user error page. The error page is shown when a page is 24 // blocked because it is on a denylist (in "allow everything" mode), not on any 25 // allowlist (in "allow only specified sites" mode), or doesn't pass safe 26 // search. 27 class SupervisedUserInterstitial { 28 public: 29 ~SupervisedUserInterstitial(); 30 31 static std::unique_ptr<SupervisedUserInterstitial> Create( 32 content::WebContents* web_contents, 33 const GURL& url, 34 supervised_user_error_page::FilteringBehaviorReason reason, 35 int frame_id, 36 int64_t interstitial_navigation_id); 37 38 static std::string GetHTMLContents( 39 Profile* profile, 40 supervised_user_error_page::FilteringBehaviorReason reason, 41 bool already_sent_request, 42 bool is_main_frame); 43 44 void GoBack(); 45 void RequestPermission(base::OnceCallback<void(bool)> callback); 46 void ShowFeedback(); 47 48 // Getter methods. web_contents()49 content::WebContents* web_contents() { return web_contents_; } frame_id()50 int frame_id() const { return frame_id_; } interstitial_navigation_id()51 int64_t interstitial_navigation_id() const { 52 return interstitial_navigation_id_; 53 } url()54 const GURL& url() const { return url_; } 55 56 private: 57 SupervisedUserInterstitial( 58 content::WebContents* web_contents, 59 const GURL& url, 60 supervised_user_error_page::FilteringBehaviorReason reason, 61 int frame_id, 62 int64_t interstitial_navigation_id); 63 64 // Tries to go back. 65 void AttemptMoveAwayFromCurrentFrameURL(); 66 67 void OnInterstitialDone(); 68 69 // Owns SupervisedUserNavigationObserver which owns us. 70 content::WebContents* web_contents_; 71 72 Profile* profile_; 73 74 // The last committed url for this frame. 75 GURL url_; 76 supervised_user_error_page::FilteringBehaviorReason reason_; 77 78 // The uniquely identifying global id for the frame. 79 int frame_id_; 80 81 // The Navigation ID of the navigation that last triggered the interstitial. 82 int64_t interstitial_navigation_id_; 83 84 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); 85 }; 86 87 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ 88