| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 static void Create(InfoBarService* infobar_service, | 129 static void Create(InfoBarService* infobar_service, |
| 130 content::NavigationController* controller, | 130 content::NavigationController* controller, |
| 131 const base::string16& message); | 131 const base::string16& message); |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 ReloadPluginInfoBarDelegate(content::NavigationController* controller, | 134 ReloadPluginInfoBarDelegate(content::NavigationController* controller, |
| 135 const base::string16& message); | 135 const base::string16& message); |
| 136 ~ReloadPluginInfoBarDelegate() override; | 136 ~ReloadPluginInfoBarDelegate() override; |
| 137 | 137 |
| 138 // ConfirmInfobarDelegate: | 138 // ConfirmInfobarDelegate: |
| 139 std::string GetIdentifier() const override; |
| 139 int GetIconId() const override; | 140 int GetIconId() const override; |
| 140 gfx::VectorIconId GetVectorIconId() const override; | 141 gfx::VectorIconId GetVectorIconId() const override; |
| 141 base::string16 GetMessageText() const override; | 142 base::string16 GetMessageText() const override; |
| 142 int GetButtons() const override; | 143 int GetButtons() const override; |
| 143 base::string16 GetButtonLabel(InfoBarButton button) const override; | 144 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 144 bool Accept() override; | 145 bool Accept() override; |
| 145 | 146 |
| 146 content::NavigationController* controller_; | 147 content::NavigationController* controller_; |
| 147 base::string16 message_; | 148 base::string16 message_; |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 // static | 151 // static |
| 151 void ReloadPluginInfoBarDelegate::Create( | 152 void ReloadPluginInfoBarDelegate::Create( |
| 152 InfoBarService* infobar_service, | 153 InfoBarService* infobar_service, |
| 153 content::NavigationController* controller, | 154 content::NavigationController* controller, |
| 154 const base::string16& message) { | 155 const base::string16& message) { |
| 155 infobar_service->AddInfoBar( | 156 infobar_service->AddInfoBar( |
| 156 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( | 157 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
| 157 new ReloadPluginInfoBarDelegate(controller, message)))); | 158 new ReloadPluginInfoBarDelegate(controller, message)))); |
| 158 } | 159 } |
| 159 | 160 |
| 160 ReloadPluginInfoBarDelegate::ReloadPluginInfoBarDelegate( | 161 ReloadPluginInfoBarDelegate::ReloadPluginInfoBarDelegate( |
| 161 content::NavigationController* controller, | 162 content::NavigationController* controller, |
| 162 const base::string16& message) | 163 const base::string16& message) |
| 163 : controller_(controller), | 164 : controller_(controller), |
| 164 message_(message) {} | 165 message_(message) {} |
| 165 | 166 |
| 166 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate(){ } | 167 ReloadPluginInfoBarDelegate::~ReloadPluginInfoBarDelegate(){ } |
| 167 | 168 |
| 169 std::string ReloadPluginInfoBarDelegate::GetIdentifier() const { |
| 170 return "ReloadPluginInfoBarDelegate"; |
| 171 } |
| 172 |
| 168 int ReloadPluginInfoBarDelegate::GetIconId() const { | 173 int ReloadPluginInfoBarDelegate::GetIconId() const { |
| 169 return IDR_INFOBAR_PLUGIN_CRASHED; | 174 return IDR_INFOBAR_PLUGIN_CRASHED; |
| 170 } | 175 } |
| 171 | 176 |
| 172 gfx::VectorIconId ReloadPluginInfoBarDelegate::GetVectorIconId() const { | 177 gfx::VectorIconId ReloadPluginInfoBarDelegate::GetVectorIconId() const { |
| 173 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) | 178 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) |
| 174 return gfx::VectorIconId::EXTENSION_CRASHED; | 179 return gfx::VectorIconId::EXTENSION_CRASHED; |
| 175 #else | 180 #else |
| 176 return gfx::VectorIconId::VECTOR_ICON_NONE; | 181 return gfx::VectorIconId::VECTOR_ICON_NONE; |
| 177 #endif | 182 #endif |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); | 414 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); |
| 410 } | 415 } |
| 411 | 416 |
| 412 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { | 417 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { |
| 413 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( | 418 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( |
| 414 plugin_path); | 419 plugin_path); |
| 415 base::string16 plugin_name = | 420 base::string16 plugin_name = |
| 416 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 421 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
| 417 SimpleAlertInfoBarDelegate::Create( | 422 SimpleAlertInfoBarDelegate::Create( |
| 418 InfoBarService::FromWebContents(web_contents()), | 423 InfoBarService::FromWebContents(web_contents()), |
| 424 "PluginObserver", |
| 419 IDR_INFOBAR_PLUGIN_CRASHED, | 425 IDR_INFOBAR_PLUGIN_CRASHED, |
| 420 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) | 426 #if !defined(OS_MACOSX) && !defined(OS_IOS) && !defined(OS_ANDROID) |
| 421 gfx::VectorIconId::EXTENSION_CRASHED, | 427 gfx::VectorIconId::EXTENSION_CRASHED, |
| 422 #else | 428 #else |
| 423 gfx::VectorIconId::VECTOR_ICON_NONE, | 429 gfx::VectorIconId::VECTOR_ICON_NONE, |
| 424 #endif | 430 #endif |
| 425 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 431 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
| 426 plugin_name), | 432 plugin_name), |
| 427 true); | 433 true); |
| 428 } | 434 } |
| 429 | 435 |
| 430 void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { | 436 void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { |
| 431 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) | 437 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
| 432 #if !defined(USE_AURA) | 438 #if !defined(USE_AURA) |
| 433 DCHECK(base::win::IsMetroProcess()); | 439 DCHECK(base::win::IsMetroProcess()); |
| 434 #endif | 440 #endif |
| 435 | 441 |
| 436 scoped_ptr<PluginMetadata> plugin; | 442 scoped_ptr<PluginMetadata> plugin; |
| 437 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( | 443 bool ret = PluginFinder::GetInstance()->FindPluginWithIdentifier( |
| 438 identifier, NULL, &plugin); | 444 identifier, NULL, &plugin); |
| 439 DCHECK(ret); | 445 DCHECK(ret); |
| 440 | 446 |
| 441 PluginMetroModeInfoBarDelegate::Create( | 447 PluginMetroModeInfoBarDelegate::Create( |
| 442 InfoBarService::FromWebContents(web_contents()), | 448 InfoBarService::FromWebContents(web_contents()), |
| 443 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); | 449 PluginMetroModeInfoBarDelegate::DESKTOP_MODE_REQUIRED, plugin->name()); |
| 444 #endif | 450 #endif |
| 445 } | 451 } |
| OLD | NEW |