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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/debug/crash_logging.h" | 11 #include "base/debug/crash_logging.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/infobars/infobar_service.h" | 17 #include "chrome/browser/infobars/infobar_service.h" |
18 #include "chrome/browser/lifetime/application_lifetime.h" | 18 #include "chrome/browser/lifetime/application_lifetime.h" |
19 #include "chrome/browser/plugins/flash_download_interception.h" | 19 #include "chrome/browser/plugins/flash_download_interception.h" |
20 #include "chrome/browser/plugins/plugin_finder.h" | 20 #include "chrome/browser/plugins/plugin_finder.h" |
21 #include "chrome/browser/plugins/plugin_infobar_delegates.h" | 21 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 23 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
24 #include "chrome/common/features.h" | 24 #include "chrome/common/features.h" |
25 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
26 #include "chrome/common/url_constants.h" | |
27 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
28 #include "chrome/grit/theme_resources.h" | 27 #include "chrome/grit/theme_resources.h" |
29 #include "components/component_updater/component_updater_service.h" | 28 #include "components/component_updater/component_updater_service.h" |
30 #include "components/content_settings/core/browser/host_content_settings_map.h" | 29 #include "components/content_settings/core/browser/host_content_settings_map.h" |
31 #include "components/infobars/core/confirm_infobar_delegate.h" | 30 #include "components/infobars/core/confirm_infobar_delegate.h" |
32 #include "components/infobars/core/infobar.h" | 31 #include "components/infobars/core/infobar.h" |
33 #include "components/infobars/core/infobar_delegate.h" | 32 #include "components/infobars/core/infobar_delegate.h" |
34 #include "components/infobars/core/simple_alert_infobar_delegate.h" | 33 #include "components/infobars/core/simple_alert_infobar_delegate.h" |
35 #include "components/metrics_services_manager/metrics_services_manager.h" | 34 #include "components/metrics_services_manager/metrics_services_manager.h" |
36 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/plugin_service.h" | 36 #include "content/public/browser/plugin_service.h" |
38 #include "content/public/browser/render_frame_host.h" | 37 #include "content/public/browser/render_frame_host.h" |
39 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
40 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
41 #include "content/public/browser/web_contents_delegate.h" | 40 #include "content/public/browser/web_contents_delegate.h" |
42 #include "content/public/common/webplugininfo.h" | 41 #include "content/public/common/webplugininfo.h" |
43 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
44 #include "ui/gfx/vector_icons_public.h" | 43 #include "ui/gfx/vector_icons_public.h" |
45 | 44 |
46 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 45 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
47 #include "chrome/browser/plugins/plugin_installer.h" | 46 #include "chrome/browser/plugins/plugin_installer.h" |
48 #include "chrome/browser/plugins/plugin_installer_observer.h" | 47 #include "chrome/browser/plugins/plugin_installer_observer.h" |
49 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 48 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
50 #endif // BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 49 #endif // BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
51 | 50 |
52 using content::OpenURLParams; | |
53 using content::PluginService; | 51 using content::PluginService; |
54 using content::Referrer; | |
55 using content::WebContents; | |
56 | 52 |
57 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginObserver); | 53 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginObserver); |
58 | 54 |
59 namespace { | 55 namespace { |
60 | 56 |
61 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 57 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
62 | 58 |
63 // ConfirmInstallDialogDelegate ------------------------------------------------ | 59 // ConfirmInstallDialogDelegate ------------------------------------------------ |
64 | 60 |
65 class ConfirmInstallDialogDelegate : public TabModalConfirmDialogDelegate, | 61 class ConfirmInstallDialogDelegate : public TabModalConfirmDialogDelegate, |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 content::RenderFrameHost* render_frame_host) { | 355 content::RenderFrameHost* render_frame_host) { |
360 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) | 356 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) |
361 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, | 357 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, |
362 OnBlockedOutdatedPlugin) | 358 OnBlockedOutdatedPlugin) |
363 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedComponentUpdatedPlugin, | 359 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedComponentUpdatedPlugin, |
364 OnBlockedComponentUpdatedPlugin) | 360 OnBlockedComponentUpdatedPlugin) |
365 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 361 #if BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
366 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, | 362 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, |
367 OnRemovePluginPlaceholderHost) | 363 OnRemovePluginPlaceholderHost) |
368 #endif | 364 #endif |
369 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenAboutPlugins, | |
370 OnOpenAboutPlugins) | |
371 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowFlashPermissionBubble, | 365 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowFlashPermissionBubble, |
372 OnShowFlashPermissionBubble) | 366 OnShowFlashPermissionBubble) |
373 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, | 367 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, |
374 OnCouldNotLoadPlugin) | 368 OnCouldNotLoadPlugin) |
375 | 369 |
376 IPC_MESSAGE_UNHANDLED(return false) | 370 IPC_MESSAGE_UNHANDLED(return false) |
377 IPC_END_MESSAGE_MAP() | 371 IPC_END_MESSAGE_MAP() |
378 | 372 |
379 return true; | 373 return true; |
380 } | 374 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 void PluginObserver::OnRemovePluginPlaceholderHost(int placeholder_id) { | 416 void PluginObserver::OnRemovePluginPlaceholderHost(int placeholder_id) { |
423 auto it = plugin_placeholders_.find(placeholder_id); | 417 auto it = plugin_placeholders_.find(placeholder_id); |
424 if (it == plugin_placeholders_.end()) { | 418 if (it == plugin_placeholders_.end()) { |
425 NOTREACHED(); | 419 NOTREACHED(); |
426 return; | 420 return; |
427 } | 421 } |
428 plugin_placeholders_.erase(it); | 422 plugin_placeholders_.erase(it); |
429 } | 423 } |
430 #endif // BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) | 424 #endif // BUILDFLAG(ENABLE_PLUGIN_INSTALLATION) |
431 | 425 |
432 void PluginObserver::OnOpenAboutPlugins() { | |
433 web_contents()->OpenURL( | |
434 OpenURLParams(GURL(chrome::kChromeUIPluginsURL), | |
435 content::Referrer::SanitizeForRequest( | |
436 GURL(chrome::kChromeUIPluginsURL), | |
437 content::Referrer(web_contents()->GetURL(), | |
438 blink::WebReferrerPolicyDefault)), | |
439 WindowOpenDisposition::NEW_FOREGROUND_TAB, | |
440 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); | |
441 } | |
442 | |
443 void PluginObserver::OnShowFlashPermissionBubble() { | 426 void PluginObserver::OnShowFlashPermissionBubble() { |
444 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 427 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
445 | 428 |
446 FlashDownloadInterception::InterceptFlashDownloadNavigation( | 429 FlashDownloadInterception::InterceptFlashDownloadNavigation( |
447 web_contents(), web_contents()->GetLastCommittedURL()); | 430 web_contents(), web_contents()->GetLastCommittedURL()); |
448 } | 431 } |
449 | 432 |
450 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { | 433 void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { |
451 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( | 434 g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( |
452 plugin_path); | 435 plugin_path); |
453 base::string16 plugin_name = | 436 base::string16 plugin_name = |
454 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 437 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
455 SimpleAlertInfoBarDelegate::Create( | 438 SimpleAlertInfoBarDelegate::Create( |
456 InfoBarService::FromWebContents(web_contents()), | 439 InfoBarService::FromWebContents(web_contents()), |
457 infobars::InfoBarDelegate::PLUGIN_OBSERVER, 0, | 440 infobars::InfoBarDelegate::PLUGIN_OBSERVER, 0, |
458 gfx::VectorIconId::EXTENSION_CRASHED, | 441 gfx::VectorIconId::EXTENSION_CRASHED, |
459 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 442 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
460 plugin_name), | 443 plugin_name), |
461 true); | 444 true); |
462 } | 445 } |
OLD | NEW |