android-webview: Remove legacy crash handler (### Version)
[chromium-blink-merge.git] / chrome / browser / supervised_user / supervised_user_interstitial.h
blobbf75f13217bfdac2b9f084afbee99c36054cf633
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_
8 #include <string>
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"
15 #include "url/gurl.h"
17 namespace content {
18 class InterstitialPage;
19 class WebContents;
22 class Profile;
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 {
29 public:
30 // Interstitial type, used for testing.
31 static content::InterstitialPageDelegate::TypeID kTypeForTesting;
33 static void Show(content::WebContents* web_contents,
34 const GURL& url,
35 SupervisedUserURLFilter::FilteringBehaviorReason reason,
36 const base::Callback<void(bool)>& callback);
38 private:
39 SupervisedUserInterstitial(
40 content::WebContents* web_contents,
41 const GURL& url,
42 SupervisedUserURLFilter::FilteringBehaviorReason reason,
43 const base::Callback<void(bool)>& callback);
44 ~SupervisedUserInterstitial() override;
46 bool Init();
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".
66 bool ShouldProceed();
68 void DispatchContinueRequest(bool continue_request);
70 // Owns the interstitial, which owns us.
71 content::WebContents* web_contents_;
73 Profile* profile_;
75 content::InterstitialPage* interstitial_page_; // Owns us.
77 GURL url_;
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_