| 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" |
| 11 #include "chrome/browser/history/history_service.h" | 11 #include "chrome/browser/history/history_service.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/history/history_types.h" | 13 #include "chrome/browser/history/history_types.h" |
| 14 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 14 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 15 #include "chrome/browser/infobars/infobar.h" | |
| 16 #include "chrome/browser/infobars/infobar_service.h" | 15 #include "chrome/browser/infobars/infobar_service.h" |
| 17 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" | 16 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" |
| 18 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" | 17 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" |
| 19 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 18 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
| 20 #include "chrome/browser/managed_mode/managed_user_service.h" | 19 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 21 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 20 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/tab_contents/tab_util.h" | 22 #include "chrome/browser/tab_contents/tab_util.h" |
| 23 #include "components/infobars/core/infobar.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/user_metrics.h" | 28 #include "content/public/browser/user_metrics.h" |
| 29 #include "content/public/browser/web_contents_view.h" | 29 #include "content/public/browser/web_contents_view.h" |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 | 32 |
| 33 #if !defined(OS_ANDROID) | 33 #if !defined(OS_ANDROID) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 web_contents->GetDelegate()->CloseContents(web_contents); | 76 web_contents->GetDelegate()->CloseContents(web_contents); |
| 77 } | 77 } |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 // ManagedModeWarningInfoBarDelegate ------------------------------------------ | 80 // ManagedModeWarningInfoBarDelegate ------------------------------------------ |
| 81 | 81 |
| 82 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate { | 82 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 83 public: | 83 public: |
| 84 // Creates a managed mode warning infobar and delegate and adds the infobar to | 84 // Creates a managed mode warning infobar and delegate and adds the infobar to |
| 85 // |infobar_service|. Returns the infobar if it was successfully added. | 85 // |infobar_service|. Returns the infobar if it was successfully added. |
| 86 static InfoBar* Create(InfoBarService* infobar_service); | 86 static infobars::InfoBar* Create(InfoBarService* infobar_service); |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 ManagedModeWarningInfoBarDelegate(); | 89 ManagedModeWarningInfoBarDelegate(); |
| 90 virtual ~ManagedModeWarningInfoBarDelegate(); | 90 virtual ~ManagedModeWarningInfoBarDelegate(); |
| 91 | 91 |
| 92 // ConfirmInfoBarDelegate: | 92 // ConfirmInfoBarDelegate: |
| 93 virtual bool ShouldExpire(const NavigationDetails& details) const OVERRIDE; | 93 virtual bool ShouldExpire(const NavigationDetails& details) const OVERRIDE; |
| 94 virtual void InfoBarDismissed() OVERRIDE; | 94 virtual void InfoBarDismissed() OVERRIDE; |
| 95 virtual base::string16 GetMessageText() const OVERRIDE; | 95 virtual base::string16 GetMessageText() const OVERRIDE; |
| 96 virtual int GetButtons() const OVERRIDE; | 96 virtual int GetButtons() const OVERRIDE; |
| 97 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 97 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 98 virtual bool Accept() OVERRIDE; | 98 virtual bool Accept() OVERRIDE; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(ManagedModeWarningInfoBarDelegate); | 100 DISALLOW_COPY_AND_ASSIGN(ManagedModeWarningInfoBarDelegate); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 // static | 103 // static |
| 104 InfoBar* ManagedModeWarningInfoBarDelegate::Create( | 104 infobars::InfoBar* ManagedModeWarningInfoBarDelegate::Create( |
| 105 InfoBarService* infobar_service) { | 105 InfoBarService* infobar_service) { |
| 106 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 106 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
| 107 scoped_ptr<ConfirmInfoBarDelegate>( | 107 scoped_ptr<ConfirmInfoBarDelegate>( |
| 108 new ManagedModeWarningInfoBarDelegate()))); | 108 new ManagedModeWarningInfoBarDelegate()))); |
| 109 } | 109 } |
| 110 | 110 |
| 111 ManagedModeWarningInfoBarDelegate::ManagedModeWarningInfoBarDelegate() | 111 ManagedModeWarningInfoBarDelegate::ManagedModeWarningInfoBarDelegate() |
| 112 : ConfirmInfoBarDelegate() { | 112 : ConfirmInfoBarDelegate() { |
| 113 } | 113 } |
| 114 | 114 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |