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/prefs/pref_change_registrar.h" | 11 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" |
12 #include "content/public/browser/interstitial_page_delegate.h" | 12 #include "content/public/browser/interstitial_page_delegate.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class InterstitialPage; | 16 class InterstitialPage; |
17 class WebContents; | 17 class WebContents; |
18 } | 18 } |
19 | 19 |
| 20 class Profile; |
| 21 |
20 // Delegate for an interstitial page when a page is blocked for a supervised | 22 // Delegate for an interstitial page when a page is blocked for a supervised |
21 // user because it is on a blacklist (in "allow everything" mode) or not on any | 23 // user because it is on a blacklist (in "allow everything" mode) or not on any |
22 // whitelist (in "allow only specified sites" mode). | 24 // whitelist (in "allow only specified sites" mode). |
23 class SupervisedUserInterstitial : public content::InterstitialPageDelegate { | 25 class SupervisedUserInterstitial : public content::InterstitialPageDelegate, |
| 26 public SupervisedUserServiceObserver { |
24 public: | 27 public: |
25 static void Show(content::WebContents* web_contents, | 28 static void Show(content::WebContents* web_contents, |
26 const GURL& url, | 29 const GURL& url, |
27 const base::Callback<void(bool)>& callback); | 30 const base::Callback<void(bool)>& callback); |
28 | 31 |
29 private: | 32 private: |
30 SupervisedUserInterstitial(content::WebContents* web_contents, | 33 SupervisedUserInterstitial(content::WebContents* web_contents, |
31 const GURL& url, | 34 const GURL& url, |
32 const base::Callback<void(bool)>& callback); | 35 const base::Callback<void(bool)>& callback); |
33 virtual ~SupervisedUserInterstitial(); | 36 virtual ~SupervisedUserInterstitial(); |
34 | 37 |
35 bool Init(); | 38 bool Init(); |
36 | 39 |
37 // InterstitialPageDelegate implementation. | 40 // InterstitialPageDelegate implementation. |
38 virtual std::string GetHTMLContents() OVERRIDE; | 41 virtual std::string GetHTMLContents() OVERRIDE; |
39 virtual void CommandReceived(const std::string& command) OVERRIDE; | 42 virtual void CommandReceived(const std::string& command) OVERRIDE; |
40 virtual void OnProceed() OVERRIDE; | 43 virtual void OnProceed() OVERRIDE; |
41 virtual void OnDontProceed() OVERRIDE; | 44 virtual void OnDontProceed() OVERRIDE; |
42 | 45 |
| 46 // SupervisedUserServiceObserver implementation. |
| 47 virtual void OnURLFilterChanged() OVERRIDE; |
| 48 |
43 // Returns whether the blocked URL is now allowed. Called initially before the | 49 // Returns whether the blocked URL is now allowed. Called initially before the |
44 // interstitial is shown (to catch race conditions), or when the URL filtering | 50 // interstitial is shown (to catch race conditions), or when the URL filtering |
45 // prefs change. | 51 // prefs change. |
46 bool ShouldProceed(); | 52 bool ShouldProceed(); |
47 | 53 |
48 void OnFilteringPrefsChanged(); | |
49 void DispatchContinueRequest(bool continue_request); | 54 void DispatchContinueRequest(bool continue_request); |
50 | 55 |
51 // Owns the interstitial, which owns us. | 56 // Owns the interstitial, which owns us. |
52 content::WebContents* web_contents_; | 57 content::WebContents* web_contents_; |
53 | 58 |
| 59 Profile* profile_; |
| 60 |
54 content::InterstitialPage* interstitial_page_; // Owns us. | 61 content::InterstitialPage* interstitial_page_; // Owns us. |
55 | 62 |
56 PrefChangeRegistrar pref_change_registrar_; | |
57 | |
58 GURL url_; | 63 GURL url_; |
59 | 64 |
60 base::Callback<void(bool)> callback_; | 65 base::Callback<void(bool)> callback_; |
61 | 66 |
62 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); | 67 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); |
63 }; | 68 }; |
64 | 69 |
65 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ | 70 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ |
OLD | NEW |