| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 if (bad_flag) { | 1067 if (bad_flag) { |
| 1078 tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab, NULL, | 1068 tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab, NULL, |
| 1079 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, | 1069 l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, |
| 1080 UTF8ToUTF16(std::string("--") + bad_flag)), | 1070 UTF8ToUTF16(std::string("--") + bad_flag)), |
| 1081 false)); | 1071 false)); |
| 1082 } | 1072 } |
| 1083 } | 1073 } |
| 1084 | 1074 |
| 1085 class DNSCertProvenanceCheckingInfoBar : public ConfirmInfoBarDelegate { | 1075 class DNSCertProvenanceCheckingInfoBar : public ConfirmInfoBarDelegate { |
| 1086 public: | 1076 public: |
| 1087 explicit DNSCertProvenanceCheckingInfoBar(TabContents* tab_contents) | 1077 explicit DNSCertProvenanceCheckingInfoBar(TabContents* tab_contents); |
| 1088 : ConfirmInfoBarDelegate(tab_contents), | 1078 virtual ~DNSCertProvenanceCheckingInfoBar(); |
| 1089 tab_contents_(tab_contents) { | |
| 1090 } | |
| 1091 | 1079 |
| 1092 virtual string16 GetMessageText() const { | 1080 virtual string16 GetMessageText() const OVERRIDE; |
| 1093 return l10n_util::GetStringUTF16( | 1081 virtual int GetButtons() const OVERRIDE; |
| 1094 IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE); | 1082 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 1095 } | 1083 virtual bool Accept() OVERRIDE; |
| 1096 | |
| 1097 virtual int GetButtons() const { | |
| 1098 return BUTTON_OK; | |
| 1099 } | |
| 1100 | |
| 1101 virtual string16 GetButtonLabel(InfoBarButton button) const { | |
| 1102 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | |
| 1103 } | |
| 1104 | |
| 1105 virtual bool Accept() { | |
| 1106 tab_contents_->OpenURL(GURL(kLearnMoreURL), GURL(), NEW_FOREGROUND_TAB, | |
| 1107 PageTransition::AUTO_BOOKMARK); | |
| 1108 return true; | |
| 1109 } | |
| 1110 | 1084 |
| 1111 private: | 1085 private: |
| 1112 DISALLOW_COPY_AND_ASSIGN(DNSCertProvenanceCheckingInfoBar); | 1086 DISALLOW_COPY_AND_ASSIGN(DNSCertProvenanceCheckingInfoBar); |
| 1113 | 1087 |
| 1114 static const char kLearnMoreURL[]; | 1088 static const char kLearnMoreURL[]; |
| 1115 TabContents* const tab_contents_; | 1089 TabContents* const tab_contents_; |
| 1116 }; | 1090 }; |
| 1117 | 1091 |
| 1092 DNSCertProvenanceCheckingInfoBar::DNSCertProvenanceCheckingInfoBar( |
| 1093 TabContents* tab_contents) |
| 1094 : ConfirmInfoBarDelegate(tab_contents), |
| 1095 tab_contents_(tab_contents) { |
| 1096 } |
| 1097 |
| 1098 DNSCertProvenanceCheckingInfoBar::~DNSCertProvenanceCheckingInfoBar() { |
| 1099 } |
| 1100 |
| 1101 string16 DNSCertProvenanceCheckingInfoBar::GetMessageText() const { |
| 1102 return l10n_util::GetStringUTF16( |
| 1103 IDS_DNS_CERT_PROVENANCE_CHECKING_WARNING_MESSAGE); |
| 1104 } |
| 1105 |
| 1106 int DNSCertProvenanceCheckingInfoBar::GetButtons() const { |
| 1107 return BUTTON_OK; |
| 1108 } |
| 1109 |
| 1110 string16 DNSCertProvenanceCheckingInfoBar::GetButtonLabel( |
| 1111 InfoBarButton button) const { |
| 1112 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 1113 } |
| 1114 |
| 1115 bool DNSCertProvenanceCheckingInfoBar::Accept() { |
| 1116 tab_contents_->OpenURL(GURL(kLearnMoreURL), GURL(), NEW_FOREGROUND_TAB, |
| 1117 PageTransition::AUTO_BOOKMARK); |
| 1118 return true; |
| 1119 } |
| 1120 |
| 1118 // This is the page which provides information on DNS certificate provenance | 1121 // This is the page which provides information on DNS certificate provenance |
| 1119 // checking. | 1122 // checking. |
| 1120 const char DNSCertProvenanceCheckingInfoBar::kLearnMoreURL[] = | 1123 const char DNSCertProvenanceCheckingInfoBar::kLearnMoreURL[] = |
| 1121 "http://dev.chromium.org/dnscertprovenancechecking"; | 1124 "http://dev.chromium.org/dnscertprovenancechecking"; |
| 1122 | 1125 |
| 1123 void BrowserInit::LaunchWithProfile:: | 1126 void BrowserInit::LaunchWithProfile:: |
| 1124 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary(TabContents* tab) { | 1127 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary(TabContents* tab) { |
| 1125 if (!command_line_.HasSwitch(switches::kEnableDNSCertProvenanceChecking)) | 1128 if (!command_line_.HasSwitch(switches::kEnableDNSCertProvenanceChecking)) |
| 1126 return; | 1129 return; |
| 1127 | 1130 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 return false; | 1395 return false; |
| 1393 automation->SetExpectedTabCount(expected_tabs); | 1396 automation->SetExpectedTabCount(expected_tabs); |
| 1394 | 1397 |
| 1395 AutomationProviderList* list = | 1398 AutomationProviderList* list = |
| 1396 g_browser_process->InitAutomationProviderList(); | 1399 g_browser_process->InitAutomationProviderList(); |
| 1397 DCHECK(list); | 1400 DCHECK(list); |
| 1398 list->AddProvider(automation); | 1401 list->AddProvider(automation); |
| 1399 | 1402 |
| 1400 return true; | 1403 return true; |
| 1401 } | 1404 } |
| OLD | NEW |