Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1246)

Side by Side Diff: chrome/browser/managed_mode/managed_mode_navigation_observer.cc

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_commands.h" 25 #include "chrome/browser/ui/browser_commands.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 68 }
68 69
69 web_contents->GetDelegate()->CloseContents(web_contents); 70 web_contents->GetDelegate()->CloseContents(web_contents);
70 } 71 }
71 72
72 73
73 // ManagedModeWarningInfoBarDelegate ------------------------------------------ 74 // ManagedModeWarningInfoBarDelegate ------------------------------------------
74 75
75 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate { 76 class ManagedModeWarningInfoBarDelegate : public ConfirmInfoBarDelegate {
76 public: 77 public:
77 // Creates a managed mode warning infobar delegate and adds it to 78 // Creates a managed mode warning infobar and delegate and adds the infobar to
78 // |infobar_service|. Returns the delegate if it was successfully added. 79 // |infobar_service|. Returns the infobar if it was successfully added.
79 static InfoBarDelegate* Create(InfoBarService* infobar_service); 80 static InfoBar* Create(InfoBarService* infobar_service);
80 81
81 private: 82 private:
82 explicit ManagedModeWarningInfoBarDelegate(InfoBarService* infobar_service); 83 ManagedModeWarningInfoBarDelegate();
83 virtual ~ManagedModeWarningInfoBarDelegate(); 84 virtual ~ManagedModeWarningInfoBarDelegate();
84 85
85 // ConfirmInfoBarDelegate: 86 // ConfirmInfoBarDelegate:
86 virtual bool ShouldExpire( 87 virtual bool ShouldExpire(
87 const content::LoadCommittedDetails& details) const OVERRIDE; 88 const content::LoadCommittedDetails& details) const OVERRIDE;
88 virtual void InfoBarDismissed() OVERRIDE; 89 virtual void InfoBarDismissed() OVERRIDE;
89 virtual string16 GetMessageText() const OVERRIDE; 90 virtual string16 GetMessageText() const OVERRIDE;
90 virtual int GetButtons() const OVERRIDE; 91 virtual int GetButtons() const OVERRIDE;
91 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 92 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
92 virtual bool Accept() OVERRIDE; 93 virtual bool Accept() OVERRIDE;
93 94
94 DISALLOW_COPY_AND_ASSIGN(ManagedModeWarningInfoBarDelegate); 95 DISALLOW_COPY_AND_ASSIGN(ManagedModeWarningInfoBarDelegate);
95 }; 96 };
96 97
97 // static 98 // static
98 InfoBarDelegate* ManagedModeWarningInfoBarDelegate::Create( 99 InfoBar* ManagedModeWarningInfoBarDelegate::Create(
99 InfoBarService* infobar_service) { 100 InfoBarService* infobar_service) {
100 return infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( 101 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
101 new ManagedModeWarningInfoBarDelegate(infobar_service))); 102 scoped_ptr<ConfirmInfoBarDelegate>(
103 new ManagedModeWarningInfoBarDelegate())));
102 } 104 }
103 105
104 ManagedModeWarningInfoBarDelegate::ManagedModeWarningInfoBarDelegate( 106 ManagedModeWarningInfoBarDelegate::ManagedModeWarningInfoBarDelegate()
105 InfoBarService* infobar_service) 107 : ConfirmInfoBarDelegate() {
106 : ConfirmInfoBarDelegate(infobar_service) {
107 } 108 }
108 109
109 ManagedModeWarningInfoBarDelegate::~ManagedModeWarningInfoBarDelegate() { 110 ManagedModeWarningInfoBarDelegate::~ManagedModeWarningInfoBarDelegate() {
110 } 111 }
111 112
112 bool ManagedModeWarningInfoBarDelegate::ShouldExpire( 113 bool ManagedModeWarningInfoBarDelegate::ShouldExpire(
113 const content::LoadCommittedDetails& details) const { 114 const content::LoadCommittedDetails& details) const {
114 // ManagedModeNavigationObserver removes us below. 115 // ManagedModeNavigationObserver removes us below.
115 return false; 116 return false;
116 } 117 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 history_service->AddPage(add_page_args); 242 history_service->AddPage(add_page_args);
242 243
243 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); 244 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create());
244 entry->SetVirtualURL(url); 245 entry->SetVirtualURL(url);
245 entry->SetTimestamp(timestamp); 246 entry->SetTimestamp(timestamp);
246 blocked_navigations_.push_back(entry.release()); 247 blocked_navigations_.push_back(entry.release());
247 ManagedUserService* managed_user_service = 248 ManagedUserService* managed_user_service =
248 ManagedUserServiceFactory::GetForProfile(profile); 249 ManagedUserServiceFactory::GetForProfile(profile);
249 managed_user_service->DidBlockNavigation(web_contents()); 250 managed_user_service->DidBlockNavigation(web_contents());
250 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698