OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_ | 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_ |
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_ | 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // Delegate for an interstitial page when a page is blocked in managed mode | 21 // Delegate for an interstitial page when a page is blocked in managed mode |
22 // because it is not on any whitelist. It lets an authorized user preview the | 22 // because it is not on any whitelist. It lets an authorized user preview the |
23 // blocked page, to decide later whether to manually allow it. | 23 // blocked page, to decide later whether to manually allow it. |
24 class ManagedModeInterstitial : public content::InterstitialPageDelegate { | 24 class ManagedModeInterstitial : public content::InterstitialPageDelegate { |
25 public: | 25 public: |
26 ManagedModeInterstitial(content::WebContents* web_contents, | 26 ManagedModeInterstitial(content::WebContents* web_contents, |
27 const GURL& url, | 27 const GURL& url, |
28 const base::Callback<void(bool)>& callback); | 28 const base::Callback<void(bool)>& callback); |
29 virtual ~ManagedModeInterstitial(); | 29 virtual ~ManagedModeInterstitial(); |
30 | 30 |
31 // Should be called on the IO thread. | |
32 // |render_process_host_id| and |render_view_id| identify the WebContents | |
33 // where the request was blocked. |url| is the URL that was blocked. | |
34 // |callback| should be called with the result (whether to allow the request | |
35 // or not). | |
36 static void ShowInterstitial(int render_process_host_id, | |
37 int render_view_id, | |
38 const GURL& url, | |
39 const base::Callback<void(bool)>& callback); | |
40 | |
41 private: | 31 private: |
42 void GoToNewTabPage(); | 32 void GoToNewTabPage(); |
43 | 33 |
44 // InterstitialPageDelegate implementation. | 34 // InterstitialPageDelegate implementation. |
45 virtual std::string GetHTMLContents() OVERRIDE; | 35 virtual std::string GetHTMLContents() OVERRIDE; |
46 virtual void CommandReceived(const std::string& command) OVERRIDE; | 36 virtual void CommandReceived(const std::string& command) OVERRIDE; |
47 virtual void OnProceed() OVERRIDE; | 37 virtual void OnProceed() OVERRIDE; |
48 virtual void OnDontProceed() OVERRIDE; | 38 virtual void OnDontProceed() OVERRIDE; |
49 | 39 |
50 // Will be called when the passphrase dialog is closed, which is shown after | 40 // Will be called when the passphrase dialog is closed, which is shown after |
51 // clicking the preview button. | 41 // clicking the preview button. |
52 void OnAuthorizationResult(bool success); | 42 void OnAuthorizationResult(bool success); |
53 void DispatchContinueRequest(bool continue_request); | |
54 | 43 |
55 // Owns the interstitial, which owns us. | 44 // Owns the interstitial, which owns us. |
56 content::WebContents* web_contents_; | 45 content::WebContents* web_contents_; |
57 | 46 |
58 content::InterstitialPage* interstitial_page_; // Owns us. | 47 content::InterstitialPage* interstitial_page_; // Owns us. |
59 | 48 |
60 // The UI language. Used for formatting the URL for display. | 49 // The UI language. Used for formatting the URL for display. |
61 std::string languages_; | 50 std::string languages_; |
62 GURL url_; | 51 GURL url_; |
63 | 52 |
64 base::WeakPtrFactory<ManagedModeInterstitial> weak_ptr_factory_; | 53 base::WeakPtrFactory<ManagedModeInterstitial> weak_ptr_factory_; |
65 base::Callback<void(bool)> callback_; | 54 base::Callback<void(bool)> callback_; |
66 | 55 |
67 DISALLOW_COPY_AND_ASSIGN(ManagedModeInterstitial); | 56 DISALLOW_COPY_AND_ASSIGN(ManagedModeInterstitial); |
68 }; | 57 }; |
69 | 58 |
70 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_ | 59 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_INTERSTITIAL_H_ |
OLD | NEW |