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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // ManagedModeNavigationObserver ---------------------------------------------- | 155 // ManagedModeNavigationObserver ---------------------------------------------- |
156 | 156 |
157 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver); | 157 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver); |
158 | 158 |
159 ManagedModeNavigationObserver::~ManagedModeNavigationObserver() { | 159 ManagedModeNavigationObserver::~ManagedModeNavigationObserver() { |
160 } | 160 } |
161 | 161 |
162 ManagedModeNavigationObserver::ManagedModeNavigationObserver( | 162 ManagedModeNavigationObserver::ManagedModeNavigationObserver( |
163 content::WebContents* web_contents) | 163 content::WebContents* web_contents) |
164 : WebContentsObserver(web_contents), | 164 : WebContentsObserver(web_contents), |
165 warn_infobar_delegate_(NULL), | 165 warn_infobar_delegate_(NULL) { |
166 is_elevated_(false) { | |
167 Profile* profile = | 166 Profile* profile = |
168 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 167 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
169 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); | 168 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); |
170 if (!managed_user_service_->ProfileIsManaged()) | |
171 is_elevated_ = true; | |
172 url_filter_ = managed_user_service_->GetURLFilterForUIThread(); | 169 url_filter_ = managed_user_service_->GetURLFilterForUIThread(); |
173 } | 170 } |
174 | 171 |
175 void ManagedModeNavigationObserver::WarnInfobarDismissed() { | 172 void ManagedModeNavigationObserver::WarnInfobarDismissed() { |
176 DCHECK(warn_infobar_delegate_); | 173 DCHECK(warn_infobar_delegate_); |
177 warn_infobar_delegate_ = NULL; | 174 warn_infobar_delegate_ = NULL; |
178 } | 175 } |
179 | 176 |
180 bool ManagedModeNavigationObserver::is_elevated() const { | |
181 #if defined(OS_CHROMEOS) | |
182 return false; | |
183 #else | |
184 return is_elevated_; | |
185 #endif | |
186 } | |
187 | |
188 void ManagedModeNavigationObserver::set_elevated(bool is_elevated) { | |
189 #if defined(OS_CHROMEOS) | |
190 NOTREACHED(); | |
191 #else | |
192 is_elevated_ = is_elevated; | |
193 #endif | |
194 } | |
195 | |
196 void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl( | 177 void ManagedModeNavigationObserver::ProvisionalChangeToMainFrameUrl( |
197 const GURL& url, | 178 const GURL& url, |
198 content::RenderViewHost* render_view_host) { | 179 content::RenderViewHost* render_view_host) { |
199 ManagedModeURLFilter::FilteringBehavior behavior = | 180 ManagedModeURLFilter::FilteringBehavior behavior = |
200 url_filter_->GetFilteringBehaviorForURL(url); | 181 url_filter_->GetFilteringBehaviorForURL(url); |
201 | 182 |
202 if (behavior == ManagedModeURLFilter::WARN || !warn_infobar_delegate_) | 183 if (behavior == ManagedModeURLFilter::WARN || !warn_infobar_delegate_) |
203 return; | 184 return; |
204 | 185 |
205 // If we shouldn't have a warn infobar remove it here. | 186 // If we shouldn't have a warn infobar remove it here. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 249 |
269 // |history_service| is null if saving history is disabled. | 250 // |history_service| is null if saving history is disabled. |
270 if (history_service) | 251 if (history_service) |
271 history_service->AddPage(add_page_args); | 252 history_service->AddPage(add_page_args); |
272 | 253 |
273 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 254 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
274 entry->SetVirtualURL(url); | 255 entry->SetVirtualURL(url); |
275 entry->SetTimestamp(timestamp); | 256 entry->SetTimestamp(timestamp); |
276 blocked_navigations_.push_back(entry.release()); | 257 blocked_navigations_.push_back(entry.release()); |
277 } | 258 } |
OLD | NEW |