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

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: Minor changes Created 7 years, 11 months 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_MANAGED_MODE_NAVIGATION_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
7 7
8 #include <set>
9
10 #include "base/values.h"
8 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
9 #include "content/public/browser/web_contents_user_data.h" 12 #include "content/public/browser/web_contents_user_data.h"
10 13
11 class InfoBarDelegate; 14 class InfoBarDelegate;
12 class ManagedModeURLFilter; 15 class ManagedModeURLFilter;
13 16
14 class ManagedModeNavigationObserver 17 class ManagedModeNavigationObserver
15 : public content::WebContentsObserver, 18 : public content::WebContentsObserver,
16 public content::WebContentsUserData<ManagedModeNavigationObserver> { 19 public content::WebContentsUserData<ManagedModeNavigationObserver> {
17 public: 20 public:
18 virtual ~ManagedModeNavigationObserver(); 21 virtual ~ManagedModeNavigationObserver();
19 22
23 // Sets the specific infobar as dismissed.
20 void WarnInfobarDismissed(); 24 void WarnInfobarDismissed();
25 void PreviewInfobarDismissed();
26
27 // Sets the state of the Observer from the outside.
28 void SetStateToRecordingAfterPreview();
29
30 // Returns whether the user should be allowed to navigate to this URL after
31 // he has clicked "Preview" on the interstitial.
32 bool CanTemporarilyNavigateHost(const GURL& url);
33
34 // Clears the state recorded in the observer.
35 void ClearObserverState();
36
37 // Whitelists exact URLs for redirects and host patterns for the final URL.
38 // If the URL uses HTTPS, whitelists only the host on HTTPS. Clears the
39 // observer state after adding the URLs.
40 void AddSavedURLsToWhitelistAndClearState();
21 41
22 private: 42 private:
43 // An observer can be in one of the following states:
44 // - RECORDING_URLS_BEFORE_PREVIEW: This is the initial state when the user
45 // navigates to a new page. In this state the navigated URLs that should be
46 // blocked are recorded. The Observer moves to the next state when an
47 // interstitial was shown and the user clicked "Preview" on the interstitial.
48 // - RECORDING_URLS_AFTER_PREVIEW: URLs that should be blocked are
49 // still recorded while the page redirects. The Observer moves to the next
50 // state after the page finished redirecting (DidNavigateMainFrame gets
51 // called).
52 // - NOT_RECORDING_URLS: The redirects have completed and blocked URLs are
53 // no longer being recorded.
54 enum ObserverState {
55 RECORDING_URLS_BEFORE_PREVIEW,
56 RECORDING_URLS_AFTER_PREVIEW,
57 NOT_RECORDING_URLS,
58 };
59
23 friend class content::WebContentsUserData<ManagedModeNavigationObserver>; 60 friend class content::WebContentsUserData<ManagedModeNavigationObserver>;
24 61
25 explicit ManagedModeNavigationObserver(content::WebContents* web_contents); 62 explicit ManagedModeNavigationObserver(content::WebContents* web_contents);
26 63
64 // Adding the temporary exception stops the ResourceThrottle from showing
65 // an interstitial for this RenderView. This allows the user to navigate
66 // around on the website after clicking preview.
67 void AddTemporaryException();
68 void RemoveTemporaryException();
69
70 void AddURLToPatternList(const GURL& url);
71 void AddURLAsLastPattern(const GURL& url);
72
27 // content::WebContentsObserver implementation. 73 // content::WebContentsObserver implementation.
74 // An example regarding the order in which these events take place for
75 // google.com in our case is as follows:
76 // 1. User types in google.com and clicks enter.
77 // -> NavigateToPendingEntry: http://google.com
78 // -> DidStartProvisionalLoadForFrame http://google.com
79 // -> ProvisionalChangeToMainFrameUrl http://google.com
80 // 2. Interstitial is shown to the user. User clicks "Preview".
81 // -> ProvisionalChangeToMainFrameUrl http://www.google.com (redirect)
82 // -> DidCommitProvisionalLoadForFrame http://www.google.com (redirect)
83 // -> DidNavigateMainFrame http://www.google.com
84 // 3. Page is shown.
85 virtual void NavigateToPendingEntry(
86 const GURL& url,
87 content::NavigationController::ReloadType reload_type) OVERRIDE;
88 virtual void DidNavigateMainFrame(
89 const content::LoadCommittedDetails& details,
90 const content::FrameNavigateParams& params) OVERRIDE;
91 virtual void DidStartProvisionalLoadForFrame(
92 int64 frame_id,
93 int64 parent_frame_id,
94 bool is_main_frame,
95 const GURL& validated_url,
96 bool is_error_page,
97 bool is_iframe_srcdoc,
98 content::RenderViewHost* render_view_host) OVERRIDE;
99 virtual void ProvisionalChangeToMainFrameUrl(
100 const GURL& url,
101 content::RenderViewHost* render_view_host) OVERRIDE;
28 virtual void DidCommitProvisionalLoadForFrame( 102 virtual void DidCommitProvisionalLoadForFrame(
29 int64 frame_id, 103 int64 frame_id,
30 bool is_main_frame, 104 bool is_main_frame,
31 const GURL& url, 105 const GURL& url,
32 content::PageTransition transition_type, 106 content::PageTransition transition_type,
33 content::RenderViewHost* render_view_host) OVERRIDE; 107 content::RenderViewHost* render_view_host) OVERRIDE;
34 108
35 // Owned by ManagedMode (which is a singleton and outlives us). 109 // Owned by ManagedMode (which is a singleton and outlives us).
36 const ManagedModeURLFilter* url_filter_; 110 const ManagedModeURLFilter* url_filter_;
37 111
38 // Owned by the InfoBarService, which has the same lifetime as this object. 112 // Owned by the InfoBarService, which has the same lifetime as this object.
39 InfoBarDelegate* warn_infobar_delegate_; 113 InfoBarDelegate* warn_infobar_delegate_;
114 InfoBarDelegate* preview_infobar_delegate_;
115
116 ObserverState state_;
117 std::set<GURL> navigated_urls_;
118 GURL last_url_;
119
120 int last_allowed_page_;
40 121
41 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); 122 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver);
42 }; 123 };
43 124
44 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ 125 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698