Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: chrome/browser/plugin_observer.cc

Issue 7648017: Make WebPluginInfo more generic (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/google/google_util.h" 9 #include "chrome/browser/google/google_util.h"
10 #include "chrome/browser/plugin_installer_infobar_delegate.h" 10 #include "chrome/browser/plugin_installer_infobar_delegate.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/render_messages.h" 15 #include "chrome/common/render_messages.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/user_metrics.h" 18 #include "content/browser/user_metrics.h"
19 #include "content/common/view_messages.h" 19 #include "content/common/view_messages.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources_standard.h" 21 #include "grit/theme_resources_standard.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
24 #include "webkit/plugins/npapi/default_plugin_shared.h" 24 #include "webkit/plugins/npapi/default_plugin_shared.h"
25 #include "webkit/plugins/npapi/plugin_group.h" 25 #include "webkit/plugins/npapi/plugin_group.h"
26 #include "webkit/plugins/npapi/plugin_list.h" 26 #include "webkit/plugins/npapi/plugin_list.h"
27 #include "webkit/plugins/npapi/webplugininfo.h" 27 #include "webkit/plugins/webplugininfo.h"
28 28
29 namespace { 29 namespace {
30 30
31 // PluginInfoBarDelegate ------------------------------------------------------ 31 // PluginInfoBarDelegate ------------------------------------------------------
32 32
33 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { 33 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate {
34 public: 34 public:
35 PluginInfoBarDelegate(TabContents* tab_contents, const string16& name); 35 PluginInfoBarDelegate(TabContents* tab_contents, const string16& name);
36 36
37 protected: 37 protected:
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return; 328 return;
329 } 329 }
330 } 330 }
331 #endif 331 #endif
332 } 332 }
333 333
334 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { 334 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) {
335 DCHECK(!plugin_path.value().empty()); 335 DCHECK(!plugin_path.value().empty());
336 336
337 string16 plugin_name = plugin_path.LossyDisplayName(); 337 string16 plugin_name = plugin_path.LossyDisplayName();
338 webkit::npapi::WebPluginInfo plugin_info; 338 webkit::WebPluginInfo plugin_info;
339 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( 339 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
340 plugin_path, &plugin_info) && 340 plugin_path, &plugin_info) &&
341 !plugin_info.name.empty()) { 341 !plugin_info.name.empty()) {
342 plugin_name = plugin_info.name; 342 plugin_name = plugin_info.name;
343 #if defined(OS_MACOSX) 343 #if defined(OS_MACOSX)
344 // Many plugins on the Mac have .plugin in the actual name, which looks 344 // Many plugins on the Mac have .plugin in the actual name, which looks
345 // terrible, so look for that and strip it off if present. 345 // terrible, so look for that and strip it off if present.
346 const std::string kPluginExtension = ".plugin"; 346 const std::string kPluginExtension = ".plugin";
347 if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) 347 if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true))
348 plugin_name.erase(plugin_name.length() - kPluginExtension.length()); 348 plugin_name.erase(plugin_name.length() - kPluginExtension.length());
349 #endif // OS_MACOSX 349 #endif // OS_MACOSX
350 } 350 }
351 gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 351 gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
352 IDR_INFOBAR_PLUGIN_CRASHED); 352 IDR_INFOBAR_PLUGIN_CRASHED);
353 tab_contents_->AddInfoBar(new SimpleAlertInfoBarDelegate(tab_contents(), 353 tab_contents_->AddInfoBar(new SimpleAlertInfoBarDelegate(tab_contents(),
354 icon, 354 icon,
355 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), 355 l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name),
356 true)); 356 true));
357 } 357 }
358 358
359 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, 359 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name,
360 const GURL& update_url) { 360 const GURL& update_url) {
361 tab_contents_->AddInfoBar(update_url.is_empty() ? 361 tab_contents_->AddInfoBar(update_url.is_empty() ?
362 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate( 362 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate(
363 tab_contents(), name)) : 363 tab_contents(), name)) :
364 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url)); 364 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url));
365 } 365 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_exceptions_table_model_unittest.cc ('k') | chrome/browser/plugin_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698