Chromium Code Reviews| Index: chrome/browser/managed_mode/managed_mode_navigation_observer.h |
| diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.h b/chrome/browser/managed_mode/managed_mode_navigation_observer.h |
| index 1ddd4953e9a79fb2549b6c5dd43ccf931b6df305..4067c8ea53e4570614c912f4e5a1ae3045d8094a 100644 |
| --- a/chrome/browser/managed_mode/managed_mode_navigation_observer.h |
| +++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.h |
| @@ -7,7 +7,10 @@ |
| #include <set> |
| +#include "base/memory/weak_ptr.h" |
| #include "base/values.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| #include "content/public/browser/web_contents_observer.h" |
| #include "content/public/browser/web_contents_user_data.h" |
| @@ -16,18 +19,24 @@ class ManagedModeURLFilter; |
| class ManagedUserService; |
| class ManagedModeNavigationObserver |
| - : public content::WebContentsObserver, |
| - public content::WebContentsUserData<ManagedModeNavigationObserver> { |
| + : public content::WebContentsUserData<ManagedModeNavigationObserver>, |
| + public content::WebContentsObserver, |
| + public content::NotificationObserver { |
| public: |
| virtual ~ManagedModeNavigationObserver(); |
| + // Called when a network request was blocked. The passed in |callback| is |
| + // called with the result of the interstitial, i.e. whether we should proceed |
| + // with the request or not. |
| + static void DidBlockRequest(int render_process_id, |
| + int render_view_id, |
| + const GURL& url, |
| + const base::Callback<void(bool)>& callback); |
|
Adrian Kuegel
2013/03/28 14:28:34
nit: You could use a typedef for this kind of call
Bernhard Bauer
2013/03/28 15:03:30
Done.
|
| + |
| // Sets the specific infobar as dismissed. |
| void WarnInfobarDismissed(); |
| void PreviewInfobarDismissed(); |
| - // Sets the state of the Observer from the outside. |
| - void SetStateToRecordingAfterPreview(); |
| - |
| // Returns whether the user should be allowed to navigate to this URL after |
| // he has clicked "Preview" on the interstitial. |
| bool CanTemporarilyNavigateHost(const GURL& url); |
| @@ -65,6 +74,16 @@ class ManagedModeNavigationObserver |
| explicit ManagedModeNavigationObserver(content::WebContents* web_contents); |
| + // Shows the blocking interstitial if it is not already shown. |
| + void ShowInterstitial(const GURL& url); |
| + |
| + // Queues up a callback to be called with the result of the interstitial. |
| + void AddInterstitialCallback(const GURL& url, |
| + const base::Callback<void(bool)>& callback); |
| + |
| + // Dispatches the result of the interstitial to all pending callbacks. |
| + void OnInterstitialResult(bool result); |
| + |
| // Adding the temporary exception stops the ResourceThrottle from showing |
| // an interstitial for this RenderView. This allows the user to navigate |
| // around on the website after clicking preview. |
| @@ -75,6 +94,10 @@ class ManagedModeNavigationObserver |
| void AddURLToPatternList(const GURL& url); |
| + // Returns whether the user would stay in elevated state if he visits this |
| + // URL. |
| + bool ShouldStayElevatedForURL(const GURL& url); |
| + |
| // content::WebContentsObserver implementation. |
| // An example regarding the order in which these events take place for |
| // google.com in our case is as follows: |
| @@ -90,9 +113,6 @@ class ManagedModeNavigationObserver |
| virtual void NavigateToPendingEntry( |
| const GURL& url, |
| content::NavigationController::ReloadType reload_type) OVERRIDE; |
| - virtual void DidNavigateMainFrame( |
| - const content::LoadCommittedDetails& details, |
| - const content::FrameNavigateParams& params) OVERRIDE; |
| virtual void ProvisionalChangeToMainFrameUrl( |
| const GURL& url, |
| content::RenderViewHost* render_view_host) OVERRIDE; |
| @@ -102,11 +122,15 @@ class ManagedModeNavigationObserver |
| const GURL& url, |
| content::PageTransition transition_type, |
| content::RenderViewHost* render_view_host) OVERRIDE; |
| + virtual void DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params) OVERRIDE; |
| virtual void DidGetUserGesture() OVERRIDE; |
| - // Returns whether the user would stay in elevated state if he visits this |
| - // URL. |
| - bool ShouldStayElevatedForURL(const GURL& url); |
| + // content::NotificationObserver implementation. |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| // Owned by the profile, so outlives us. |
| ManagedUserService* managed_user_service_; |
| @@ -132,6 +156,11 @@ class ManagedModeNavigationObserver |
| // Will be set to true for non-managed users. |
| bool is_elevated_; |
| + base::WeakPtrFactory<ManagedModeNavigationObserver> weak_ptr_factory_; |
| + std::vector<base::Callback<void(bool)> > callbacks_; |
|
Adrian Kuegel
2013/03/28 14:28:34
Nit: you could document this variable.
Bernhard Bauer
2013/03/28 15:03:30
Done.
|
| + |
| + content::NotificationRegistrar registrar_; |
| + |
| int last_allowed_page_; |
| DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); |