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 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" | 5 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 // ManagedModeNavigationObserver ---------------------------------------------- | 152 // ManagedModeNavigationObserver ---------------------------------------------- |
153 | 153 |
154 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver); | 154 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver); |
155 | 155 |
156 ManagedModeNavigationObserver::~ManagedModeNavigationObserver() { | 156 ManagedModeNavigationObserver::~ManagedModeNavigationObserver() { |
157 } | 157 } |
158 | 158 |
159 ManagedModeNavigationObserver::ManagedModeNavigationObserver( | 159 ManagedModeNavigationObserver::ManagedModeNavigationObserver( |
160 content::WebContents* web_contents) | 160 content::WebContents* web_contents) |
161 : WebContentsObserver(web_contents), | 161 : WebContentsObserver(web_contents), |
162 warn_infobar_delegate_(NULL), | 162 warn_infobar_delegate_(NULL) { |
163 is_elevated_(false) { | |
164 Profile* profile = | 163 Profile* profile = |
165 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 164 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
166 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); | 165 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); |
167 if (!managed_user_service_->ProfileIsManaged()) | 166 if (!managed_user_service_->ProfileIsManaged()) |
Pam (message me for reviews)
2013/05/24 11:01:24
This line needs to be removed too.
Adrian Kuegel
2013/05/24 11:07:22
Right, I missed that. Thanks for noticing.
| |
168 is_elevated_ = true; | |
169 url_filter_ = managed_user_service_->GetURLFilterForUIThread(); | 167 url_filter_ = managed_user_service_->GetURLFilterForUIThread(); |
170 } | 168 } |
171 | 169 |
172 void ManagedModeNavigationObserver::WarnInfobarDismissed() { | 170 void ManagedModeNavigationObserver::WarnInfobarDismissed() { |
173 DCHECK(warn_infobar_delegate_); | 171 DCHECK(warn_infobar_delegate_); |
174 warn_infobar_delegate_ = NULL; | 172 warn_infobar_delegate_ = NULL; |
175 } | 173 } |
176 | 174 |
177 bool ManagedModeNavigationObserver::is_elevated() const { | |
178 #if defined(OS_CHROMEOS) | |
179 return false; | |
180 #else | |
181 return is_elevated_; | |
182 #endif | |
183 } | |
184 | |
185 void ManagedModeNavigationObserver::set_elevated(bool is_elevated) { | |
186 #if defined(OS_CHROMEOS) | |
187 NOTREACHED(); | |
188 #else | |
189 is_elevated_ = is_elevated; | |
190 #endif | |
191 } | |
192 | |
193 void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl( | 175 void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl( |
194 const GURL& url, | 176 const GURL& url, |
195 content::RenderViewHost* render_view_host) { | 177 content::RenderViewHost* render_view_host) { |
196 ManagedModeURLFilter::FilteringBehavior behavior = | 178 ManagedModeURLFilter::FilteringBehavior behavior = |
197 url_filter_->GetFilteringBehaviorForURL(url); | 179 url_filter_->GetFilteringBehaviorForURL(url); |
198 | 180 |
199 if (behavior == ManagedModeURLFilter::WARN || !warn_infobar_delegate_) | 181 if (behavior == ManagedModeURLFilter::WARN || !warn_infobar_delegate_) |
200 return; | 182 return; |
201 | 183 |
202 // If we shouldn't have a warn infobar remove it here. | 184 // If we shouldn't have a warn infobar remove it here. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 HistoryService* history_service = | 234 HistoryService* history_service = |
253 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 235 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
254 | 236 |
255 // |history_service| is null if saving history is disabled. | 237 // |history_service| is null if saving history is disabled. |
256 if (history_service) | 238 if (history_service) |
257 history_service->AddPage(add_page_args); | 239 history_service->AddPage(add_page_args); |
258 | 240 |
259 // Show the interstitial. | 241 // Show the interstitial. |
260 new ManagedModeInterstitial(web_contents, url, callback); | 242 new ManagedModeInterstitial(web_contents, url, callback); |
261 } | 243 } |
OLD | NEW |