| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| 11 #include "chrome/browser/lifetime/application_lifetime.h" | 11 #include "chrome/browser/lifetime/application_lifetime.h" |
| 12 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 12 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 13 #include "chrome/browser/plugins/plugin_metadata.h" | 13 #include "chrome/browser/plugins/plugin_metadata.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/shell_integration.h" | 15 #include "chrome/browser/shell_integration.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "chrome/grit/locale_settings.h" | 19 #include "chrome/grit/locale_settings.h" |
| 20 #include "components/content_settings/core/browser/host_content_settings_map.h" | |
| 21 #include "components/google/core/browser/google_util.h" | 20 #include "components/google/core/browser/google_util.h" |
| 22 #include "components/infobars/core/infobar.h" | 21 #include "components/infobars/core/infobar.h" |
| 23 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 26 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 27 #include "grit/components_strings.h" | 26 #include "grit/components_strings.h" |
| 28 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 30 | 29 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 73 } |
| 75 | 74 |
| 76 int PluginInfoBarDelegate::GetIconID() const { | 75 int PluginInfoBarDelegate::GetIconID() const { |
| 77 return IDR_INFOBAR_PLUGIN_INSTALL; | 76 return IDR_INFOBAR_PLUGIN_INSTALL; |
| 78 } | 77 } |
| 79 | 78 |
| 80 base::string16 PluginInfoBarDelegate::GetLinkText() const { | 79 base::string16 PluginInfoBarDelegate::GetLinkText() const { |
| 81 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 80 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 82 } | 81 } |
| 83 | 82 |
| 84 | |
| 85 // UnauthorizedPluginInfoBarDelegate ------------------------------------------ | |
| 86 | |
| 87 // static | |
| 88 void UnauthorizedPluginInfoBarDelegate::Create( | |
| 89 InfoBarService* infobar_service, | |
| 90 HostContentSettingsMap* content_settings, | |
| 91 const base::string16& name, | |
| 92 const std::string& identifier) { | |
| 93 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | |
| 94 scoped_ptr<ConfirmInfoBarDelegate>(new UnauthorizedPluginInfoBarDelegate( | |
| 95 content_settings, name, identifier)))); | |
| 96 | |
| 97 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); | |
| 98 std::string utf8_name(base::UTF16ToUTF8(name)); | |
| 99 if (utf8_name == PluginMetadata::kJavaGroupName) { | |
| 100 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown.Java")); | |
| 101 } else if (utf8_name == PluginMetadata::kQuickTimeGroupName) { | |
| 102 content::RecordAction( | |
| 103 UserMetricsAction("BlockedPluginInfobar.Shown.QuickTime")); | |
| 104 } else if (utf8_name == PluginMetadata::kShockwaveGroupName) { | |
| 105 content::RecordAction( | |
| 106 UserMetricsAction("BlockedPluginInfobar.Shown.Shockwave")); | |
| 107 } else if (utf8_name == PluginMetadata::kRealPlayerGroupName) { | |
| 108 content::RecordAction( | |
| 109 UserMetricsAction("BlockedPluginInfobar.Shown.RealPlayer")); | |
| 110 } else if (utf8_name == PluginMetadata::kWindowsMediaPlayerGroupName) { | |
| 111 content::RecordAction( | |
| 112 UserMetricsAction("BlockedPluginInfobar.Shown.WindowsMediaPlayer")); | |
| 113 } | |
| 114 } | |
| 115 | |
| 116 UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( | |
| 117 HostContentSettingsMap* content_settings, | |
| 118 const base::string16& name, | |
| 119 const std::string& identifier) | |
| 120 : PluginInfoBarDelegate(identifier), | |
| 121 content_settings_(content_settings), | |
| 122 name_(name) { | |
| 123 } | |
| 124 | |
| 125 UnauthorizedPluginInfoBarDelegate::~UnauthorizedPluginInfoBarDelegate() { | |
| 126 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed")); | |
| 127 } | |
| 128 | |
| 129 std::string UnauthorizedPluginInfoBarDelegate::GetLearnMoreURL() const { | |
| 130 return chrome::kBlockedPluginLearnMoreURL; | |
| 131 } | |
| 132 | |
| 133 base::string16 UnauthorizedPluginInfoBarDelegate::GetMessageText() const { | |
| 134 return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_); | |
| 135 } | |
| 136 | |
| 137 base::string16 UnauthorizedPluginInfoBarDelegate::GetButtonLabel( | |
| 138 InfoBarButton button) const { | |
| 139 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | |
| 140 IDS_PLUGIN_ENABLE_TEMPORARILY : IDS_PLUGIN_ENABLE_ALWAYS); | |
| 141 } | |
| 142 | |
| 143 bool UnauthorizedPluginInfoBarDelegate::Accept() { | |
| 144 content::RecordAction( | |
| 145 UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); | |
| 146 LoadBlockedPlugins(); | |
| 147 return true; | |
| 148 } | |
| 149 | |
| 150 bool UnauthorizedPluginInfoBarDelegate::Cancel() { | |
| 151 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); | |
| 152 const GURL& url = InfoBarService::WebContentsFromInfoBar(infobar())->GetURL(); | |
| 153 content_settings_->AddExceptionForURL(url, url, CONTENT_SETTINGS_TYPE_PLUGINS, | |
| 154 CONTENT_SETTING_ALLOW); | |
| 155 LoadBlockedPlugins(); | |
| 156 return true; | |
| 157 } | |
| 158 | |
| 159 void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() { | |
| 160 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Dismissed")); | |
| 161 } | |
| 162 | |
| 163 bool UnauthorizedPluginInfoBarDelegate::LinkClicked( | |
| 164 WindowOpenDisposition disposition) { | |
| 165 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.LearnMore")); | |
| 166 return PluginInfoBarDelegate::LinkClicked(disposition); | |
| 167 } | |
| 168 | |
| 169 | |
| 170 #if defined(ENABLE_PLUGIN_INSTALLATION) | 83 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 171 | 84 |
| 172 // OutdatedPluginInfoBarDelegate ---------------------------------------------- | 85 // OutdatedPluginInfoBarDelegate ---------------------------------------------- |
| 173 | 86 |
| 174 void OutdatedPluginInfoBarDelegate::Create( | 87 void OutdatedPluginInfoBarDelegate::Create( |
| 175 InfoBarService* infobar_service, | 88 InfoBarService* infobar_service, |
| 176 PluginInstaller* installer, | 89 PluginInstaller* installer, |
| 177 scoped_ptr<PluginMetadata> plugin_metadata) { | 90 scoped_ptr<PluginMetadata> plugin_metadata) { |
| 178 // Copy the name out of |plugin_metadata| now, since the Pass() call below | 91 // Copy the name out of |plugin_metadata| now, since the Pass() call below |
| 179 // will make it impossible to get at. | 92 // will make it impossible to get at. |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), | 434 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), |
| 522 content::Referrer(), | 435 content::Referrer(), |
| 523 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 436 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 524 ui::PAGE_TRANSITION_LINK, false)); | 437 ui::PAGE_TRANSITION_LINK, false)); |
| 525 return false; | 438 return false; |
| 526 } | 439 } |
| 527 | 440 |
| 528 #endif // defined(OS_WIN) | 441 #endif // defined(OS_WIN) |
| 529 | 442 |
| 530 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 443 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| OLD | NEW |