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