| 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/plugin_infobar_delegates.h" | 5 #include "chrome/browser/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_tab_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" |
| 11 #include "chrome/browser/plugin_observer.h" | 11 #include "chrome/browser/plugin_observer.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "grit/locale_settings.h" | 19 #include "grit/locale_settings.h" |
| 20 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "webkit/plugins/npapi/plugin_group.h" | 23 #include "webkit/plugins/npapi/plugin_group.h" |
| 24 | 24 |
| 25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 26 #include <shellapi.h> | 26 #include <shellapi.h> |
| 27 #include "ui/base/win/shell.h" | 27 #include "ui/base/win/shell.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 #if defined(ENABLE_PLUGIN_INSTALLATION) | 30 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 31 #include "chrome/browser/plugin_installer.h" | 31 #include "chrome/browser/plugin_installer.h" |
| 32 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 32 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| 33 | 33 |
| 34 using content::OpenURLParams; | 34 using content::OpenURLParams; |
| 35 using content::Referrer; | 35 using content::Referrer; |
| 36 using content::UserMetricsAction; | 36 using content::UserMetricsAction; |
| 37 | 37 |
| 38 PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarTabService* infobar_service, | 38 PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarService* infobar_service, |
| 39 const string16& name, | 39 const string16& name, |
| 40 const std::string& identifier) | 40 const std::string& identifier) |
| 41 : ConfirmInfoBarDelegate(infobar_service), | 41 : ConfirmInfoBarDelegate(infobar_service), |
| 42 name_(name), | 42 name_(name), |
| 43 identifier_(identifier) { | 43 identifier_(identifier) { |
| 44 } | 44 } |
| 45 | 45 |
| 46 PluginInfoBarDelegate::~PluginInfoBarDelegate() { | 46 PluginInfoBarDelegate::~PluginInfoBarDelegate() { |
| 47 } | 47 } |
| 48 | 48 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 69 IDR_INFOBAR_PLUGIN_INSTALL); | 69 IDR_INFOBAR_PLUGIN_INSTALL); |
| 70 } | 70 } |
| 71 | 71 |
| 72 string16 PluginInfoBarDelegate::GetLinkText() const { | 72 string16 PluginInfoBarDelegate::GetLinkText() const { |
| 73 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 73 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // UnauthorizedPluginInfoBarDelegate ------------------------------------------ | 76 // UnauthorizedPluginInfoBarDelegate ------------------------------------------ |
| 77 | 77 |
| 78 UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( | 78 UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( |
| 79 InfoBarTabService* infobar_service, | 79 InfoBarService* infobar_service, |
| 80 HostContentSettingsMap* content_settings, | 80 HostContentSettingsMap* content_settings, |
| 81 const string16& utf16_name, | 81 const string16& utf16_name, |
| 82 const std::string& identifier) | 82 const std::string& identifier) |
| 83 : PluginInfoBarDelegate(infobar_service, utf16_name, identifier), | 83 : PluginInfoBarDelegate(infobar_service, utf16_name, identifier), |
| 84 content_settings_(content_settings) { | 84 content_settings_(content_settings) { |
| 85 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); | 85 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); |
| 86 std::string name = UTF16ToUTF8(utf16_name); | 86 std::string name = UTF16ToUTF8(utf16_name); |
| 87 if (name == webkit::npapi::PluginGroup::kJavaGroupName) | 87 if (name == webkit::npapi::PluginGroup::kJavaGroupName) |
| 88 content::RecordAction( | 88 content::RecordAction( |
| 89 UserMetricsAction("BlockedPluginInfobar.Shown.Java")); | 89 UserMetricsAction("BlockedPluginInfobar.Shown.Java")); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 break; | 168 break; |
| 169 } | 169 } |
| 170 return new OutdatedPluginInfoBarDelegate( | 170 return new OutdatedPluginInfoBarDelegate( |
| 171 observer, installer, message); | 171 observer, installer, message); |
| 172 } | 172 } |
| 173 | 173 |
| 174 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( | 174 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( |
| 175 PluginObserver* observer, | 175 PluginObserver* observer, |
| 176 PluginInstaller* installer, | 176 PluginInstaller* installer, |
| 177 const string16& message) | 177 const string16& message) |
| 178 : PluginInfoBarDelegate(InfoBarTabService::ForTab(observer->tab_contents()), | 178 : PluginInfoBarDelegate(InfoBarService::ForTab(observer->tab_contents()), |
| 179 installer->name(), | 179 installer->name(), |
| 180 installer->identifier()), | 180 installer->identifier()), |
| 181 WeakPluginInstallerObserver(installer), | 181 WeakPluginInstallerObserver(installer), |
| 182 observer_(observer), | 182 observer_(observer), |
| 183 message_(message) { | 183 message_(message) { |
| 184 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); | 184 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); |
| 185 std::string name = UTF16ToUTF8(installer->name()); | 185 std::string name = UTF16ToUTF8(installer->name()); |
| 186 if (name == webkit::npapi::PluginGroup::kJavaGroupName) | 186 if (name == webkit::npapi::PluginGroup::kJavaGroupName) |
| 187 content::RecordAction( | 187 content::RecordAction( |
| 188 UserMetricsAction("OutdatedPluginInfobar.Shown.Java")); | 188 UserMetricsAction("OutdatedPluginInfobar.Shown.Java")); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 if (!owner()) | 292 if (!owner()) |
| 293 return; | 293 return; |
| 294 InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( | 294 InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( |
| 295 owner(), installer(), base::Closure(), false, message); | 295 owner(), installer(), base::Closure(), false, message); |
| 296 owner()->ReplaceInfoBar(this, delegate); | 296 owner()->ReplaceInfoBar(this, delegate); |
| 297 } | 297 } |
| 298 | 298 |
| 299 // PluginInstallerInfoBarDelegate --------------------------------------------- | 299 // PluginInstallerInfoBarDelegate --------------------------------------------- |
| 300 | 300 |
| 301 PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( | 301 PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( |
| 302 InfoBarTabService* infobar_service, | 302 InfoBarService* infobar_service, |
| 303 PluginInstaller* installer, | 303 PluginInstaller* installer, |
| 304 const base::Closure& callback, | 304 const base::Closure& callback, |
| 305 bool new_install, | 305 bool new_install, |
| 306 const string16& message) | 306 const string16& message) |
| 307 : ConfirmInfoBarDelegate(infobar_service), | 307 : ConfirmInfoBarDelegate(infobar_service), |
| 308 WeakPluginInstallerObserver(installer), | 308 WeakPluginInstallerObserver(installer), |
| 309 callback_(callback), | 309 callback_(callback), |
| 310 new_install_(new_install), | 310 new_install_(new_install), |
| 311 message_(message) { | 311 message_(message) { |
| 312 } | 312 } |
| 313 | 313 |
| 314 PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() { | 314 PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() { |
| 315 } | 315 } |
| 316 | 316 |
| 317 InfoBarDelegate* PluginInstallerInfoBarDelegate::Create( | 317 InfoBarDelegate* PluginInstallerInfoBarDelegate::Create( |
| 318 InfoBarTabService* infobar_service, | 318 InfoBarService* infobar_service, |
| 319 PluginInstaller* installer, | 319 PluginInstaller* installer, |
| 320 const base::Closure& callback) { | 320 const base::Closure& callback) { |
| 321 string16 message; | 321 string16 message; |
| 322 const string16& plugin_name = installer->name(); | 322 const string16& plugin_name = installer->name(); |
| 323 switch (installer->state()) { | 323 switch (installer->state()) { |
| 324 case PluginInstaller::INSTALLER_STATE_IDLE: | 324 case PluginInstaller::INSTALLER_STATE_IDLE: |
| 325 message = l10n_util::GetStringFUTF16( | 325 message = l10n_util::GetStringFUTF16( |
| 326 IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT, plugin_name); | 326 IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT, plugin_name); |
| 327 break; | 327 break; |
| 328 case PluginInstaller::INSTALLER_STATE_DOWNLOADING: | 328 case PluginInstaller::INSTALLER_STATE_DOWNLOADING: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 if (!owner()) | 416 if (!owner()) |
| 417 return; | 417 return; |
| 418 InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( | 418 InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( |
| 419 owner(), installer(), base::Closure(), new_install_, message); | 419 owner(), installer(), base::Closure(), new_install_, message); |
| 420 owner()->ReplaceInfoBar(this, delegate); | 420 owner()->ReplaceInfoBar(this, delegate); |
| 421 } | 421 } |
| 422 | 422 |
| 423 // PluginMetroModeInfoBarDelegate --------------------------------------------- | 423 // PluginMetroModeInfoBarDelegate --------------------------------------------- |
| 424 #if defined(OS_WIN) | 424 #if defined(OS_WIN) |
| 425 InfoBarDelegate* PluginMetroModeInfoBarDelegate::Create( | 425 InfoBarDelegate* PluginMetroModeInfoBarDelegate::Create( |
| 426 InfoBarTabService* infobar_service, const string16& plugin_name) { | 426 InfoBarService* infobar_service, const string16& plugin_name) { |
| 427 string16 message = l10n_util::GetStringFUTF16( | 427 string16 message = l10n_util::GetStringFUTF16( |
| 428 IDS_METRO_MISSING_PLUGIN_PROMPT, plugin_name); | 428 IDS_METRO_MISSING_PLUGIN_PROMPT, plugin_name); |
| 429 return new PluginMetroModeInfoBarDelegate( | 429 return new PluginMetroModeInfoBarDelegate( |
| 430 infobar_service, message); | 430 infobar_service, message); |
| 431 } | 431 } |
| 432 | 432 |
| 433 PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate( | 433 PluginMetroModeInfoBarDelegate::PluginMetroModeInfoBarDelegate( |
| 434 InfoBarTabService* infobar_service, const string16& message) | 434 InfoBarService* infobar_service, const string16& message) |
| 435 : ConfirmInfoBarDelegate(infobar_service), | 435 : ConfirmInfoBarDelegate(infobar_service), |
| 436 message_(message) { | 436 message_(message) { |
| 437 } | 437 } |
| 438 | 438 |
| 439 PluginMetroModeInfoBarDelegate::~PluginMetroModeInfoBarDelegate() { | 439 PluginMetroModeInfoBarDelegate::~PluginMetroModeInfoBarDelegate() { |
| 440 } | 440 } |
| 441 | 441 |
| 442 gfx::Image* PluginMetroModeInfoBarDelegate::GetIcon() const { | 442 gfx::Image* PluginMetroModeInfoBarDelegate::GetIcon() const { |
| 443 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 443 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 444 IDR_INFOBAR_PLUGIN_INSTALL); | 444 IDR_INFOBAR_PLUGIN_INSTALL); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 "https://support.google.com/chrome/?ib_display_in_desktop")); | 485 "https://support.google.com/chrome/?ib_display_in_desktop")); |
| 486 OpenURLParams params( | 486 OpenURLParams params( |
| 487 url, Referrer(), | 487 url, Referrer(), |
| 488 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 488 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 489 content::PAGE_TRANSITION_LINK, false); | 489 content::PAGE_TRANSITION_LINK, false); |
| 490 owner()->GetWebContents()->OpenURL(params); | 490 owner()->GetWebContents()->OpenURL(params); |
| 491 return false; | 491 return false; |
| 492 } | 492 } |
| 493 #endif // defined(OS_WIN) | 493 #endif // defined(OS_WIN) |
| 494 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 494 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| OLD | NEW |