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

Side by Side 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 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_MANAGED_MODE_NAVIGATION_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
6 #define CHROME_BROWSER_MANAGED_MODE_NAVIGATION_OBSERVER_H_ 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
7 7
8 #include "content/public/browser/web_contents_observer.h" 8 #include "content/public/browser/web_contents_observer.h"
9 #include "content/public/browser/web_contents_user_data.h" 9 #include "content/public/browser/web_contents_user_data.h"
10 10
11 class InfoBarDelegate; 11 class InfoBarDelegate;
12 class ManagedModeURLFilter; 12 class ManagedModeURLFilter;
13 13
14 class ManagedModeNavigationObserver 14 class ManagedModeNavigationObserver
15 : public content::WebContentsObserver, 15 : public content::WebContentsObserver,
16 public content::WebContentsUserData<ManagedModeNavigationObserver> { 16 public content::WebContentsUserData<ManagedModeNavigationObserver> {
17 public: 17 public:
18 // An observer can be in one of the following states:
19 // - RECORDING_URLS_BEFORE_PREVIEW: This is the initial state when the user
20 // 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.
21 // 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.
22 // - RECORDING_URLS_AFTER_PREVIEW: In this state an interstitial was shown
23 // to the user and "Preview" was clicked. URLs are still recorded while the
24 // page may still be redirecting.
25 // - NOT_RECORDING_URLS: The redirects have completed and URLs are no longer
26 // recorded.
27 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.
28 RECORDING_URLS_BEFORE_PREVIEW,
29 RECORDING_URLS_AFTER_PREVIEW,
30 NOT_RECORDING_URLS,
31 };
32
18 virtual ~ManagedModeNavigationObserver(); 33 virtual ~ManagedModeNavigationObserver();
19 34
35 // Sets the specific infobar as dismissed.
20 void WarnInfobarDismissed(); 36 void WarnInfobarDismissed();
21 void PreviewInfobarDismissed(); 37 void PreviewInfobarDismissed();
22 38
23 // Adds the url to the list of navigated URLs if it was not already there. 39 // Sets the state of the Observer from the outside.
24 void AddNavigatedURL(const GURL& url); 40 void SetStateToRecordingAfterPreview();
25 41
26 // For the list of URLs that were navigated since the last Observer 42 // Clears the state recorded in the observer.
27 // instantiation: 43 void ClearObserverState();
28 // * add the first N-1 to the whitelist such that only those URLs are 44
29 // allowed and not more general versions of them. 45 // Whitelist exact URLs for redirects and host patterns for the final URL.
30 // * add only the host part of the last URL so that it allows all 46 // If the URL uses HTTPS whitelist only the host on HTTPS.
31 // pages on that domain. If it's HTTPS do the same but only on the HTTPS 47 void AddSavedURLsToWhitelist();
32 // protocol.
33 void AddURLList();
34 48
35 private: 49 private:
36 friend class WebContentsUserData<ManagedModeNavigationObserver>; 50 friend class WebContentsUserData<ManagedModeNavigationObserver>;
37 51
38 explicit ManagedModeNavigationObserver(content::WebContents* web_contents); 52 explicit ManagedModeNavigationObserver(content::WebContents* web_contents);
39 53
54 // Adding the temporary exception stops the ResourceThrottle from showing
55 // an interstitial for this RenderView.
56 void AddTemporaryException();
57 void RemoveTemporaryException();
58
59 // Adds the url to the list of navigated URLs if it was not already there.
60 void SaveNavigatedURL(const GURL& url);
61
40 // content::WebContentsObserver implementation. 62 // content::WebContentsObserver implementation.
63 // An example regarding the order in which these events take place for
64 // google.com in our case is as follows:
65 // 1. User types in google.com and clicks enter.
66 // -> NavigateToPendingEntry: http://google.com
67 // -> DidStartProvisionalLoadForFrame http://google.com
68 // -> ProvisionalChangeToMainFrameUrl http://google.com
69 // 2. Interstitial is shown to the user. User clicks "Preview".
70 // -> ProvisionalChangeToMainFrameUrl http://www.google.com (redirect)
71 // -> DidCommitProvisionalLoadForFrame http://www.google.com (redirect)
72 // -> DidNavigateMainFrame http://www.google.com
73 // 3. Page is shown.
41 virtual void NavigateToPendingEntry( 74 virtual void NavigateToPendingEntry(
42 const GURL& url, 75 const GURL& url,
43 content::NavigationController::ReloadType reload_type) OVERRIDE; 76 content::NavigationController::ReloadType reload_type) OVERRIDE;
44 virtual void DidNavigateMainFrame( 77 virtual void DidNavigateMainFrame(
45 const content::LoadCommittedDetails& details, 78 const content::LoadCommittedDetails& details,
46 const content::FrameNavigateParams& params) OVERRIDE; 79 const content::FrameNavigateParams& params) OVERRIDE;
47 virtual void DidStartProvisionalLoadForFrame( 80 virtual void DidStartProvisionalLoadForFrame(
48 int64 frame_id, 81 int64 frame_id,
49 int64 parent_frame_id, 82 int64 parent_frame_id,
50 bool is_main_frame, 83 bool is_main_frame,
51 const GURL& url, 84 const GURL& url,
52 bool is_error_page, 85 bool is_error_page,
53 content::RenderViewHost* render_view_host) OVERRIDE; 86 content::RenderViewHost* render_view_host) OVERRIDE;
54 virtual void ProvisionalChangeToMainFrameUrl( 87 virtual void ProvisionalChangeToMainFrameUrl(
55 const GURL& url, 88 const GURL& url,
56 const GURL& opener_url, 89 const GURL& opener_url,
57 content::RenderViewHost* render_view_host) OVERRIDE; 90 content::RenderViewHost* render_view_host) OVERRIDE;
58 virtual void DidCommitProvisionalLoadForFrame( 91 virtual void DidCommitProvisionalLoadForFrame(
59 int64 frame_id, 92 int64 frame_id,
60 bool is_main_frame, 93 bool is_main_frame,
61 const GURL& url, 94 const GURL& url,
62 content::PageTransition transition_type, 95 content::PageTransition transition_type,
63 content::RenderViewHost* render_view_host) OVERRIDE; 96 content::RenderViewHost* render_view_host) OVERRIDE;
64 97
65 // Owned by ManagedMode (which is a singleton and outlives us). 98 // Owned by ManagedMode (which is a singleton and outlives us).
66 const ManagedModeURLFilter* url_filter_; 99 const ManagedModeURLFilter* url_filter_;
67 100
68 InfoBarDelegate* warn_infobar_delegate_; 101 InfoBarDelegate* warn_infobar_delegate_;
69 InfoBarDelegate* preview_infobar_delegate_; 102 InfoBarDelegate* preview_infobar_delegate_;
103
104 ObserverState state_;
70 std::vector<GURL> navigated_urls_; 105 std::vector<GURL> navigated_urls_;
71 bool after_interstitial_;
72 106
73 int last_allowed_page_; 107 int last_allowed_page_;
74 108
75 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); 109 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver);
76 }; 110 };
77 111
78 #endif // CHROME_BROWSER_MANAGED_MODE_NAVIGATION_OBSERVER_H_ 112 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698