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