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

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 6926001: Replace the virtual InfoBarDelegate::InfoBarClosed() function with a non-virtual one. This is a ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/browser_init.h" 5 #include "chrome/browser/ui/browser_init.h"
6 6
7 #include <algorithm> // For max(). 7 #include <algorithm> // For max().
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 explicit DefaultBrowserInfoBarDelegate(TabContents* contents); 137 explicit DefaultBrowserInfoBarDelegate(TabContents* contents);
138 138
139 private: 139 private:
140 virtual ~DefaultBrowserInfoBarDelegate(); 140 virtual ~DefaultBrowserInfoBarDelegate();
141 141
142 void AllowExpiry() { should_expire_ = true; } 142 void AllowExpiry() { should_expire_ = true; }
143 143
144 // ConfirmInfoBarDelegate: 144 // ConfirmInfoBarDelegate:
145 virtual bool ShouldExpire( 145 virtual bool ShouldExpire(
146 const NavigationController::LoadCommittedDetails& details) const OVERRIDE; 146 const NavigationController::LoadCommittedDetails& details) const OVERRIDE;
147 virtual void InfoBarClosed() OVERRIDE;
148 virtual gfx::Image* GetIcon() const OVERRIDE; 147 virtual gfx::Image* GetIcon() const OVERRIDE;
149 virtual string16 GetMessageText() const OVERRIDE; 148 virtual string16 GetMessageText() const OVERRIDE;
150 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 149 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
151 virtual bool NeedElevation(InfoBarButton button) const OVERRIDE; 150 virtual bool NeedElevation(InfoBarButton button) const OVERRIDE;
152 virtual bool Accept() OVERRIDE; 151 virtual bool Accept() OVERRIDE;
153 virtual bool Cancel() OVERRIDE; 152 virtual bool Cancel() OVERRIDE;
154 153
155 // The Profile that we restore sessions from. 154 // The Profile that we restore sessions from.
156 Profile* profile_; 155 Profile* profile_;
157 156
(...skipping 17 matching lines...) Expand all
175 should_expire_(false), 174 should_expire_(false),
176 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 175 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
177 // We want the info-bar to stick-around for few seconds and then be hidden 176 // We want the info-bar to stick-around for few seconds and then be hidden
178 // on the next navigation after that. 177 // on the next navigation after that.
179 MessageLoop::current()->PostDelayedTask(FROM_HERE, 178 MessageLoop::current()->PostDelayedTask(FROM_HERE,
180 method_factory_.NewRunnableMethod( 179 method_factory_.NewRunnableMethod(
181 &DefaultBrowserInfoBarDelegate::AllowExpiry), 8000); // 8 seconds. 180 &DefaultBrowserInfoBarDelegate::AllowExpiry), 8000); // 8 seconds.
182 } 181 }
183 182
184 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() { 183 DefaultBrowserInfoBarDelegate::~DefaultBrowserInfoBarDelegate() {
184 if (!action_taken_)
185 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1);
185 } 186 }
186 187
187 bool DefaultBrowserInfoBarDelegate::ShouldExpire( 188 bool DefaultBrowserInfoBarDelegate::ShouldExpire(
188 const NavigationController::LoadCommittedDetails& details) const { 189 const NavigationController::LoadCommittedDetails& details) const {
189 return should_expire_; 190 return should_expire_;
190 } 191 }
191 192
192 void DefaultBrowserInfoBarDelegate::InfoBarClosed() {
193 if (!action_taken_)
194 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.Ignored", 1);
195 delete this;
196 }
197
198 gfx::Image* DefaultBrowserInfoBarDelegate::GetIcon() const { 193 gfx::Image* DefaultBrowserInfoBarDelegate::GetIcon() const {
199 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 194 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
200 IDR_PRODUCT_ICON_32); 195 IDR_PRODUCT_ICON_32);
201 } 196 }
202 197
203 string16 DefaultBrowserInfoBarDelegate::GetMessageText() const { 198 string16 DefaultBrowserInfoBarDelegate::GetMessageText() const {
204 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); 199 return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT);
205 } 200 }
206 201
207 string16 DefaultBrowserInfoBarDelegate::GetButtonLabel( 202 string16 DefaultBrowserInfoBarDelegate::GetButtonLabel(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 293
299 // A delegate for the InfoBar shown when the previous session has crashed. 294 // A delegate for the InfoBar shown when the previous session has crashed.
300 class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { 295 class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
301 public: 296 public:
302 explicit SessionCrashedInfoBarDelegate(TabContents* contents); 297 explicit SessionCrashedInfoBarDelegate(TabContents* contents);
303 298
304 private: 299 private:
305 virtual ~SessionCrashedInfoBarDelegate(); 300 virtual ~SessionCrashedInfoBarDelegate();
306 301
307 // ConfirmInfoBarDelegate: 302 // ConfirmInfoBarDelegate:
308 virtual void InfoBarClosed() OVERRIDE;
309 virtual gfx::Image* GetIcon() const OVERRIDE; 303 virtual gfx::Image* GetIcon() const OVERRIDE;
310 virtual string16 GetMessageText() const OVERRIDE; 304 virtual string16 GetMessageText() const OVERRIDE;
311 virtual int GetButtons() const OVERRIDE; 305 virtual int GetButtons() const OVERRIDE;
312 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 306 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
313 virtual bool Accept() OVERRIDE; 307 virtual bool Accept() OVERRIDE;
314 308
315 // The Profile that we restore sessions from. 309 // The Profile that we restore sessions from.
316 Profile* profile_; 310 Profile* profile_;
317 311
318 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate); 312 DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
319 }; 313 };
320 314
321 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate( 315 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
322 TabContents* contents) 316 TabContents* contents)
323 : ConfirmInfoBarDelegate(contents), 317 : ConfirmInfoBarDelegate(contents),
324 profile_(contents->profile()) { 318 profile_(contents->profile()) {
325 } 319 }
326 320
327 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { 321 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
328 } 322 }
329 323
330 void SessionCrashedInfoBarDelegate::InfoBarClosed() {
331 delete this;
332 }
333
334 gfx::Image* SessionCrashedInfoBarDelegate::GetIcon() const { 324 gfx::Image* SessionCrashedInfoBarDelegate::GetIcon() const {
335 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 325 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
336 IDR_INFOBAR_RESTORE_SESSION); 326 IDR_INFOBAR_RESTORE_SESSION);
337 } 327 }
338 328
339 string16 SessionCrashedInfoBarDelegate::GetMessageText() const { 329 string16 SessionCrashedInfoBarDelegate::GetMessageText() const {
340 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE); 330 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE);
341 } 331 }
342 332
343 int SessionCrashedInfoBarDelegate::GetButtons() const { 333 int SessionCrashedInfoBarDelegate::GetButtons() const {
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if (bad_flag) { 1064 if (bad_flag) {
1075 tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab, NULL, 1065 tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab, NULL,
1076 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, 1066 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE,
1077 UTF8ToUTF16(std::string("--") + bad_flag)), 1067 UTF8ToUTF16(std::string("--") + bad_flag)),
1078 false)); 1068 false));
1079 } 1069 }
1080 } 1070 }
1081 1071
1082 class DNSCertProvenanceCheckingInfoBar : public ConfirmInfoBarDelegate { 1072 class DNSCertProvenanceCheckingInfoBar : public ConfirmInfoBarDelegate {
1083 public: 1073 public:
1084 explicit DNSCertProvenanceCheckingInfoBar(TabContents* tab_contents) 1074 explicit DNSCertProvenanceCheckingInfoBar(TabContents* tab_contents);
1085 : ConfirmInfoBarDelegate(tab_contents), 1075 virtual ~DNSCertProvenanceCheckingInfoBar();
1086 tab_contents_(tab_contents) {
1087 }
1088 1076
1089 virtual string16 GetMessageText() const { 1077 virtual string16 GetMessageText() const OVERRIDE;
1090 return l10n_util::GetStringUTF16( 1078 virtual int GetButtons() const OVERRIDE;
1091 IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE); 1079 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
1092 } 1080 virtual bool Accept() OVERRIDE;
1093
1094 virtual int GetButtons() const {
1095 return BUTTON_OK;
1096 }
1097
1098 virtual string16 GetButtonLabel(InfoBarButton button) const {
1099 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
1100 }
1101
1102 virtual bool Accept() {
1103 tab_contents_->OpenURL(GURL(kLearnMoreURL), GURL(), NEW_FOREGROUND_TAB,
1104 PageTransition::AUTO_BOOKMARK);
1105 return true;
1106 }
1107 1081
1108 private: 1082 private:
1109 DISALLOW_COPY_AND_ASSIGN(DNSCertProvenanceCheckingInfoBar); 1083 DISALLOW_COPY_AND_ASSIGN(DNSCertProvenanceCheckingInfoBar);
1110 1084
1111 static const char kLearnMoreURL[]; 1085 static const char kLearnMoreURL[];
1112 TabContents* const tab_contents_; 1086 TabContents* const tab_contents_;
1113 }; 1087 };
1114 1088
1089 DNSCertProvenanceCheckingInfoBar::DNSCertProvenanceCheckingInfoBar(
1090 TabContents* tab_contents)
1091 : ConfirmInfoBarDelegate(tab_contents),
1092 tab_contents_(tab_contents) {
1093 }
1094
1095 DNSCertProvenanceCheckingInfoBar::~DNSCertProvenanceCheckingInfoBar() {
1096 }
1097
1098 string16 DNSCertProvenanceCheckingInfoBar::GetMessageText() const {
1099 return l10n_util::GetStringUTF16(
1100 IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE);
1101 }
1102
1103 int DNSCertProvenanceCheckingInfoBar::GetButtons() const {
1104 return BUTTON_OK;
1105 }
1106
1107 string16 DNSCertProvenanceCheckingInfoBar::GetButtonLabel(
1108 InfoBarButton button) const {
1109 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
1110 }
1111
1112 bool DNSCertProvenanceCheckingInfoBar::Accept() {
1113 tab_contents_->OpenURL(GURL(kLearnMoreURL), GURL(), NEW_FOREGROUND_TAB,
1114 PageTransition::AUTO_BOOKMARK);
1115 return true;
1116 }
1117
1115 // This is the page which provides information on DNS certificate provenance 1118 // This is the page which provides information on DNS certificate provenance
1116 // checking. 1119 // checking.
1117 const char DNSCertProvenanceCheckingInfoBar::kLearnMoreURL[] = 1120 const char DNSCertProvenanceCheckingInfoBar::kLearnMoreURL[] =
1118 "http://dev.chromium.org/dnscertprovenancechecking"; 1121 "http://dev.chromium.org/dnscertprovenancechecking";
1119 1122
1120 void BrowserInit::LaunchWithProfile:: 1123 void BrowserInit::LaunchWithProfile::
1121 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary(TabContents* tab) { 1124 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary(TabContents* tab) {
1122 if (!command_line_.HasSwitch(switches::kEnableDNSCertProvenanceChecking)) 1125 if (!command_line_.HasSwitch(switches::kEnableDNSCertProvenanceChecking))
1123 return; 1126 return;
1124 1127
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 return false; 1392 return false;
1390 automation->SetExpectedTabCount(expected_tabs); 1393 automation->SetExpectedTabCount(expected_tabs);
1391 1394
1392 AutomationProviderList* list = 1395 AutomationProviderList* list =
1393 g_browser_process->InitAutomationProviderList(); 1396 g_browser_process->InitAutomationProviderList();
1394 DCHECK(list); 1397 DCHECK(list);
1395 list->AddProvider(automation); 1398 list->AddProvider(automation);
1396 1399
1397 return true; 1400 return true;
1398 } 1401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698