| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_observer.h" | 5 #include "chrome/browser/plugin_observer.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/metrics/user_metrics.h" | 9 #include "chrome/browser/metrics/user_metrics.h" |
| 10 #include "chrome/browser/plugin_installer_infobar_delegate.h" | 10 #include "chrome/browser/plugin_installer_infobar_delegate.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 void PluginObserver::OnMissingPluginStatus(int status) { | 251 void PluginObserver::OnMissingPluginStatus(int status) { |
| 252 #if defined(OS_WIN) | 252 #if defined(OS_WIN) |
| 253 // TODO(PORT): pull in when plug-ins work | 253 // TODO(PORT): pull in when plug-ins work |
| 254 GetPluginInstaller()->OnMissingPluginStatus(status); | 254 GetPluginInstaller()->OnMissingPluginStatus(status); |
| 255 #endif | 255 #endif |
| 256 } | 256 } |
| 257 | 257 |
| 258 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { | 258 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { |
| 259 DCHECK(!plugin_path.value().empty()); | 259 DCHECK(!plugin_path.value().empty()); |
| 260 | 260 |
| 261 std::wstring plugin_name = plugin_path.ToWStringHack(); | 261 string16 plugin_name = plugin_path.LossyDisplayName(); |
| 262 webkit::npapi::WebPluginInfo plugin_info; | 262 webkit::npapi::WebPluginInfo plugin_info; |
| 263 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 263 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
| 264 plugin_path, &plugin_info) && | 264 plugin_path, &plugin_info) && |
| 265 !plugin_info.name.empty()) { | 265 !plugin_info.name.empty()) { |
| 266 plugin_name = UTF16ToWide(plugin_info.name); | 266 plugin_name = plugin_info.name; |
| 267 #if defined(OS_MACOSX) | 267 #if defined(OS_MACOSX) |
| 268 // Many plugins on the Mac have .plugin in the actual name, which looks | 268 // Many plugins on the Mac have .plugin in the actual name, which looks |
| 269 // terrible, so look for that and strip it off if present. | 269 // terrible, so look for that and strip it off if present. |
| 270 const std::wstring plugin_extension(L".plugin"); | 270 const char* kPluginExtension = ".plugin"; |
| 271 if (EndsWith(plugin_name, plugin_extension, true)) | 271 if (EndsWith(plugin_name, ASCIIToUTF16(plugin_extension), true)) |
| 272 plugin_name.erase(plugin_name.length() - plugin_extension.length()); | 272 plugin_name.erase(plugin_name.length() - plugin_extension.length()); |
| 273 #endif // OS_MACOSX | 273 #endif // OS_MACOSX |
| 274 } | 274 } |
| 275 SkBitmap* crash_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( | 275 SkBitmap* crash_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 276 IDR_INFOBAR_PLUGIN_CRASHED); | 276 IDR_INFOBAR_PLUGIN_CRASHED); |
| 277 tab_contents_->AddInfoBar(new SimpleAlertInfoBarDelegate( | 277 tab_contents_->AddInfoBar(new SimpleAlertInfoBarDelegate( |
| 278 tab_contents_, crash_icon, | 278 tab_contents_, crash_icon, |
| 279 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, | 279 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), |
| 280 WideToUTF16Hack(plugin_name)), true)); | 280 true)); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, | 283 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, |
| 284 const GURL& update_url) { | 284 const GURL& update_url) { |
| 285 if (!update_url.is_empty()) | 285 if (!update_url.is_empty()) |
| 286 new OutdatedPluginInfoBar(tab_contents_, name, update_url); | 286 new OutdatedPluginInfoBar(tab_contents_, name, update_url); |
| 287 else | 287 else |
| 288 new BlockedPluginInfoBar(tab_contents_, name); | 288 new BlockedPluginInfoBar(tab_contents_, name); |
| 289 } | 289 } |
| 290 | 290 |
| OLD | NEW |