| 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_observer.h" | 5 #include "chrome/browser/plugins/plugin_observer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/debug/crash_logging.h" | 11 #include "base/debug/crash_logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/app/vector_icons/vector_icons.h" |
| 16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/infobars/infobar_service.h" | 18 #include "chrome/browser/infobars/infobar_service.h" |
| 18 #include "chrome/browser/lifetime/application_lifetime.h" | 19 #include "chrome/browser/lifetime/application_lifetime.h" |
| 19 #include "chrome/browser/plugins/flash_download_interception.h" | 20 #include "chrome/browser/plugins/flash_download_interception.h" |
| 20 #include "chrome/browser/plugins/plugin_finder.h" | 21 #include "chrome/browser/plugins/plugin_finder.h" |
| 21 #include "chrome/browser/plugins/plugin_infobar_delegates.h" | 22 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 24 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
| 24 #include "chrome/common/features.h" | 25 #include "chrome/common/features.h" |
| 25 #include "chrome/common/render_messages.h" | 26 #include "chrome/common/render_messages.h" |
| 26 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 27 #include "chrome/grit/theme_resources.h" | 28 #include "chrome/grit/theme_resources.h" |
| 28 #include "components/component_updater/component_updater_service.h" | 29 #include "components/component_updater/component_updater_service.h" |
| 29 #include "components/content_settings/core/browser/host_content_settings_map.h" | 30 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 30 #include "components/infobars/core/confirm_infobar_delegate.h" | 31 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 31 #include "components/infobars/core/infobar.h" | 32 #include "components/infobars/core/infobar.h" |
| 32 #include "components/infobars/core/infobar_delegate.h" | 33 #include "components/infobars/core/infobar_delegate.h" |
| 33 #include "components/infobars/core/simple_alert_infobar_delegate.h" | 34 #include "components/infobars/core/simple_alert_infobar_delegate.h" |
| 34 #include "components/metrics_services_manager/metrics_services_manager.h" | 35 #include "components/metrics_services_manager/metrics_services_manager.h" |
| 35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 36 #include "content/public/browser/plugin_service.h" | 37 #include "content/public/browser/plugin_service.h" |
| 37 #include "content/public/browser/render_frame_host.h" | 38 #include "content/public/browser/render_frame_host.h" |
| 38 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
| 39 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 40 #include "content/public/browser/web_contents_delegate.h" | 41 #include "content/public/browser/web_contents_delegate.h" |
| 41 #include "content/public/common/webplugininfo.h" | 42 #include "content/public/common/webplugininfo.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/gfx/vector_icons_public.h" | |
| 44 | 44 |
| 45 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 45 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
| 46 #include "chrome/browser/plugins/plugin_installer.h" | 46 #include "chrome/browser/plugins/plugin_installer.h" |
| 47 #include "chrome/browser/plugins/plugin_installer_observer.h" | 47 #include "chrome/browser/plugins/plugin_installer_observer.h" |
| 48 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 48 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 49 #endif // BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 49 #endif // BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
| 50 | 50 |
| 51 using content::PluginService; | 51 using content::PluginService; |
| 52 | 52 |
| 53 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginObserver); | 53 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginObserver); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 content::NavigationController* controller, | 129 content::NavigationController* controller, |
| 130 const base::string16& message); | 130 const base::string16& message); |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 ReloadPluginInfoBarDelegate(content::NavigationController* controller, | 133 ReloadPluginInfoBarDelegate(content::NavigationController* controller, |
| 134 const base::string16& message); | 134 const base::string16& message); |
| 135 ~ReloadPluginInfoBarDelegate() override; | 135 ~ReloadPluginInfoBarDelegate() override; |
| 136 | 136 |
| 137 // ConfirmInfobarDelegate: | 137 // ConfirmInfobarDelegate: |
| 138 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 138 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 139 gfx::VectorIconId GetVectorIconId() const override; | 139 const gfx::VectorIcon& GetVectorIcon() const override; |
| 140 base::string16 GetMessageText() const override; | 140 base::string16 GetMessageText() const override; |
| 141 int GetButtons() const override; | 141 int GetButtons() const override; |
| 142 base::string16 GetButtonLabel(InfoBarButton button) const override; | 142 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 143 bool Accept() override; | 143 bool Accept() override; |
| 144 | 144 |
| 145 content::NavigationController* controller_; | 145 content::NavigationController* controller_; |
| 146 base::string16 message_; | 146 base::string16 message_; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 // static | 149 // static |
| (...skipping 12 matching lines...) Expand all Loading... |
| 162 : controller_(controller), | 162 : controller_(controller), |
| 163 message_(message) {} | 163 message_(message) {} |
| 164 | 164 |
| 165 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate() {} | 165 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate() {} |
| 166 | 166 |
| 167 infobars::InfoBarDelegate::InfoBarIdentifier | 167 infobars::InfoBarDelegate::InfoBarIdentifier |
| 168 ReloadPluginInfoBarDelegate::GetIdentifier() const { | 168 ReloadPluginInfoBarDelegate::GetIdentifier() const { |
| 169 return RELOAD_PLUGIN_INFOBAR_DELEGATE; | 169 return RELOAD_PLUGIN_INFOBAR_DELEGATE; |
| 170 } | 170 } |
| 171 | 171 |
| 172 gfx::VectorIconId ReloadPluginInfoBarDelegate::GetVectorIconId() const { | 172 const gfx::VectorIcon& ReloadPluginInfoBarDelegate::GetVectorIcon() const { |
| 173 return gfx::VectorIconId::EXTENSION_CRASHED; | 173 return kExtensionCrashedIcon; |
| 174 } | 174 } |
| 175 | 175 |
| 176 base::string16 ReloadPluginInfoBarDelegate::GetMessageText() const { | 176 base::string16 ReloadPluginInfoBarDelegate::GetMessageText() const { |
| 177 return message_; | 177 return message_; |
| 178 } | 178 } |
| 179 | 179 |
| 180 int ReloadPluginInfoBarDelegate::GetButtons() const { | 180 int ReloadPluginInfoBarDelegate::GetButtons() const { |
| 181 return BUTTON_OK; | 181 return BUTTON_OK; |
| 182 } | 182 } |
| 183 | 183 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 web_contents(), web_contents()->GetLastCommittedURL()); | 430 web_contents(), web_contents()->GetLastCommittedURL()); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { | 433 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { |
| 434 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( | 434 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( |
| 435 plugin_path); | 435 plugin_path); |
| 436 base::string16 plugin_name = | 436 base::string16 plugin_name = |
| 437 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 437 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
| 438 SimpleAlertInfoBarDelegate::Create( | 438 SimpleAlertInfoBarDelegate::Create( |
| 439 InfoBarService::FromWebContents(web_contents()), | 439 InfoBarService::FromWebContents(web_contents()), |
| 440 infobars::InfoBarDelegate::PLUGIN_OBSERVER, 0, | 440 infobars::InfoBarDelegate::PLUGIN_OBSERVER, &kExtensionCrashedIcon, |
| 441 gfx::VectorIconId::EXTENSION_CRASHED, | |
| 442 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 441 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
| 443 plugin_name), | 442 plugin_name), |
| 444 true); | 443 true); |
| 445 } | 444 } |
| OLD | NEW |