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/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" | 12 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" |
13 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 13 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
14 #include "content/public/browser/interstitial_page_delegate.h" | 14 #include "content/public/browser/interstitial_page_delegate.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class InterstitialPage; | 18 class InterstitialPage; |
19 class WebContents; | 19 class WebContents; |
20 } | 20 } |
21 | 21 |
22 class Profile; | 22 class Profile; |
23 | 23 |
24 // Delegate for an interstitial page when a page is blocked for a supervised | 24 // Delegate for an interstitial page when a page is blocked for a supervised |
25 // user because it is on a blacklist (in "allow everything" mode) or not on any | 25 // user because it is on a blacklist (in "allow everything" mode) or not on any |
26 // whitelist (in "allow only specified sites" mode). | 26 // whitelist (in "allow only specified sites" mode). |
27 class SupervisedUserInterstitial : public content::InterstitialPageDelegate, | 27 class SupervisedUserInterstitial : public content::InterstitialPageDelegate, |
28 public SupervisedUserServiceObserver { | 28 public SupervisedUserServiceObserver { |
29 public: | 29 public: |
| 30 // Interstitial type, used for testing. |
| 31 static content::InterstitialPageDelegate::TypeID kTypeForTesting; |
| 32 |
30 static void Show(content::WebContents* web_contents, | 33 static void Show(content::WebContents* web_contents, |
31 const GURL& url, | 34 const GURL& url, |
32 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 35 SupervisedUserURLFilter::FilteringBehaviorReason reason, |
33 const base::Callback<void(bool)>& callback); | 36 const base::Callback<void(bool)>& callback); |
34 | 37 |
35 private: | 38 private: |
36 SupervisedUserInterstitial( | 39 SupervisedUserInterstitial( |
37 content::WebContents* web_contents, | 40 content::WebContents* web_contents, |
38 const GURL& url, | 41 const GURL& url, |
39 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 42 SupervisedUserURLFilter::FilteringBehaviorReason reason, |
40 const base::Callback<void(bool)>& callback); | 43 const base::Callback<void(bool)>& callback); |
41 ~SupervisedUserInterstitial() override; | 44 ~SupervisedUserInterstitial() override; |
42 | 45 |
43 bool Init(); | 46 bool Init(); |
44 | 47 |
45 // InterstitialPageDelegate implementation. | 48 // InterstitialPageDelegate implementation. |
46 std::string GetHTMLContents() override; | 49 std::string GetHTMLContents() override; |
47 void CommandReceived(const std::string& command) override; | 50 void CommandReceived(const std::string& command) override; |
48 void OnProceed() override; | 51 void OnProceed() override; |
49 void OnDontProceed() override; | 52 void OnDontProceed() override; |
| 53 content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override; |
50 | 54 |
51 // SupervisedUserServiceObserver implementation. | 55 // SupervisedUserServiceObserver implementation. |
52 void OnURLFilterChanged() override; | 56 void OnURLFilterChanged() override; |
53 // TODO(treib): Also listen to OnCustodianInfoChanged and update as required. | 57 // TODO(treib): Also listen to OnCustodianInfoChanged and update as required. |
54 | 58 |
55 void OnAccessRequestAdded(bool success); | 59 void OnAccessRequestAdded(bool success); |
56 | 60 |
57 // Returns whether we should now proceed on a previously-blocked URL. | 61 // Returns whether we should now proceed on a previously-blocked URL. |
58 // Called initially before the interstitial is shown (to catch race | 62 // Called initially before the interstitial is shown (to catch race |
59 // conditions), or when the URL filtering prefs change. Note that this does | 63 // conditions), or when the URL filtering prefs change. Note that this does |
(...skipping 14 matching lines...) Expand all Loading... |
74 SupervisedUserURLFilter::FilteringBehaviorReason reason_; | 78 SupervisedUserURLFilter::FilteringBehaviorReason reason_; |
75 | 79 |
76 base::Callback<void(bool)> callback_; | 80 base::Callback<void(bool)> callback_; |
77 | 81 |
78 base::WeakPtrFactory<SupervisedUserInterstitial> weak_ptr_factory_; | 82 base::WeakPtrFactory<SupervisedUserInterstitial> weak_ptr_factory_; |
79 | 83 |
80 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); | 84 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); |
81 }; | 85 }; |
82 | 86 |
83 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ | 87 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ |
OLD | NEW |