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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 }; | 62 }; |
63 | 63 |
64 friend class content::WebContentsUserData<ManagedModeNavigationObserver>; | 64 friend class content::WebContentsUserData<ManagedModeNavigationObserver>; |
65 | 65 |
66 explicit ManagedModeNavigationObserver(content::WebContents* web_contents); | 66 explicit ManagedModeNavigationObserver(content::WebContents* web_contents); |
67 | 67 |
68 // Adding the temporary exception stops the ResourceThrottle from showing | 68 // Adding the temporary exception stops the ResourceThrottle from showing |
69 // an interstitial for this RenderView. This allows the user to navigate | 69 // an interstitial for this RenderView. This allows the user to navigate |
70 // around on the website after clicking preview. | 70 // around on the website after clicking preview. |
71 void AddTemporaryException(); | 71 void AddTemporaryException(); |
72 // Updates the ResourceThrottle with the latest user navigation status. | |
73 void UpdateExceptionNavigationStatus(); | |
74 void RemoveTemporaryException(); | 72 void RemoveTemporaryException(); |
75 | 73 |
76 void AddURLToPatternList(const GURL& url); | 74 void AddURLToPatternList(const GURL& url); |
77 | 75 |
78 // content::WebContentsObserver implementation. | 76 // content::WebContentsObserver implementation. |
79 // An example regarding the order in which these events take place for | 77 // An example regarding the order in which these events take place for |
80 // google.com in our case is as follows: | 78 // google.com in our case is as follows: |
81 // 1. User types in google.com and clicks enter. | 79 // 1. User types in google.com and clicks enter. |
82 // -> NavigateToPendingEntry: http://google.com | 80 // -> NavigateToPendingEntry: http://google.com |
83 // -> DidStartProvisionalLoadForFrame http://google.com | 81 // -> DidStartProvisionalLoadForFrame http://google.com |
(...skipping 11 matching lines...) Expand all Loading... | |
95 const content::FrameNavigateParams& params) OVERRIDE; | 93 const content::FrameNavigateParams& params) OVERRIDE; |
96 virtual void ProvisionalChangeToMainFrameUrl( | 94 virtual void ProvisionalChangeToMainFrameUrl( |
97 const GURL& url, | 95 const GURL& url, |
98 content::RenderViewHost* render_view_host) OVERRIDE; | 96 content::RenderViewHost* render_view_host) OVERRIDE; |
99 virtual void DidCommitProvisionalLoadForFrame( | 97 virtual void DidCommitProvisionalLoadForFrame( |
100 int64 frame_id, | 98 int64 frame_id, |
101 bool is_main_frame, | 99 bool is_main_frame, |
102 const GURL& url, | 100 const GURL& url, |
103 content::PageTransition transition_type, | 101 content::PageTransition transition_type, |
104 content::RenderViewHost* render_view_host) OVERRIDE; | 102 content::RenderViewHost* render_view_host) OVERRIDE; |
105 virtual void DidGetUserGesture() OVERRIDE; | |
106 | 103 |
107 // Returns whether the user would stay in elevated state if he visits this | 104 // Returns whether the user would stay in elevated state if he visits this |
108 // URL. | 105 // URL. |
109 bool ShouldStayElevatedForURL(const GURL& url); | 106 bool ShouldStayElevatedForURL(const GURL& url); |
110 | 107 |
111 // Owned by the profile, so outlives us. | 108 // Owned by the profile, so outlives us. |
112 ManagedUserService* managed_user_service_; | 109 ManagedUserService* managed_user_service_; |
113 | 110 |
114 // Owned by ManagedUserService. | 111 // Owned by ManagedUserService. |
115 const ManagedModeURLFilter* url_filter_; | 112 const ManagedModeURLFilter* url_filter_; |
116 | 113 |
117 // Owned by the InfoBarService, which has the same lifetime as this object. | 114 // Owned by the InfoBarService, which has the same lifetime as this object. |
118 InfoBarDelegate* warn_infobar_delegate_; | 115 InfoBarDelegate* warn_infobar_delegate_; |
119 InfoBarDelegate* preview_infobar_delegate_; | 116 InfoBarDelegate* preview_infobar_delegate_; |
120 | 117 |
121 // Whether we received a user gesture. | |
122 // The goal is to allow automatic redirects (in order not to break the flow | |
123 // or show too many interstitials) while not allowing the user to navigate | |
124 // to blocked pages. We consider a redirect to be automatic if we did | |
125 // not get a user gesture. | |
126 bool got_user_gesture_; | |
127 ObserverState state_; | 118 ObserverState state_; |
128 std::set<GURL> navigated_urls_; | 119 std::set<GURL> navigated_urls_; |
129 GURL last_url_; | 120 GURL last_url_; |
130 | 121 |
131 // The elevation state corresponding to the current WebContents. | 122 // The elevation state corresponding to the current WebContents. |
132 // Will be set to true for non-managed users. | 123 // Will be set to true for non-managed users. |
133 bool is_elevated_; | 124 bool is_elevated_; |
134 | 125 |
135 int last_allowed_page_; | 126 int last_allowed_page_; |
127 bool after_click_on_link_; | |
Bernhard Bauer
2013/04/08 09:50:50
What does this flag mean?
Sergiu
2013/04/08 12:19:48
I've added a (pretty large) comment.
| |
136 | 128 |
137 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); | 129 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); |
138 }; | 130 }; |
139 | 131 |
140 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ | 132 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ |
OLD | NEW |