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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 content::BrowserThread::IO, FROM_HERE, base::Bind(callback, false)); | 226 content::BrowserThread::IO, FROM_HERE, base::Bind(callback, false)); |
227 return; | 227 return; |
228 } | 228 } |
229 | 229 |
230 ManagedModeNavigationObserver* navigation_observer = | 230 ManagedModeNavigationObserver* navigation_observer = |
231 ManagedModeNavigationObserver::FromWebContents(web_contents); | 231 ManagedModeNavigationObserver::FromWebContents(web_contents); |
232 if (navigation_observer) | 232 if (navigation_observer) |
233 navigation_observer->OnRequestBlockedInternal(url); | 233 navigation_observer->OnRequestBlockedInternal(url); |
234 | 234 |
235 // Show the interstitial. | 235 // Show the interstitial. |
236 new ManagedModeInterstitial(web_contents, url, callback); | 236 ManagedModeInterstitial::Show(web_contents, url, callback); |
237 } | 237 } |
238 | 238 |
239 void ManagedModeNavigationObserver::OnRequestBlockedInternal(const GURL& url) { | 239 void ManagedModeNavigationObserver::OnRequestBlockedInternal(const GURL& url) { |
240 Time timestamp = Time::Now(); // TODO(bauerb): Use SaneTime when available. | 240 Time timestamp = Time::Now(); // TODO(bauerb): Use SaneTime when available. |
241 // Create a history entry for the attempt and mark it as such. | 241 // Create a history entry for the attempt and mark it as such. |
242 history::HistoryAddPageArgs add_page_args( | 242 history::HistoryAddPageArgs add_page_args( |
243 url, timestamp, web_contents(), 0, | 243 url, timestamp, web_contents(), 0, |
244 url, history::RedirectList(), | 244 url, history::RedirectList(), |
245 content::PAGE_TRANSITION_BLOCKED, history::SOURCE_BROWSED, | 245 content::PAGE_TRANSITION_BLOCKED, history::SOURCE_BROWSED, |
246 false); | 246 false); |
247 | 247 |
248 // Add the entry to the history database. | 248 // Add the entry to the history database. |
249 Profile* profile = | 249 Profile* profile = |
250 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 250 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
251 HistoryService* history_service = | 251 HistoryService* history_service = |
252 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 252 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
253 | 253 |
254 // |history_service| is null if saving history is disabled. | 254 // |history_service| is null if saving history is disabled. |
255 if (history_service) | 255 if (history_service) |
256 history_service->AddPage(add_page_args); | 256 history_service->AddPage(add_page_args); |
257 | 257 |
258 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 258 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
259 entry->SetVirtualURL(url); | 259 entry->SetVirtualURL(url); |
260 entry->SetTimestamp(timestamp); | 260 entry->SetTimestamp(timestamp); |
261 blocked_navigations_.push_back(entry.release()); | 261 blocked_navigations_.push_back(entry.release()); |
262 ManagedUserService* managed_user_service = | 262 ManagedUserService* managed_user_service = |
263 ManagedUserServiceFactory::GetForProfile(profile); | 263 ManagedUserServiceFactory::GetForProfile(profile); |
264 managed_user_service->DidBlockNavigation(web_contents()); | 264 managed_user_service->DidBlockNavigation(web_contents()); |
265 } | 265 } |
OLD | NEW |