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 "content/ppapi_plugin/broker_process_dispatcher.h" | 5 #include "content/ppapi_plugin/broker_process_dispatcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/debug/dump_without_crashing.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "content/child/child_process.h" | 16 #include "content/child/child_process.h" |
16 #include "ppapi/c/pp_bool.h" | 17 #include "ppapi/c/pp_bool.h" |
17 #include "ppapi/c/private/ppp_flash_browser_operations.h" | 18 #include "ppapi/c/private/ppp_flash_browser_operations.h" |
18 #include "ppapi/proxy/ppapi_messages.h" | 19 #include "ppapi/proxy/ppapi_messages.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 namespace { | 22 namespace { |
22 | 23 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 site_vector.clear(); | 71 site_vector.clear(); |
71 } | 72 } |
72 context->dispatcher->OnGetPermissionSettingsCompleted( | 73 context->dispatcher->OnGetPermissionSettingsCompleted( |
73 context->request_id, PP_ToBool(success), default_permission, site_vector); | 74 context->request_id, PP_ToBool(success), default_permission, site_vector); |
74 } | 75 } |
75 | 76 |
76 } // namespace | 77 } // namespace |
77 | 78 |
78 BrokerProcessDispatcher::BrokerProcessDispatcher( | 79 BrokerProcessDispatcher::BrokerProcessDispatcher( |
79 PP_GetInterface_Func get_plugin_interface, | 80 PP_GetInterface_Func get_plugin_interface, |
80 PP_ConnectInstance_Func connect_instance) | 81 PP_ConnectInstance_Func connect_instance, |
| 82 bool peer_is_browser) |
81 : ppapi::proxy::BrokerSideDispatcher(connect_instance), | 83 : ppapi::proxy::BrokerSideDispatcher(connect_instance), |
82 get_plugin_interface_(get_plugin_interface), | 84 get_plugin_interface_(get_plugin_interface), |
83 flash_browser_operations_1_3_(NULL), | 85 flash_browser_operations_1_3_(NULL), |
84 flash_browser_operations_1_2_(NULL), | 86 flash_browser_operations_1_2_(NULL), |
85 flash_browser_operations_1_0_(NULL) { | 87 flash_browser_operations_1_0_(NULL), |
| 88 peer_is_browser_(peer_is_browser) { |
86 if (get_plugin_interface) { | 89 if (get_plugin_interface) { |
87 flash_browser_operations_1_0_ = | 90 flash_browser_operations_1_0_ = |
88 static_cast<const PPP_Flash_BrowserOperations_1_0*>( | 91 static_cast<const PPP_Flash_BrowserOperations_1_0*>( |
89 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0)); | 92 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0)); |
90 | 93 |
91 flash_browser_operations_1_2_ = | 94 flash_browser_operations_1_2_ = |
92 static_cast<const PPP_Flash_BrowserOperations_1_2*>( | 95 static_cast<const PPP_Flash_BrowserOperations_1_2*>( |
93 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2)); | 96 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2)); |
94 | 97 |
95 flash_browser_operations_1_3_ = | 98 flash_browser_operations_1_3_ = |
96 static_cast<const PPP_Flash_BrowserOperations_1_3*>( | 99 static_cast<const PPP_Flash_BrowserOperations_1_3*>( |
97 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3)); | 100 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3)); |
98 } | 101 } |
99 } | 102 } |
100 | 103 |
101 BrokerProcessDispatcher::~BrokerProcessDispatcher() { | 104 BrokerProcessDispatcher::~BrokerProcessDispatcher() { |
102 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()"; | 105 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()"; |
103 // Don't free the process right away. This timer allows the child process | 106 // Don't free the process right away. This timer allows the child process |
104 // to be re-used if the user rapidly goes to a new page that requires this | 107 // to be re-used if the user rapidly goes to a new page that requires this |
105 // plugin. This is the case for common plugins where they may be used on a | 108 // plugin. This is the case for common plugins where they may be used on a |
106 // source and destination page of a navigation. We don't want to tear down | 109 // source and destination page of a navigation. We don't want to tear down |
107 // and re-start processes each time in these cases. | 110 // and re-start processes each time in these cases. |
108 process_ref_.ReleaseWithDelay( | 111 process_ref_.ReleaseWithDelay( |
109 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds)); | 112 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds)); |
110 } | 113 } |
111 | 114 |
112 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) { | 115 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| 116 if (BrokerSideDispatcher::OnMessageReceived(msg)) |
| 117 return true; |
| 118 |
| 119 if (!peer_is_browser_) { |
| 120 // We might want to consider killing the peer instead is we see problems in |
| 121 // the future. |
| 122 if (msg.type() == PpapiMsg_GetSitesWithData::ID || |
| 123 msg.type() == PpapiMsg_ClearSiteData::ID || |
| 124 msg.type() == PpapiMsg_DeauthorizeContentLicenses::ID || |
| 125 msg.type() == PpapiMsg_GetPermissionSettings::ID || |
| 126 msg.type() == PpapiMsg_SetDefaultPermission::ID || |
| 127 msg.type() == PpapiMsg_SetSitePermission::ID) { |
| 128 base::debug::DumpWithoutCrashing(); |
| 129 } |
| 130 return false; |
| 131 } |
| 132 |
| 133 bool handled = true; |
113 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg) | 134 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg) |
114 IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnGetSitesWithData) | 135 IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnGetSitesWithData) |
115 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnClearSiteData) | 136 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnClearSiteData) |
116 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses, | 137 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses, |
117 OnDeauthorizeContentLicenses) | 138 OnDeauthorizeContentLicenses) |
118 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings, OnGetPermissionSettings) | 139 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings, |
| 140 OnGetPermissionSettings) |
119 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission, OnSetDefaultPermission) | 141 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission, OnSetDefaultPermission) |
120 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnSetSitePermission) | 142 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnSetSitePermission) |
121 IPC_MESSAGE_UNHANDLED(return BrokerSideDispatcher::OnMessageReceived(msg)) | 143 IPC_MESSAGE_UNHANDLED(handled = false) |
122 IPC_END_MESSAGE_MAP() | 144 IPC_END_MESSAGE_MAP() |
123 return true; | 145 return handled; |
124 } | 146 } |
125 | 147 |
126 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted( | 148 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted( |
127 uint32_t request_id, | 149 uint32_t request_id, |
128 bool success, | 150 bool success, |
129 PP_Flash_BrowserOperations_Permission default_permission, | 151 PP_Flash_BrowserOperations_Permission default_permission, |
130 const ppapi::FlashSiteSettings& sites) { | 152 const ppapi::FlashSiteSettings& sites) { |
131 Send(new PpapiHostMsg_GetPermissionSettingsResult( | 153 Send(new PpapiHostMsg_GetPermissionSettingsResult( |
132 request_id, success, default_permission, sites)); | 154 request_id, success, default_permission, sites)); |
133 } | 155 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 data_str.c_str(), setting_type, | 344 data_str.c_str(), setting_type, |
323 static_cast<uint32_t>(sites.size()), site_array.get()); | 345 static_cast<uint32_t>(sites.size()), site_array.get()); |
324 | 346 |
325 return PP_ToBool(result); | 347 return PP_ToBool(result); |
326 } | 348 } |
327 | 349 |
328 return false; | 350 return false; |
329 } | 351 } |
330 | 352 |
331 } // namespace content | 353 } // namespace content |
OLD | NEW |