| 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" |
| 15 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
| 16 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" | 17 #include "chrome/browser/managed_mode/managed_mode_interstitial.h" |
| 17 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" | 18 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h" |
| 18 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 19 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
| 19 #include "chrome/browser/managed_mode/managed_user_service.h" | 20 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 20 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 21 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/tab_contents/tab_util.h" | 23 #include "chrome/browser/tab_contents/tab_util.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 74 } |
| 74 | 75 |
| 75 web_contents->GetDelegate()->CloseContents(web_contents); | 76 web_contents->GetDelegate()->CloseContents(web_contents); |
| 76 } | 77 } |
| 77 #endif | 78 #endif |
| 78 | 79 |
| 79 // ManagedModeWarningInfoBarDelegate ------------------------------------------ | 80 // ManagedModeWarningInfoBarDelegate ------------------------------------------ |
| 80 | 81 |
| 81 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate { | 82 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 82 public: | 83 public: |
| 83 // Creates a managed mode warning infobar delegate and adds it to | 84 // Creates a managed mode warning infobar and delegate and adds the infobar to |
| 84 // |infobar_service|. Returns the delegate if it was successfully added. | 85 // |infobar_service|. Returns the infobar if it was successfully added. |
| 85 static InfoBarDelegate* Create(InfoBarService* infobar_service); | 86 static InfoBar* Create(InfoBarService* infobar_service); |
| 86 | 87 |
| 87 private: | 88 private: |
| 88 explicit ManagedModeWarningInfoBarDelegate(InfoBarService* infobar_service); | 89 ManagedModeWarningInfoBarDelegate(); |
| 89 virtual ~ManagedModeWarningInfoBarDelegate(); | 90 virtual ~ManagedModeWarningInfoBarDelegate(); |
| 90 | 91 |
| 91 // ConfirmInfoBarDelegate: | 92 // ConfirmInfoBarDelegate: |
| 92 virtual bool ShouldExpire( | 93 virtual bool ShouldExpire( |
| 93 const content::LoadCommittedDetails& details) const OVERRIDE; | 94 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 94 virtual void InfoBarDismissed() OVERRIDE; | 95 virtual void InfoBarDismissed() OVERRIDE; |
| 95 virtual string16 GetMessageText() const OVERRIDE; | 96 virtual string16 GetMessageText() const OVERRIDE; |
| 96 virtual int GetButtons() const OVERRIDE; | 97 virtual int GetButtons() const OVERRIDE; |
| 97 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 98 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 98 virtual bool Accept() OVERRIDE; | 99 virtual bool Accept() OVERRIDE; |
| 99 | 100 |
| 100 DISALLOW_COPY_AND_ASSIGN(ManagedModeWarningInfoBarDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(ManagedModeWarningInfoBarDelegate); |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 // static | 104 // static |
| 104 InfoBarDelegate* ManagedModeWarningInfoBarDelegate::Create( | 105 InfoBar* ManagedModeWarningInfoBarDelegate::Create( |
| 105 InfoBarService* infobar_service) { | 106 InfoBarService* infobar_service) { |
| 106 return infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 107 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
| 107 new ManagedModeWarningInfoBarDelegate(infobar_service))); | 108 scoped_ptr<ConfirmInfoBarDelegate>( |
| 109 new ManagedModeWarningInfoBarDelegate()))); |
| 108 } | 110 } |
| 109 | 111 |
| 110 ManagedModeWarningInfoBarDelegate::ManagedModeWarningInfoBarDelegate( | 112 ManagedModeWarningInfoBarDelegate::ManagedModeWarningInfoBarDelegate() |
| 111 InfoBarService* infobar_service) | 113 : ConfirmInfoBarDelegate() { |
| 112 : ConfirmInfoBarDelegate(infobar_service) { | |
| 113 } | 114 } |
| 114 | 115 |
| 115 ManagedModeWarningInfoBarDelegate::~ManagedModeWarningInfoBarDelegate() { | 116 ManagedModeWarningInfoBarDelegate::~ManagedModeWarningInfoBarDelegate() { |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool ManagedModeWarningInfoBarDelegate::ShouldExpire( | 119 bool ManagedModeWarningInfoBarDelegate::ShouldExpire( |
| 119 const content::LoadCommittedDetails& details) const { | 120 const content::LoadCommittedDetails& details) const { |
| 120 // ManagedModeNavigationObserver removes us below. | 121 // ManagedModeNavigationObserver removes us below. |
| 121 return false; | 122 return false; |
| 122 } | 123 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 history_service->AddPage(add_page_args); | 255 history_service->AddPage(add_page_args); |
| 255 | 256 |
| 256 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 257 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| 257 entry->SetVirtualURL(url); | 258 entry->SetVirtualURL(url); |
| 258 entry->SetTimestamp(timestamp); | 259 entry->SetTimestamp(timestamp); |
| 259 blocked_navigations_.push_back(entry.release()); | 260 blocked_navigations_.push_back(entry.release()); |
| 260 ManagedUserService* managed_user_service = | 261 ManagedUserService* managed_user_service = |
| 261 ManagedUserServiceFactory::GetForProfile(profile); | 262 ManagedUserServiceFactory::GetForProfile(profile); |
| 262 managed_user_service->DidBlockNavigation(web_contents()); | 263 managed_user_service->DidBlockNavigation(web_contents()); |
| 263 } | 264 } |
| OLD | NEW |