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); |
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_); | 479 DCHECK_EQ(DESKTOP_MODE_REQUIRED, mode_); |
490 content::WebContents* web_contents = owner()->GetWebContents(); | 480 content::WebContents* web_contents = owner()->GetWebContents(); |
491 Profile* profile = | 481 Profile* profile = |
492 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 482 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
493 HostContentSettingsMap* content_settings = | 483 HostContentSettingsMap* content_settings = |
494 profile->GetHostContentSettingsMap(); | 484 profile->GetHostContentSettingsMap(); |
495 GURL url = web_contents->GetURL(); | 485 GURL url = web_contents->GetURL(); |
496 content_settings->SetContentSetting( | 486 content_settings->SetContentSetting( |
497 ContentSettingsPattern::FromURL(url), | 487 ContentSettingsPattern::FromURL(url), |
498 ContentSettingsPattern::Wildcard(), | 488 ContentSettingsPattern::Wildcard(), |
499 CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP, | 489 CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP, |
500 std::string(), | 490 std::string(), |
501 CONTENT_SETTING_BLOCK); | 491 CONTENT_SETTING_BLOCK); |
502 return true; | 492 return true; |
503 } | 493 } |
504 | 494 |
505 string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { | 495 string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { |
506 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 496 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
507 } | 497 } |
508 | 498 |
509 bool PluginMetroModeInfoBarDelegate::LinkClicked( | 499 bool PluginMetroModeInfoBarDelegate::LinkClicked( |
510 WindowOpenDisposition disposition) { | 500 WindowOpenDisposition disposition) { |
511 OpenURLParams params( | 501 OpenURLParams params( |
512 learn_more_url_, Referrer(), | 502 GURL((mode_ == MISSING_PLUGIN) ? |
| 503 "https://support.google.com/chrome/?ib_display_in_desktop" : |
| 504 "https://support.google.com/chrome/?ib_redirect_to_desktop"), |
| 505 Referrer(), |
513 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 506 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
514 content::PAGE_TRANSITION_LINK, false); | 507 content::PAGE_TRANSITION_LINK, false); |
515 owner()->GetWebContents()->OpenURL(params); | 508 owner()->GetWebContents()->OpenURL(params); |
516 return false; | 509 return false; |
517 } | 510 } |
518 #endif // defined(OS_WIN) | 511 #endif // defined(OS_WIN) |
519 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 512 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
OLD | NEW |