| 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 27 matching lines...) Expand all Loading... |
| 80 // -> ProvisionalChangeToMainFrameUrl http://www.google.com (redirect) | 86 // -> ProvisionalChangeToMainFrameUrl http://www.google.com (redirect) |
| 81 // -> DidCommitProvisionalLoadForFrame http://www.google.com (redirect) | 87 // -> DidCommitProvisionalLoadForFrame http://www.google.com (redirect) |
| 82 // -> DidNavigateMainFrame http://www.google.com | 88 // -> DidNavigateMainFrame http://www.google.com |
| 83 // 3. Page is shown. | 89 // 3. Page is shown. |
| 84 virtual void NavigateToPendingEntry( | 90 virtual void NavigateToPendingEntry( |
| 85 const GURL& url, | 91 const GURL& url, |
| 86 content::NavigationController::ReloadType reload_type) OVERRIDE; | 92 content::NavigationController::ReloadType reload_type) OVERRIDE; |
| 87 virtual void DidNavigateMainFrame( | 93 virtual void DidNavigateMainFrame( |
| 88 const content::LoadCommittedDetails& details, | 94 const content::LoadCommittedDetails& details, |
| 89 const content::FrameNavigateParams& params) OVERRIDE; | 95 const content::FrameNavigateParams& params) OVERRIDE; |
| 90 virtual void DidStartProvisionalLoadForFrame( | |
| 91 int64 frame_id, | |
| 92 int64 parent_frame_id, | |
| 93 bool is_main_frame, | |
| 94 const GURL& validated_url, | |
| 95 bool is_error_page, | |
| 96 bool is_iframe_srcdoc, | |
| 97 content::RenderViewHost* render_view_host) OVERRIDE; | |
| 98 virtual void ProvisionalChangeToMainFrameUrl( | 96 virtual void ProvisionalChangeToMainFrameUrl( |
| 99 const GURL& url, | 97 const GURL& url, |
| 100 content::RenderViewHost* render_view_host) OVERRIDE; | 98 content::RenderViewHost* render_view_host) OVERRIDE; |
| 101 virtual void DidCommitProvisionalLoadForFrame( | 99 virtual void DidCommitProvisionalLoadForFrame( |
| 102 int64 frame_id, | 100 int64 frame_id, |
| 103 bool is_main_frame, | 101 bool is_main_frame, |
| 104 const GURL& url, | 102 const GURL& url, |
| 105 content::PageTransition transition_type, | 103 content::PageTransition transition_type, |
| 106 content::RenderViewHost* render_view_host) OVERRIDE; | 104 content::RenderViewHost* render_view_host) OVERRIDE; |
| 107 virtual void DidGetUserGesture() OVERRIDE; | 105 virtual void DidGetUserGesture() OVERRIDE; |
| 108 | 106 |
| 107 // Returns whether the user would stay in elevated state if he visits this |
| 108 // URL. |
| 109 bool ShouldStayElevatedForURL(const GURL& url); |
| 110 |
| 109 // Owned by the profile, so outlives us. | 111 // Owned by the profile, so outlives us. |
| 110 ManagedUserService* managed_user_service_; | 112 ManagedUserService* managed_user_service_; |
| 111 | 113 |
| 112 // Owned by ManagedUserService. | 114 // Owned by ManagedUserService. |
| 113 const ManagedModeURLFilter* url_filter_; | 115 const ManagedModeURLFilter* url_filter_; |
| 114 | 116 |
| 115 // Owned by the InfoBarService, which has the same lifetime as this object. | 117 // Owned by the InfoBarService, which has the same lifetime as this object. |
| 116 InfoBarDelegate* warn_infobar_delegate_; | 118 InfoBarDelegate* warn_infobar_delegate_; |
| 117 InfoBarDelegate* preview_infobar_delegate_; | 119 InfoBarDelegate* preview_infobar_delegate_; |
| 118 | 120 |
| 119 // Whether we received a user gesture. | 121 // Whether we received a user gesture. |
| 120 // The goal is to allow automatic redirects (in order not to break the flow | 122 // 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 | 123 // 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 | 124 // to blocked pages. We consider a redirect to be automatic if we did |
| 123 // not get a user gesture. | 125 // not get a user gesture. |
| 124 bool got_user_gesture_; | 126 bool got_user_gesture_; |
| 125 ObserverState state_; | 127 ObserverState state_; |
| 126 std::set<GURL> navigated_urls_; | 128 std::set<GURL> navigated_urls_; |
| 127 GURL last_url_; | 129 GURL last_url_; |
| 128 | 130 |
| 131 // The elevation state corresponding to the current WebContents. |
| 132 // Will be set to true for non-managed users. |
| 133 bool is_elevated_; |
| 134 |
| 129 int last_allowed_page_; | 135 int last_allowed_page_; |
| 130 | 136 |
| 131 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); | 137 DISALLOW_COPY_AND_ASSIGN(ManagedModeNavigationObserver); |
| 132 }; | 138 }; |
| 133 | 139 |
| 134 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ | 140 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_NAVIGATION_OBSERVER_H_ |
| OLD | NEW |