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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "chrome/common/render_messages.h" | 29 #include "chrome/common/render_messages.h" |
30 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
31 #include "components/component_updater/component_updater_service.h" | 31 #include "components/component_updater/component_updater_service.h" |
32 #include "components/content_settings/core/browser/host_content_settings_map.h" | 32 #include "components/content_settings/core/browser/host_content_settings_map.h" |
33 #include "components/infobars/core/confirm_infobar_delegate.h" | 33 #include "components/infobars/core/confirm_infobar_delegate.h" |
34 #include "components/infobars/core/infobar.h" | 34 #include "components/infobars/core/infobar.h" |
35 #include "components/infobars/core/infobar_delegate.h" | 35 #include "components/infobars/core/infobar_delegate.h" |
36 #include "components/infobars/core/simple_alert_infobar_delegate.h" | 36 #include "components/infobars/core/simple_alert_infobar_delegate.h" |
37 #include "components/metrics_services_manager/metrics_services_manager.h" | 37 #include "components/metrics_services_manager/metrics_services_manager.h" |
38 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/child_process_security_policy.h" |
39 #include "content/public/browser/plugin_service.h" | 40 #include "content/public/browser/plugin_service.h" |
40 #include "content/public/browser/render_frame_host.h" | 41 #include "content/public/browser/render_frame_host.h" |
41 #include "content/public/browser/render_view_host.h" | 42 #include "content/public/browser/render_view_host.h" |
42 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
43 #include "content/public/browser/web_contents_delegate.h" | 44 #include "content/public/browser/web_contents_delegate.h" |
44 #include "content/public/common/webplugininfo.h" | 45 #include "content/public/common/webplugininfo.h" |
45 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
46 | 47 |
47 using content::PluginService; | 48 using content::PluginService; |
48 | 49 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 250 |
250 ReloadPluginInfoBarDelegate::Create( | 251 ReloadPluginInfoBarDelegate::Create( |
251 InfoBarService::FromWebContents(web_contents()), | 252 InfoBarService::FromWebContents(web_contents()), |
252 &web_contents()->GetController(), | 253 &web_contents()->GetController(), |
253 infobar_text); | 254 infobar_text); |
254 } | 255 } |
255 | 256 |
256 bool PluginObserver::OnMessageReceived( | 257 bool PluginObserver::OnMessageReceived( |
257 const IPC::Message& message, | 258 const IPC::Message& message, |
258 content::RenderFrameHost* render_frame_host) { | 259 content::RenderFrameHost* render_frame_host) { |
| 260 bool handled = true; |
259 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) | 261 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) |
260 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, | 262 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, |
261 OnBlockedOutdatedPlugin) | 263 OnBlockedOutdatedPlugin) |
262 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedComponentUpdatedPlugin, | 264 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedComponentUpdatedPlugin, |
263 OnBlockedComponentUpdatedPlugin) | 265 OnBlockedComponentUpdatedPlugin) |
264 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, | 266 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, |
265 OnRemovePluginPlaceholderHost) | 267 OnRemovePluginPlaceholderHost) |
266 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowFlashPermissionBubble, | 268 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ShowFlashPermissionBubble, |
267 OnShowFlashPermissionBubble) | 269 OnShowFlashPermissionBubble) |
268 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, | 270 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, |
269 OnCouldNotLoadPlugin) | 271 OnCouldNotLoadPlugin) |
| 272 IPC_MESSAGE_UNHANDLED(handled = false) |
| 273 IPC_END_MESSAGE_MAP() |
270 | 274 |
| 275 if (handled) |
| 276 return true; |
| 277 |
| 278 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(PluginObserver, message, render_frame_host) |
| 279 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenPDF, OnOpenPDF) |
271 IPC_MESSAGE_UNHANDLED(return false) | 280 IPC_MESSAGE_UNHANDLED(return false) |
272 IPC_END_MESSAGE_MAP() | 281 IPC_END_MESSAGE_MAP() |
273 | 282 |
274 return true; | 283 return true; |
275 } | 284 } |
276 | 285 |
277 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, | 286 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, |
278 const std::string& identifier) { | 287 const std::string& identifier) { |
279 PluginFinder* finder = PluginFinder::GetInstance(); | 288 PluginFinder* finder = PluginFinder::GetInstance(); |
280 // Find plugin to update. | 289 // Find plugin to update. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 plugin_path); | 337 plugin_path); |
329 base::string16 plugin_name = | 338 base::string16 plugin_name = |
330 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); | 339 PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); |
331 SimpleAlertInfoBarDelegate::Create( | 340 SimpleAlertInfoBarDelegate::Create( |
332 InfoBarService::FromWebContents(web_contents()), | 341 InfoBarService::FromWebContents(web_contents()), |
333 infobars::InfoBarDelegate::PLUGIN_OBSERVER, &kExtensionCrashedIcon, | 342 infobars::InfoBarDelegate::PLUGIN_OBSERVER, &kExtensionCrashedIcon, |
334 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 343 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
335 plugin_name), | 344 plugin_name), |
336 true); | 345 true); |
337 } | 346 } |
| 347 |
| 348 void PluginObserver::OnOpenPDF(content::RenderFrameHost* render_frame_host, |
| 349 const GURL& url) { |
| 350 if (!content::ChildProcessSecurityPolicy::GetInstance()->CanRequestURL( |
| 351 render_frame_host->GetRoutingID(), url)) |
| 352 return; |
| 353 |
| 354 web_contents()->OpenURL(content::OpenURLParams( |
| 355 url, |
| 356 content::Referrer::SanitizeForRequest( |
| 357 url, content::Referrer(web_contents()->GetURL(), |
| 358 blink::kWebReferrerPolicyDefault)), |
| 359 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 360 ui::PAGE_TRANSITION_AUTO_BOOKMARK, false)); |
| 361 } |
OLD | NEW |