Chromium Code Reviews| 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; |
| 58 content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override; | 59 content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override; |
| 59 | 60 |
| 60 // SupervisedUserServiceObserver implementation. | 61 // SupervisedUserServiceObserver implementation. |
| 61 void OnURLFilterChanged() override; | 62 void OnURLFilterChanged() override; |
| 62 // TODO(treib): Also listen to OnCustodianInfoChanged and update as required. | 63 // TODO(treib): Also listen to OnCustodianInfoChanged and update as required. |
| 63 | 64 |
| 64 void OnAccessRequestAdded(bool success); | 65 void OnAccessRequestAdded(bool success); |
| 65 | 66 |
| 66 // Returns whether we should now proceed on a previously-blocked URL. | 67 // Returns whether we should now proceed on a previously-blocked URL. |
| 67 // Called initially before the interstitial is shown (to catch race | 68 // Called initially before the interstitial is shown (to catch race |
| 68 // conditions), or when the URL filtering prefs change. Note that this does | 69 // conditions), or when the URL filtering prefs change. Note that this does |
| 69 // not include the asynchronous online checks, so if those are enabled, then | 70 // not include the asynchronous online checks, so if those are enabled, then |
| 70 // the return value indicates only "allow" or "don't know". | 71 // the return value indicates only "allow" or "don't know". |
| 71 bool ShouldProceed(); | 72 bool ShouldProceed(); |
| 72 | 73 |
| 73 void DispatchContinueRequest(bool continue_request); | 74 void DispatchContinueRequest(bool continue_request); |
| 74 | 75 |
| 76 static std::string BuildHtml( | |
| 77 bool allow_access_requests, | |
| 78 const std::string& profile_image_url, | |
| 79 const std::string& profile_image_url2, | |
| 80 const base::string16& custodian, | |
| 81 const base::string16& custodian_email, | |
| 82 const base::string16& second_custodian, | |
| 83 const base::string16& second_custodian_email, | |
| 84 bool is_child_account, | |
| 85 supervised_user_error_page::FilteringBehaviorReason reason); | |
|
Bernhard Bauer
2016/03/16 13:59:45
Add an empty line before comments please.
But act
aberent
2016/03/16 16:06:40
Removed. Forgot to clean up an intermediate stage
| |
| 75 // Owns the interstitial, which owns us. | 86 // Owns the interstitial, which owns us. |
|
Bernhard Bauer
2016/03/16 13:59:45
Add an empty line before comments please.
aberent
2016/03/16 16:06:40
Done.
| |
| 76 content::WebContents* web_contents_; | 87 content::WebContents* web_contents_; |
| 77 | 88 |
| 78 Profile* profile_; | 89 Profile* profile_; |
| 79 | 90 |
| 80 content::InterstitialPage* interstitial_page_; // Owns us. | 91 content::InterstitialPage* interstitial_page_; // Owns us. |
| 81 | 92 |
| 82 GURL url_; | 93 GURL url_; |
| 83 SupervisedUserURLFilter::FilteringBehaviorReason reason_; | 94 supervised_user_error_page::FilteringBehaviorReason reason_; |
| 84 | 95 |
| 85 base::Callback<void(bool)> callback_; | 96 base::Callback<void(bool)> callback_; |
| 86 | 97 |
| 87 base::WeakPtrFactory<SupervisedUserInterstitial> weak_ptr_factory_; | 98 base::WeakPtrFactory<SupervisedUserInterstitial> weak_ptr_factory_; |
| 88 | 99 |
| 89 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); | 100 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial); |
| 90 }; | 101 }; |
| 91 | 102 |
| 92 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ | 103 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_ |
| OLD | NEW |