OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/guest_view/web_view/plugin_permission_helper.h" | 5 #include "chrome/browser/guest_view/web_view/plugin_permission_helper.h" |
6 | 6 |
7 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 7 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
8 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" | 8 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
9 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 9 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/user_metrics.h" | 13 #include "content/public/browser/user_metrics.h" |
14 | 14 |
15 using content::BrowserPluginGuestDelegate; | 15 using content::BrowserPluginGuestDelegate; |
16 using content::RenderViewHost; | 16 using content::RenderViewHost; |
17 using content::WebContents; | 17 using content::WebContents; |
18 | 18 |
19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginPermissionHelper); | 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginPermissionHelper); |
20 | 20 |
21 PluginPermissionHelper::PluginPermissionHelper(WebContents* contents) | 21 PluginPermissionHelper::PluginPermissionHelper(WebContents* contents) |
22 : content::WebContentsObserver(contents), | 22 : content::WebContentsObserver(contents), |
23 weak_factory_(this) { | 23 weak_factory_(this) { |
24 } | 24 } |
25 | 25 |
26 PluginPermissionHelper::~PluginPermissionHelper() { | 26 PluginPermissionHelper::~PluginPermissionHelper() { |
27 } | 27 } |
28 | 28 |
29 bool PluginPermissionHelper::OnMessageReceived( | |
30 const IPC::Message& message, | |
31 content::RenderFrameHost* render_frame_host) { | |
32 IPC_BEGIN_MESSAGE_MAP(PluginPermissionHelper, message) | |
33 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, | |
34 OnBlockedOutdatedPlugin) | |
35 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedUnauthorizedPlugin, | |
36 OnBlockedUnauthorizedPlugin) | |
37 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, | |
38 OnNPAPINotSupported) | |
39 IPC_MESSAGE_UNHANDLED(return false) | |
40 IPC_END_MESSAGE_MAP() | |
41 | |
42 return true; | |
43 } | |
44 | |
45 bool PluginPermissionHelper::OnMessageReceived(const IPC::Message& message) { | 29 bool PluginPermissionHelper::OnMessageReceived(const IPC::Message& message) { |
46 IPC_BEGIN_MESSAGE_MAP(PluginPermissionHelper, message) | 30 IPC_BEGIN_MESSAGE_MAP(PluginPermissionHelper, message) |
| 31 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedUnauthorizedPlugin, |
| 32 OnBlockedUnauthorizedPlugin) |
47 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, | 33 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, |
48 OnCouldNotLoadPlugin) | 34 OnCouldNotLoadPlugin) |
| 35 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, |
| 36 OnBlockedOutdatedPlugin) |
| 37 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, |
| 38 OnNPAPINotSupported) |
49 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenAboutPlugins, | 39 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenAboutPlugins, |
50 OnOpenAboutPlugins) | 40 OnOpenAboutPlugins) |
51 #if defined(ENABLE_PLUGIN_INSTALLATION) | 41 #if defined(ENABLE_PLUGIN_INSTALLATION) |
52 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FindMissingPlugin, | 42 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FindMissingPlugin, |
53 OnFindMissingPlugin) | 43 OnFindMissingPlugin) |
54 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, | 44 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, |
55 OnRemovePluginPlaceholderHost) | 45 OnRemovePluginPlaceholderHost) |
56 #endif | 46 #endif |
57 IPC_MESSAGE_UNHANDLED(return false) | 47 IPC_MESSAGE_UNHANDLED(return false) |
58 IPC_END_MESSAGE_MAP() | 48 IPC_END_MESSAGE_MAP() |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 100 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
111 | 101 |
112 void PluginPermissionHelper::OnPermissionResponse(const std::string& identifier, | 102 void PluginPermissionHelper::OnPermissionResponse(const std::string& identifier, |
113 bool allow, | 103 bool allow, |
114 const std::string& input) { | 104 const std::string& input) { |
115 if (allow) { | 105 if (allow) { |
116 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( | 106 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
117 web_contents(), true, identifier); | 107 web_contents(), true, identifier); |
118 } | 108 } |
119 } | 109 } |
OLD | NEW |