OLD | NEW |
---|---|
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> | 8 #include <set> |
9 | 9 |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 bool CanTemporarilyNavigateHost(const GURL& url); | 33 bool CanTemporarilyNavigateHost(const GURL& url); |
34 | 34 |
35 // Clears the state recorded in the observer. | 35 // Clears the state recorded in the observer. |
36 void ClearObserverState(); | 36 void ClearObserverState(); |
37 | 37 |
38 // Whitelists exact URLs for redirects and host patterns for the final URL. | 38 // Whitelists exact URLs for redirects and host patterns for the final URL. |
39 // If the URL uses HTTPS, whitelists only the host on HTTPS. Clears the | 39 // If the URL uses HTTPS, whitelists only the host on HTTPS. Clears the |
40 // observer state after adding the URLs. | 40 // observer state after adding the URLs. |
41 void AddSavedURLsToWhitelistAndClearState(); | 41 void AddSavedURLsToWhitelistAndClearState(); |
42 | 42 |
43 // Returns the elevation state for the corresponding WebContents. | |
44 bool is_elevated() const; | |
45 | |
46 // Set the elevation state for the corresponding WebContents. | |
47 void set_elevated(bool is_elevated); | |
48 | |
43 private: | 49 private: |
44 // An observer can be in one of the following states: | 50 // An observer can be in one of the following states: |
45 // - RECORDING_URLS_BEFORE_PREVIEW: This is the initial state when the user | 51 // - RECORDING_URLS_BEFORE_PREVIEW: This is the initial state when the user |
46 // navigates to a new page. In this state the navigated URLs that should be | 52 // navigates to a new page. In this state the navigated URLs that should be |
47 // blocked are recorded. The Observer moves to the next state when an | 53 // blocked are recorded. The Observer moves to the next state when an |
48 // interstitial was shown and the user clicked "Preview" on the interstitial. | 54 // interstitial was shown and the user clicked "Preview" on the interstitial. |
49 // - RECORDING_URLS_AFTER_PREVIEW: URLs that should be blocked are | 55 // - RECORDING_URLS_AFTER_PREVIEW: URLs that should be blocked are |
50 // still recorded while the page redirects. The Observer moves to the next | 56 // still recorded while the page redirects. The Observer moves to the next |
51 // state after the page finished redirecting (DidNavigateMainFrame gets | 57 // state after the page finished redirecting (DidNavigateMainFrame gets |
52 // called). | 58 // called). |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 const GURL& url, | 105 const GURL& url, |
100 content::RenderViewHost* render_view_host) OVERRIDE; | 106 content::RenderViewHost* render_view_host) OVERRIDE; |
101 virtual void DidCommitProvisionalLoadForFrame( | 107 virtual void DidCommitProvisionalLoadForFrame( |
102 int64 frame_id, | 108 int64 frame_id, |
103 bool is_main_frame, | 109 bool is_main_frame, |
104 const GURL& url, | 110 const GURL& url, |
105 content::PageTransition transition_type, | 111 content::PageTransition transition_type, |
106 content::RenderViewHost* render_view_host) OVERRIDE; | 112 content::RenderViewHost* render_view_host) OVERRIDE; |
107 virtual void DidGetUserGesture() OVERRIDE; | 113 virtual void DidGetUserGesture() OVERRIDE; |
108 | 114 |
115 // Returns whether the user would stay in elevated state if he visits this | |
Bernhard Bauer
2013/03/21 15:52:58
Naming nit: "ShouldStayElevated"?
Adrian Kuegel
2013/03/21 16:30:04
Done.
| |
116 // URL. | |
117 bool WillStayElevatedForURL(const GURL& url); | |
118 | |
109 // Owned by the profile, so outlives us. | 119 // Owned by the profile, so outlives us. |
110 ManagedUserService* managed_user_service_; | 120 ManagedUserService* managed_user_service_; |
111 | 121 |
112 // Owned by ManagedUserService. | 122 // Owned by ManagedUserService. |
113 const ManagedModeURLFilter* url_filter_; | 123 const ManagedModeURLFilter* url_filter_; |
114 | 124 |
115 // Owned by the InfoBarService, which has the same lifetime as this object. | 125 // Owned by the InfoBarService, which has the same lifetime as this object. |
116 InfoBarDelegate* warn_infobar_delegate_; | 126 InfoBarDelegate* warn_infobar_delegate_; |
117 InfoBarDelegate* preview_infobar_delegate_; | 127 InfoBarDelegate* preview_infobar_delegate_; |
118 | 128 |
119 // Whether we received a user gesture. | 129 // Whether we received a user gesture. |
120 // The goal is to allow automatic redirects (in order not to break the flow | 130 // The goal is to allow automatic redirects (in order not to break the flow |
121 // or show too many interstitials) while not allowing the user to navigate | 131 // or show too many interstitials) while not allowing the user to navigate |
122 // to blocked pages. We consider a redirect to be automatic if we did | 132 // to blocked pages. We consider a redirect to be automatic if we did |
123 // not get a user gesture. | 133 // not get a user gesture. |
124 bool got_user_gesture_; | 134 bool got_user_gesture_; |
125 ObserverState state_; | 135 ObserverState state_; |
126 std::set<GURL> navigated_urls_; | 136 std::set<GURL> navigated_urls_; |
127 GURL last_url_; | 137 GURL last_url_; |
128 | 138 |
139 // The elevation state corresponding to the current WebContents. | |
140 // Will be set to true for non-managed users. | |
141 bool is_elevated_; | |
142 | |
129 int last_allowed_page_; | 143 int last_allowed_page_; |
130 | 144 |
131 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); | 145 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); |
132 }; | 146 }; |
133 | 147 |
134 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ | 148 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ |
OLD | NEW |