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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "components/infobars/core/infobar.h" | 27 #include "components/infobars/core/infobar.h" |
28 #include "components/infobars/core/simple_alert_infobar_delegate.h" | 28 #include "components/infobars/core/simple_alert_infobar_delegate.h" |
29 #include "content/public/browser/plugin_service.h" | 29 #include "content/public/browser/plugin_service.h" |
30 #include "content/public/browser/render_frame_host.h" | 30 #include "content/public/browser/render_frame_host.h" |
31 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
32 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
33 #include "content/public/browser/web_contents_delegate.h" | 33 #include "content/public/browser/web_contents_delegate.h" |
34 #include "content/public/common/webplugininfo.h" | 34 #include "content/public/common/webplugininfo.h" |
35 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/gfx/vector_icons_public.h" |
37 | 38 |
38 #if defined(ENABLE_PLUGIN_INSTALLATION) | 39 #if defined(ENABLE_PLUGIN_INSTALLATION) |
39 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
40 #include "base/win/metro.h" | 41 #include "base/win/metro.h" |
41 #endif | 42 #endif |
42 #include "chrome/browser/plugins/plugin_installer.h" | 43 #include "chrome/browser/plugins/plugin_installer.h" |
43 #include "chrome/browser/plugins/plugin_installer_observer.h" | 44 #include "chrome/browser/plugins/plugin_installer_observer.h" |
44 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 45 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
45 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 46 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
46 | 47 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 content::NavigationController* controller, | 130 content::NavigationController* controller, |
130 const base::string16& message); | 131 const base::string16& message); |
131 | 132 |
132 private: | 133 private: |
133 ReloadPluginInfoBarDelegate(content::NavigationController* controller, | 134 ReloadPluginInfoBarDelegate(content::NavigationController* controller, |
134 const base::string16& message); | 135 const base::string16& message); |
135 ~ReloadPluginInfoBarDelegate() override; | 136 ~ReloadPluginInfoBarDelegate() override; |
136 | 137 |
137 // ConfirmInfobarDelegate: | 138 // ConfirmInfobarDelegate: |
138 int GetIconId() const override; | 139 int GetIconId() const override; |
| 140 gfx::VectorIconId GetVectorIconId() const override; |
139 base::string16 GetMessageText() const override; | 141 base::string16 GetMessageText() const override; |
140 int GetButtons() const override; | 142 int GetButtons() const override; |
141 base::string16 GetButtonLabel(InfoBarButton button) const override; | 143 base::string16 GetButtonLabel(InfoBarButton button) const override; |
142 bool Accept() override; | 144 bool Accept() override; |
143 | 145 |
144 content::NavigationController* controller_; | 146 content::NavigationController* controller_; |
145 base::string16 message_; | 147 base::string16 message_; |
146 }; | 148 }; |
147 | 149 |
148 // static | 150 // static |
(...skipping 11 matching lines...) Expand all Loading... |
160 const base::string16& message) | 162 const base::string16& message) |
161 : controller_(controller), | 163 : controller_(controller), |
162 message_(message) {} | 164 message_(message) {} |
163 | 165 |
164 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate(){ } | 166 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate(){ } |
165 | 167 |
166 int ReloadPluginInfoBarDelegate::GetIconId() const { | 168 int ReloadPluginInfoBarDelegate::GetIconId() const { |
167 return IDR_INFOBAR_PLUGIN_CRASHED; | 169 return IDR_INFOBAR_PLUGIN_CRASHED; |
168 } | 170 } |
169 | 171 |
| 172 gfx::VectorIconId ReloadPluginInfoBarDelegate::GetVectorIconId() const { |
| 173 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) |
| 174 return gfx::VectorIconId::EXTENSION_CRASHED; |
| 175 #else |
| 176 return gfx::VectorIconId::VECTOR_ICON_NONE; |
| 177 #endif |
| 178 } |
| 179 |
170 base::string16 ReloadPluginInfoBarDelegate::GetMessageText() const { | 180 base::string16 ReloadPluginInfoBarDelegate::GetMessageText() const { |
171 return message_; | 181 return message_; |
172 } | 182 } |
173 | 183 |
174 int ReloadPluginInfoBarDelegate::GetButtons() const { | 184 int ReloadPluginInfoBarDelegate::GetButtons() const { |
175 return BUTTON_OK; | 185 return BUTTON_OK; |
176 } | 186 } |
177 | 187 |
178 base::string16 ReloadPluginInfoBarDelegate::GetButtonLabel( | 188 base::string16 ReloadPluginInfoBarDelegate::GetButtonLabel( |
179 InfoBarButton button) const { | 189 InfoBarButton button) const { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 410 } |
401 | 411 |
402 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { | 412 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { |
403 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( | 413 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( |
404 plugin_path); | 414 plugin_path); |
405 base::string16 plugin_name = | 415 base::string16 plugin_name = |
406 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 416 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
407 SimpleAlertInfoBarDelegate::Create( | 417 SimpleAlertInfoBarDelegate::Create( |
408 InfoBarService::FromWebContents(web_contents()), | 418 InfoBarService::FromWebContents(web_contents()), |
409 IDR_INFOBAR_PLUGIN_CRASHED, | 419 IDR_INFOBAR_PLUGIN_CRASHED, |
| 420 #if !defined(OS_MACOSX) |
| 421 gfx::VectorIconId::EXTENSION_CRASHED, |
| 422 #else |
| 423 gfx::VectorIconId::VECTOR_ICON_NONE, |
| 424 #endif |
410 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 425 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
411 plugin_name), | 426 plugin_name), |
412 true); | 427 true); |
413 } | 428 } |
414 | 429 |
415 void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { | 430 void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { |
416 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) | 431 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
417 #if !defined(USE_AURA) | 432 #if !defined(USE_AURA) |
418 DCHECK(base::win::IsMetroProcess()); | 433 DCHECK(base::win::IsMetroProcess()); |
419 #endif | 434 #endif |
420 | 435 |
421 scoped_ptr<PluginMetadata> plugin; | 436 scoped_ptr<PluginMetadata> plugin; |
422 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( | 437 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( |
423 identifier, NULL, &plugin); | 438 identifier, NULL, &plugin); |
424 DCHECK(ret); | 439 DCHECK(ret); |
425 | 440 |
426 PluginMetroModeInfoBarDelegate::Create( | 441 PluginMetroModeInfoBarDelegate::Create( |
427 InfoBarService::FromWebContents(web_contents()), | 442 InfoBarService::FromWebContents(web_contents()), |
428 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); | 443 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); |
429 #endif | 444 #endif |
430 } | 445 } |
OLD | NEW |