OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ |
6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" | 13 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" |
14 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 14 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
| 15 #include "components/supervised_user_error_page/supervised_user_error_page.h" |
15 #include "content/public/browser/interstitial_page_delegate.h" | 16 #include "content/public/browser/interstitial_page_delegate.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 class InterstitialPage; | 20 class InterstitialPage; |
20 class WebContents; | 21 class WebContents; |
21 } | 22 } |
22 | 23 |
23 class Profile; | 24 class Profile; |
24 | 25 |
25 // Delegate for an interstitial page when a page is blocked for a supervised | 26 // Delegate for an interstitial page when a page is blocked for a supervised |
26 // user because it is on a blacklist (in "allow everything" mode) or not on any | 27 // user because it is on a blacklist (in "allow everything" mode) or not on any |
27 // whitelist (in "allow only specified sites" mode). | 28 // whitelist (in "allow only specified sites" mode). |
28 class SupervisedUserInterstitial : public content::InterstitialPageDelegate, | 29 class SupervisedUserInterstitial : public content::InterstitialPageDelegate, |
29 public SupervisedUserServiceObserver { | 30 public SupervisedUserServiceObserver { |
30 public: | 31 public: |
31 // Interstitial type, used for testing. | 32 // Interstitial type, used for testing. |
32 static content::InterstitialPageDelegate::TypeID kTypeForTesting; | 33 static content::InterstitialPageDelegate::TypeID kTypeForTesting; |
33 | 34 |
34 static void Show(content::WebContents* web_contents, | 35 static void Show(content::WebContents* web_contents, |
35 const GURL& url, | 36 const GURL& url, |
36 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 37 supervised_user_error_page::FilteringBehaviorReason reason, |
37 const base::Callback<void(bool)>& callback); | 38 const base::Callback<void(bool)>& callback); |
38 | 39 |
39 static std::string GetHTMLContents( | 40 static std::string GetHTMLContents( |
40 Profile* profile, | 41 Profile* profile, |
41 SupervisedUserURLFilter::FilteringBehaviorReason reason); | 42 supervised_user_error_page::FilteringBehaviorReason reason); |
42 | 43 |
43 private: | 44 private: |
44 SupervisedUserInterstitial( | 45 SupervisedUserInterstitial( |
45 content::WebContents* web_contents, | 46 content::WebContents* web_contents, |
46 const GURL& url, | 47 const GURL& url, |
47 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 48 supervised_user_error_page::FilteringBehaviorReason reason, |
48 const base::Callback<void(bool)>& callback); | 49 const base::Callback<void(bool)>& callback); |
49 ~SupervisedUserInterstitial() override; | 50 ~SupervisedUserInterstitial() override; |
50 | 51 |
51 bool Init(); | 52 bool Init(); |
52 | 53 |
53 // InterstitialPageDelegate implementation. | 54 // InterstitialPageDelegate implementation. |
54 std::string GetHTMLContents() override; | 55 std::string GetHTMLContents() override; |
55 void CommandReceived(const std::string& command) override; | 56 void CommandReceived(const std::string& command) override; |
56 void OnProceed() override; | 57 void OnProceed() override; |
57 void OnDontProceed() override; | 58 void OnDontProceed() override; |
(...skipping 15 matching lines...) Expand all Loading... |
73 void DispatchContinueRequest(bool continue_request); | 74 void DispatchContinueRequest(bool continue_request); |
74 | 75 |
75 // Owns the interstitial, which owns us. | 76 // Owns the interstitial, which owns us. |
76 content::WebContents* web_contents_; | 77 content::WebContents* web_contents_; |
77 | 78 |
78 Profile* profile_; | 79 Profile* profile_; |
79 | 80 |
80 content::InterstitialPage* interstitial_page_; // Owns us. | 81 content::InterstitialPage* interstitial_page_; // Owns us. |
81 | 82 |
82 GURL url_; | 83 GURL url_; |
83 SupervisedUserURLFilter::FilteringBehaviorReason reason_; | 84 supervised_user_error_page::FilteringBehaviorReason reason_; |
84 | 85 |
85 base::Callback<void(bool)> callback_; | 86 base::Callback<void(bool)> callback_; |
86 | 87 |
87 base::WeakPtrFactory<SupervisedUserInterstitial> weak_ptr_factory_; | 88 base::WeakPtrFactory<SupervisedUserInterstitial> weak_ptr_factory_; |
88 | 89 |
89 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); | 90 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); |
90 }; | 91 }; |
91 | 92 |
92 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ | 93 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ |
OLD | NEW |