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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_
10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/supervised_user/supervised_user_service_observer.h"
13 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
14 #include "content/public/browser/interstitial_page_delegate.h"
18 class InterstitialPage
;
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
26 // whitelist (in "allow only specified sites" mode).
27 class SupervisedUserInterstitial
: public content::InterstitialPageDelegate
,
28 public SupervisedUserServiceObserver
{
30 // Interstitial type, used for testing.
31 static content::InterstitialPageDelegate::TypeID kTypeForTesting
;
33 static void Show(content::WebContents
* web_contents
,
35 SupervisedUserURLFilter::FilteringBehaviorReason reason
,
36 const base::Callback
<void(bool)>& callback
);
39 SupervisedUserInterstitial(
40 content::WebContents
* web_contents
,
42 SupervisedUserURLFilter::FilteringBehaviorReason reason
,
43 const base::Callback
<void(bool)>& callback
);
44 ~SupervisedUserInterstitial() override
;
48 // InterstitialPageDelegate implementation.
49 std::string
GetHTMLContents() override
;
50 void CommandReceived(const std::string
& command
) override
;
51 void OnProceed() override
;
52 void OnDontProceed() override
;
53 content::InterstitialPageDelegate::TypeID
GetTypeForTesting() const override
;
55 // SupervisedUserServiceObserver implementation.
56 void OnURLFilterChanged() override
;
57 // TODO(treib): Also listen to OnCustodianInfoChanged and update as required.
59 void OnAccessRequestAdded(bool success
);
61 // Returns whether we should now proceed on a previously-blocked URL.
62 // Called initially before the interstitial is shown (to catch race
63 // conditions), or when the URL filtering prefs change. Note that this does
64 // not include the asynchronous online checks, so if those are enabled, then
65 // the return value indicates only "allow" or "don't know".
68 void DispatchContinueRequest(bool continue_request
);
70 // Owns the interstitial, which owns us.
71 content::WebContents
* web_contents_
;
75 content::InterstitialPage
* interstitial_page_
; // Owns us.
78 SupervisedUserURLFilter::FilteringBehaviorReason reason_
;
80 base::Callback
<void(bool)> callback_
;
82 base::WeakPtrFactory
<SupervisedUserInterstitial
> weak_ptr_factory_
;
84 DISALLOW_COPY_AND_ASSIGN(SupervisedUserInterstitial
);
87 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_INTERSTITIAL_H_