Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2317)

Unified Diff: chrome/browser/managed_mode/managed_mode_navigation_observer.h

Issue 11299035: Support manual (white|black)list, previewing and allowing after interstitial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 8ac23a817f41bd3865582df722ccf7c04e8f6203..f048e8acaa7ffae7ac738522ae1bd0da3de8da4b 100644
--- a/chrome/browser/managed_mode/managed_mode_navigation_observer.h
+++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_MANAGED_MODE_NAVIGATION_OBSERVER_H_
-#define CHROME_BROWSER_MANAGED_MODE_NAVIGATION_OBSERVER_H_
+#ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
+#define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
@@ -15,29 +15,62 @@ class ManagedModeNavigationObserver
: public content::WebContentsObserver,
public content::WebContentsUserData<ManagedModeNavigationObserver> {
public:
+ // An observer can be in one of the following states:
+ // - RECORDING_URLS_BEFORE_PREVIEW: This is the initial state when the user
+ // navigates to a new page. In this state the navigated URLs are recorded.
Bernhard Bauer 2012/11/28 14:21:05 Do we record all navigated URLs in this state, or
Sergiu 2012/11/29 12:00:17 Done.
+ // An interstitial was not shown while in this state.
Bernhard Bauer 2012/11/28 14:21:05 This sentence is difficult to understand. I think
Sergiu 2012/11/29 12:00:17 Done.
+ // - RECORDING_URLS_AFTER_PREVIEW: In this state an interstitial was shown
+ // to the user and "Preview" was clicked. URLs are still recorded while the
+ // page may still be redirecting.
+ // - NOT_RECORDING_URLS: The redirects have completed and URLs are no longer
+ // recorded.
+ enum ObserverState {
Bernhard Bauer 2012/11/28 14:21:05 This enum doesn't need to be public, it just needs
Sergiu 2012/11/29 12:00:17 Done.
+ RECORDING_URLS_BEFORE_PREVIEW,
+ RECORDING_URLS_AFTER_PREVIEW,
+ NOT_RECORDING_URLS,
+ };
+
virtual ~ManagedModeNavigationObserver();
+ // Sets the specific infobar as dismissed.
void WarnInfobarDismissed();
void PreviewInfobarDismissed();
- // Adds the url to the list of navigated URLs if it was not already there.
- void AddNavigatedURL(const GURL& url);
+ // Sets the state of the Observer from the outside.
+ void SetStateToRecordingAfterPreview();
- // For the list of URLs that were navigated since the last Observer
- // instantiation:
- // * add the first N-1 to the whitelist such that only those URLs are
- // allowed and not more general versions of them.
- // * add only the host part of the last URL so that it allows all
- // pages on that domain. If it's HTTPS do the same but only on the HTTPS
- // protocol.
- void AddURLList();
+ // Clears the state recorded in the observer.
+ void ClearObserverState();
+
+ // Whitelist exact URLs for redirects and host patterns for the final URL.
+ // If the URL uses HTTPS whitelist only the host on HTTPS.
+ void AddSavedURLsToWhitelist();
private:
friend class WebContentsUserData<ManagedModeNavigationObserver>;
explicit ManagedModeNavigationObserver(content::WebContents* web_contents);
+ // Adding the temporary exception stops the ResourceThrottle from showing
+ // an interstitial for this RenderView.
+ void AddTemporaryException();
+ void RemoveTemporaryException();
+
+ // Adds the url to the list of navigated URLs if it was not already there.
+ void SaveNavigatedURL(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:
+ // 1. User types in google.com and clicks enter.
+ // -> NavigateToPendingEntry: http://google.com
+ // -> DidStartProvisionalLoadForFrame http://google.com
+ // -> ProvisionalChangeToMainFrameUrl http://google.com
+ // 2. Interstitial is shown to the user. User clicks "Preview".
+ // -> ProvisionalChangeToMainFrameUrl http://www.google.com (redirect)
+ // -> DidCommitProvisionalLoadForFrame http://www.google.com (redirect)
+ // -> DidNavigateMainFrame http://www.google.com
+ // 3. Page is shown.
virtual void NavigateToPendingEntry(
const GURL& url,
content::NavigationController::ReloadType reload_type) OVERRIDE;
@@ -67,12 +100,13 @@ class ManagedModeNavigationObserver
InfoBarDelegate* warn_infobar_delegate_;
InfoBarDelegate* preview_infobar_delegate_;
+
+ ObserverState state_;
std::vector<GURL> navigated_urls_;
- bool after_interstitial_;
int last_allowed_page_;
DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver);
};
-#endif // CHROME_BROWSER_MANAGED_MODE_NAVIGATION_OBSERVER_H_
+#endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698