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..044f1243e0c877977135eff3f8ffa4138b1e84d2 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,26 @@ class ManagedModeURLFilter; |
class ManagedUserService; |
class ManagedModeNavigationObserver |
- : public content::WebContentsObserver, |
- public content::WebContentsUserData<ManagedModeNavigationObserver> { |
+ : public content::WebContentsUserData<ManagedModeNavigationObserver>, |
+ public content::WebContentsObserver, |
+ public content::NotificationObserver { |
public: |
+ typedef base::Callback<void(bool)> SuccessCallback; |
+ |
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 SuccessCallback& callback); |
+ |
// 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 +76,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 SuccessCallback& 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 +96,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 +115,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 +124,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 +158,15 @@ class ManagedModeNavigationObserver |
// Will be set to true for non-managed users. |
bool is_elevated_; |
+ base::WeakPtrFactory<ManagedModeNavigationObserver> weak_ptr_factory_; |
+ |
+ // These callbacks get queued up when we show the blocking interstitial and |
+ // are posted to the IO thread with the result of the interstitial, i.e. |
+ // whether the user successfully authenticated to continue. |
+ std::vector<SuccessCallback> callbacks_; |
+ |
+ content::NotificationRegistrar registrar_; |
+ |
int last_allowed_page_; |
DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); |