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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/infobars/infobar_service.h" | 15 #include "chrome/browser/infobars/infobar_service.h" |
16 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
17 #include "chrome/browser/plugins/plugin_finder.h" | 17 #include "chrome/browser/plugins/plugin_finder.h" |
18 #include "chrome/browser/plugins/plugin_infobar_delegates.h" | 18 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 20 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
21 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
24 #include "components/content_settings/content/common/content_settings_messages.h
" | 24 #include "components/content_settings/content/common/content_settings_messages.h
" |
25 #include "components/content_settings/core/browser/host_content_settings_map.h" | 25 #include "components/content_settings/core/browser/host_content_settings_map.h" |
26 #include "components/infobars/core/confirm_infobar_delegate.h" | 26 #include "components/infobars/core/confirm_infobar_delegate.h" |
27 #include "components/infobars/core/infobar.h" | 27 #include "components/infobars/core/infobar.h" |
| 28 #include "components/infobars/core/infobar_delegate.h" |
28 #include "components/infobars/core/simple_alert_infobar_delegate.h" | 29 #include "components/infobars/core/simple_alert_infobar_delegate.h" |
29 #include "components/metrics_services_manager/metrics_services_manager.h" | 30 #include "components/metrics_services_manager/metrics_services_manager.h" |
30 #include "content/public/browser/plugin_service.h" | 31 #include "content/public/browser/plugin_service.h" |
31 #include "content/public/browser/render_frame_host.h" | 32 #include "content/public/browser/render_frame_host.h" |
32 #include "content/public/browser/render_view_host.h" | 33 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
34 #include "content/public/browser/web_contents_delegate.h" | 35 #include "content/public/browser/web_contents_delegate.h" |
35 #include "content/public/common/webplugininfo.h" | 36 #include "content/public/common/webplugininfo.h" |
36 #include "grit/theme_resources.h" | 37 #include "grit/theme_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 static void Create(InfoBarService* infobar_service, | 131 static void Create(InfoBarService* infobar_service, |
131 content::NavigationController* controller, | 132 content::NavigationController* controller, |
132 const base::string16& message); | 133 const base::string16& message); |
133 | 134 |
134 private: | 135 private: |
135 ReloadPluginInfoBarDelegate(content::NavigationController* controller, | 136 ReloadPluginInfoBarDelegate(content::NavigationController* controller, |
136 const base::string16& message); | 137 const base::string16& message); |
137 ~ReloadPluginInfoBarDelegate() override; | 138 ~ReloadPluginInfoBarDelegate() override; |
138 | 139 |
139 // ConfirmInfobarDelegate: | 140 // ConfirmInfobarDelegate: |
| 141 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
140 int GetIconId() const override; | 142 int GetIconId() const override; |
141 gfx::VectorIconId GetVectorIconId() const override; | 143 gfx::VectorIconId GetVectorIconId() const override; |
142 base::string16 GetMessageText() const override; | 144 base::string16 GetMessageText() const override; |
143 int GetButtons() const override; | 145 int GetButtons() const override; |
144 base::string16 GetButtonLabel(InfoBarButton button) const override; | 146 base::string16 GetButtonLabel(InfoBarButton button) const override; |
145 bool Accept() override; | 147 bool Accept() override; |
146 | 148 |
147 content::NavigationController* controller_; | 149 content::NavigationController* controller_; |
148 base::string16 message_; | 150 base::string16 message_; |
149 }; | 151 }; |
150 | 152 |
151 // static | 153 // static |
152 void ReloadPluginInfoBarDelegate::Create( | 154 void ReloadPluginInfoBarDelegate::Create( |
153 InfoBarService* infobar_service, | 155 InfoBarService* infobar_service, |
154 content::NavigationController* controller, | 156 content::NavigationController* controller, |
155 const base::string16& message) { | 157 const base::string16& message) { |
156 infobar_service->AddInfoBar( | 158 infobar_service->AddInfoBar( |
157 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( | 159 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
158 new ReloadPluginInfoBarDelegate(controller, message)))); | 160 new ReloadPluginInfoBarDelegate(controller, message)))); |
159 } | 161 } |
160 | 162 |
161 ReloadPluginInfoBarDelegate::ReloadPluginInfoBarDelegate( | 163 ReloadPluginInfoBarDelegate::ReloadPluginInfoBarDelegate( |
162 content::NavigationController* controller, | 164 content::NavigationController* controller, |
163 const base::string16& message) | 165 const base::string16& message) |
164 : controller_(controller), | 166 : controller_(controller), |
165 message_(message) {} | 167 message_(message) {} |
166 | 168 |
167 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate(){ } | 169 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate(){ } |
168 | 170 |
| 171 infobars::InfoBarDelegate::InfoBarIdentifier |
| 172 ReloadPluginInfoBarDelegate::GetIdentifier() const { |
| 173 return RELOAD_PLUGIN_INFOBAR_DELEGATE; |
| 174 } |
| 175 |
169 int ReloadPluginInfoBarDelegate::GetIconId() const { | 176 int ReloadPluginInfoBarDelegate::GetIconId() const { |
170 return IDR_INFOBAR_PLUGIN_CRASHED; | 177 return IDR_INFOBAR_PLUGIN_CRASHED; |
171 } | 178 } |
172 | 179 |
173 gfx::VectorIconId ReloadPluginInfoBarDelegate::GetVectorIconId() const { | 180 gfx::VectorIconId ReloadPluginInfoBarDelegate::GetVectorIconId() const { |
174 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) | 181 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) |
175 return gfx::VectorIconId::EXTENSION_CRASHED; | 182 return gfx::VectorIconId::EXTENSION_CRASHED; |
176 #else | 183 #else |
177 return gfx::VectorIconId::VECTOR_ICON_NONE; | 184 return gfx::VectorIconId::VECTOR_ICON_NONE; |
178 #endif | 185 #endif |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); | 417 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); |
411 } | 418 } |
412 | 419 |
413 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { | 420 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { |
414 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( | 421 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( |
415 plugin_path); | 422 plugin_path); |
416 base::string16 plugin_name = | 423 base::string16 plugin_name = |
417 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 424 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
418 SimpleAlertInfoBarDelegate::Create( | 425 SimpleAlertInfoBarDelegate::Create( |
419 InfoBarService::FromWebContents(web_contents()), | 426 InfoBarService::FromWebContents(web_contents()), |
| 427 infobars::InfoBarDelegate::PLUGIN_OBSERVER, |
420 IDR_INFOBAR_PLUGIN_CRASHED, | 428 IDR_INFOBAR_PLUGIN_CRASHED, |
421 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) | 429 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) |
422 gfx::VectorIconId::EXTENSION_CRASHED, | 430 gfx::VectorIconId::EXTENSION_CRASHED, |
423 #else | 431 #else |
424 gfx::VectorIconId::VECTOR_ICON_NONE, | 432 gfx::VectorIconId::VECTOR_ICON_NONE, |
425 #endif | 433 #endif |
426 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 434 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
427 plugin_name), | 435 plugin_name), |
428 true); | 436 true); |
429 } | 437 } |
430 | 438 |
431 void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { | 439 void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { |
432 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) | 440 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
433 #if !defined(USE_AURA) | 441 #if !defined(USE_AURA) |
434 DCHECK(base::win::IsMetroProcess()); | 442 DCHECK(base::win::IsMetroProcess()); |
435 #endif | 443 #endif |
436 | 444 |
437 scoped_ptr<PluginMetadata> plugin; | 445 scoped_ptr<PluginMetadata> plugin; |
438 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( | 446 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( |
439 identifier, NULL, &plugin); | 447 identifier, NULL, &plugin); |
440 DCHECK(ret); | 448 DCHECK(ret); |
441 | 449 |
442 PluginMetroModeInfoBarDelegate::Create( | 450 PluginMetroModeInfoBarDelegate::Create( |
443 InfoBarService::FromWebContents(web_contents()), | 451 InfoBarService::FromWebContents(web_contents()), |
444 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); | 452 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); |
445 #endif | 453 #endif |
446 } | 454 } |
OLD | NEW |