| 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..e8c8e99a91599ac156a169662e6ed6d3a45891ea 100644
|
| --- a/chrome/browser/managed_mode/managed_mode_navigation_observer.h
|
| +++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.h
|
| @@ -2,9 +2,10 @@
|
| // 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 "base/values.h"
|
| #include "content/public/browser/web_contents_observer.h"
|
| #include "content/public/browser/web_contents_user_data.h"
|
|
|
| @@ -17,27 +18,62 @@ class ManagedModeNavigationObserver
|
| public:
|
| 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:
|
| + // 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 that should be
|
| + // blocked are recorded. The Observer moves to the next state when an
|
| + // interstitial was shown and the user clicked "Preview" on the interstitial.
|
| + // - RECORDING_URLS_AFTER_PREVIEW: URLs that should be blocked are
|
| + // still recorded while the page redirect. The Observer moves to the next
|
| + // state after the page finished redirecting (DidNavigateMainFrame gets
|
| + // called).
|
| + // - NOT_RECORDING_URLS: The redirects have completed and blocked URLs are
|
| + // no longer being recorded.
|
| + enum ObserverState {
|
| + RECORDING_URLS_BEFORE_PREVIEW,
|
| + RECORDING_URLS_AFTER_PREVIEW,
|
| + NOT_RECORDING_URLS,
|
| + };
|
| +
|
| 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();
|
| +
|
| + void AddURLToPatternList(const GURL& url);
|
| + void AddURLAsLastPattern(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 +103,14 @@ class ManagedModeNavigationObserver
|
|
|
| InfoBarDelegate* warn_infobar_delegate_;
|
| InfoBarDelegate* preview_infobar_delegate_;
|
| - std::vector<GURL> navigated_urls_;
|
| - bool after_interstitial_;
|
| +
|
| + ObserverState state_;
|
| + base::ListValue url_patterns_;
|
| + std::string last_url_pattern_;
|
|
|
| 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_
|
|
|