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

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 according 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..c608923e8114965400419d32e6b84e747ec2dbba 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"
@@ -17,27 +17,46 @@ class ManagedModeNavigationObserver
public:
virtual ~ManagedModeNavigationObserver();
+ // The resource throttle contains an observer:hostname map to check when
+ // deciding whether to show an interstitial or not. These functions
+ // add/remove the current observer to/from that map.
Bernhard Bauer 2012/11/27 18:44:46 The map is from RenderView to hostname, not from o
Sergiu 2012/11/28 12:53:25 Done.
+ void AddTemporaryException();
Bernhard Bauer 2012/11/27 18:44:46 Can you make these methods private?
Sergiu 2012/11/28 12:53:25 Done.
+ void RemoveTemporaryException();
+
+ // 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);
+ // 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;
@@ -65,14 +84,21 @@ class ManagedModeNavigationObserver
// Owned by ManagedMode (which is a singleton and outlives us).
const ManagedModeURLFilter* url_filter_;
+ enum ObserverState {
Bernhard Bauer 2012/11/27 18:44:46 Type declarations like enums come before methods.
Sergiu 2012/11/28 12:53:25 Done.
+ RECORDING_URLS_BEFORE_PREVIEW,
Bernhard Bauer 2012/11/27 18:44:46 We should have some explanation for these states.
Sergiu 2012/11/28 12:53:25 I've commented the states near the definition, ple
+ RECORDING_URLS_AFTER_PREVIEW,
+ NOT_RECORDING_URLS,
+ };
+
+ ObserverState state_;
Bernhard Bauer 2012/11/27 18:44:46 I think it would be nice if we could group state m
Sergiu 2012/11/28 12:53:25 Hopefully better now.
+
InfoBarDelegate* warn_infobar_delegate_;
InfoBarDelegate* preview_infobar_delegate_;
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