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/plugins/plugin_infobar_delegates.h" | 5 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/api/infobars/infobar_service.h" | 8 #include "chrome/browser/api/infobars/infobar_service.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( | 431 InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( |
432 owner(), installer(), plugin_metadata_->Clone(), | 432 owner(), installer(), plugin_metadata_->Clone(), |
433 InstallCallback(), new_install_, message); | 433 InstallCallback(), new_install_, message); |
434 owner()->ReplaceInfoBar(this, delegate); | 434 owner()->ReplaceInfoBar(this, delegate); |
435 } | 435 } |
436 | 436 |
437 // PluginMetroModeInfoBarDelegate --------------------------------------------- | 437 // PluginMetroModeInfoBarDelegate --------------------------------------------- |
438 #if defined(OS_WIN) | 438 #if defined(OS_WIN) |
439 PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate( | 439 PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate( |
440 InfoBarService* infobar_service, | 440 InfoBarService* infobar_service, |
441 const string16& message, | 441 PluginMetroModeInfoBarDelegate::Mode mode, |
442 const string16& ok_label, | 442 const string16& name) |
443 const GURL& learn_more_url, | |
444 bool show_dont_ask_again_button) | |
445 : ConfirmInfoBarDelegate(infobar_service), | 443 : ConfirmInfoBarDelegate(infobar_service), |
446 message_(message), | 444 mode_(mode), |
447 ok_label_(ok_label), | 445 name_(name) { |
448 learn_more_url_(learn_more_url), | |
449 show_dont_ask_again_button_(show_dont_ask_again_button) { | |
450 } | 446 } |
451 | 447 |
452 PluginMetroModeInfoBarDelegate::~PluginMetroModeInfoBarDelegate() { | 448 PluginMetroModeInfoBarDelegate::~PluginMetroModeInfoBarDelegate() { |
453 } | 449 } |
454 | 450 |
455 gfx::Image* PluginMetroModeInfoBarDelegate::GetIcon() const { | 451 gfx::Image* PluginMetroModeInfoBarDelegate::GetIcon() const { |
456 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 452 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
457 IDR_INFOBAR_PLUGIN_INSTALL); | 453 IDR_INFOBAR_PLUGIN_INSTALL); |
458 } | 454 } |
459 | 455 |
460 string16 PluginMetroModeInfoBarDelegate::GetMessageText() const { | 456 string16 PluginMetroModeInfoBarDelegate::GetMessageText() const { |
461 return message_; | 457 return l10n_util::GetStringFUTF16((mode_ == MISSING_PLUGIN) ? |
458 IDS_METRO_MISSING_PLUGIN_PROMPT : IDS_METRO_NPAPI_PLUGIN_PROMPT, name_); | |
462 } | 459 } |
463 | 460 |
464 int PluginMetroModeInfoBarDelegate::GetButtons() const { | 461 int PluginMetroModeInfoBarDelegate::GetButtons() const { |
465 int buttons = BUTTON_OK; | 462 return (mode_ == MISSING_PLUGIN) ? BUTTON_OK : (BUTTON_OK | BUTTON_CANCEL); |
Bernhard Bauer
2012/12/22 01:55:54
I think making these into switch statements would
Peter Kasting
2012/12/26 18:40:36
I'm not a huge fan of switches for a two-element e
Bernhard Bauer
2012/12/26 22:38:59
I know what you mean, but the same argument could
| |
466 if (show_dont_ask_again_button_) | |
467 buttons |= BUTTON_CANCEL; | |
468 return buttons; | |
469 } | 463 } |
470 | 464 |
471 string16 PluginMetroModeInfoBarDelegate::GetButtonLabel( | 465 string16 PluginMetroModeInfoBarDelegate::GetButtonLabel( |
472 InfoBarButton button) const { | 466 InfoBarButton button) const { |
473 if (button == BUTTON_OK) | 467 if (button == BUTTON_CANCEL) |
474 return ok_label_; | |
475 if (button == BUTTON_CANCEL) { | |
476 DCHECK(show_dont_ask_again_button_); | |
477 return l10n_util::GetStringUTF16(IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); | 468 return l10n_util::GetStringUTF16(IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); |
478 } | 469 return l10n_util::GetStringUTF16((mode_ == MISSING_PLUGIN) ? |
479 NOTREACHED(); | 470 IDS_WIN8_DESKTOP_RESTART : IDS_WIN8_RESTART); |
480 return string16(); | |
481 } | 471 } |
482 | 472 |
483 bool PluginMetroModeInfoBarDelegate::Accept() { | 473 bool PluginMetroModeInfoBarDelegate::Accept() { |
484 browser::AttemptRestartWithModeSwitch(); | 474 browser::AttemptRestartWithModeSwitch(); |
485 return true; | 475 return true; |
486 } | 476 } |
487 | 477 |
488 bool PluginMetroModeInfoBarDelegate::Cancel() { | 478 bool PluginMetroModeInfoBarDelegate::Cancel() { |
489 DCHECK(show_dont_ask_again_button_); | |
Bernhard Bauer
2012/12/22 01:55:54
Is there a reason you removed this DCHECK? I kinda
Peter Kasting
2012/12/26 18:40:36
I removed this because I killed the member variabl
| |
490 content::WebContents* web_contents = owner()->GetWebContents(); | 479 content::WebContents* web_contents = owner()->GetWebContents(); |
491 Profile* profile = | 480 Profile* profile = |
492 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 481 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
493 HostContentSettingsMap* content_settings = | 482 HostContentSettingsMap* content_settings = |
494 profile->GetHostContentSettingsMap(); | 483 profile->GetHostContentSettingsMap(); |
495 GURL url = web_contents->GetURL(); | 484 GURL url = web_contents->GetURL(); |
496 content_settings->SetContentSetting( | 485 content_settings->SetContentSetting( |
497 ContentSettingsPattern::FromURL(url), | 486 ContentSettingsPattern::FromURL(url), |
498 ContentSettingsPattern::Wildcard(), | 487 ContentSettingsPattern::Wildcard(), |
499 CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP, | 488 CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP, |
500 std::string(), | 489 std::string(), |
501 CONTENT_SETTING_BLOCK); | 490 CONTENT_SETTING_BLOCK); |
502 return true; | 491 return true; |
503 } | 492 } |
504 | 493 |
505 string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { | 494 string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { |
506 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 495 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
507 } | 496 } |
508 | 497 |
509 bool PluginMetroModeInfoBarDelegate::LinkClicked( | 498 bool PluginMetroModeInfoBarDelegate::LinkClicked( |
510 WindowOpenDisposition disposition) { | 499 WindowOpenDisposition disposition) { |
511 OpenURLParams params( | 500 OpenURLParams params( |
512 learn_more_url_, Referrer(), | 501 GURL((mode_ == MISSING_PLUGIN) ? |
502 "https://support.google.com/chrome/?ib_display_in_desktop" : | |
503 "https://support.google.com/chrome/?ib_redirect_to_desktop"), | |
504 Referrer(), | |
513 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 505 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
514 content::PAGE_TRANSITION_LINK, false); | 506 content::PAGE_TRANSITION_LINK, false); |
515 owner()->GetWebContents()->OpenURL(params); | 507 owner()->GetWebContents()->OpenURL(params); |
516 return false; | 508 return false; |
517 } | 509 } |
518 #endif // defined(OS_WIN) | 510 #endif // defined(OS_WIN) |
519 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 511 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
OLD | NEW |