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

Side by Side Diff: content/ppapi_plugin/broker_process_dispatcher.cc

Issue 2069853002: Ignore certain messages in plugin broker process if they are not sent by the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
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
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 site_vector.clear(); 70 site_vector.clear();
71 } 71 }
72 context->dispatcher->OnGetPermissionSettingsCompleted( 72 context->dispatcher->OnGetPermissionSettingsCompleted(
73 context->request_id, PP_ToBool(success), default_permission, site_vector); 73 context->request_id, PP_ToBool(success), default_permission, site_vector);
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 BrokerProcessDispatcher::BrokerProcessDispatcher( 78 BrokerProcessDispatcher::BrokerProcessDispatcher(
79 PP_GetInterface_Func get_plugin_interface, 79 PP_GetInterface_Func get_plugin_interface,
80 PP_ConnectInstance_Func connect_instance) 80 PP_ConnectInstance_Func connect_instance,
81 bool peer_is_browser)
81 : ppapi::proxy::BrokerSideDispatcher(connect_instance), 82 : ppapi::proxy::BrokerSideDispatcher(connect_instance),
82 get_plugin_interface_(get_plugin_interface), 83 get_plugin_interface_(get_plugin_interface),
83 flash_browser_operations_1_3_(NULL), 84 flash_browser_operations_1_3_(NULL),
84 flash_browser_operations_1_2_(NULL), 85 flash_browser_operations_1_2_(NULL),
85 flash_browser_operations_1_0_(NULL) { 86 flash_browser_operations_1_0_(NULL),
87 peer_is_browser_(peer_is_browser) {
86 if (get_plugin_interface) { 88 if (get_plugin_interface) {
87 flash_browser_operations_1_0_ = 89 flash_browser_operations_1_0_ =
88 static_cast<const PPP_Flash_BrowserOperations_1_0*>( 90 static_cast<const PPP_Flash_BrowserOperations_1_0*>(
89 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0)); 91 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0));
90 92
91 flash_browser_operations_1_2_ = 93 flash_browser_operations_1_2_ =
92 static_cast<const PPP_Flash_BrowserOperations_1_2*>( 94 static_cast<const PPP_Flash_BrowserOperations_1_2*>(
93 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2)); 95 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2));
94 96
95 flash_browser_operations_1_3_ = 97 flash_browser_operations_1_3_ =
96 static_cast<const PPP_Flash_BrowserOperations_1_3*>( 98 static_cast<const PPP_Flash_BrowserOperations_1_3*>(
97 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3)); 99 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3));
98 } 100 }
99 } 101 }
100 102
101 BrokerProcessDispatcher::~BrokerProcessDispatcher() { 103 BrokerProcessDispatcher::~BrokerProcessDispatcher() {
102 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()"; 104 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()";
103 // Don't free the process right away. This timer allows the child process 105 // 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 106 // 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 107 // 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 108 // source and destination page of a navigation. We don't want to tear down
107 // and re-start processes each time in these cases. 109 // and re-start processes each time in these cases.
108 process_ref_.ReleaseWithDelay( 110 process_ref_.ReleaseWithDelay(
109 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds)); 111 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds));
110 } 112 }
111 113
112 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) { 114 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) {
113 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg) 115 if (BrokerSideDispatcher::OnMessageReceived(msg))
114 IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnGetSitesWithData) 116 return true;
115 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnClearSiteData) 117
116 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses, 118 if (peer_is_browser_) {
jam 2016/06/15 17:50:38 nit: might be easier with indentation if you early
yzshen1 2016/06/15 18:17:43 Done.
117 OnDeauthorizeContentLicenses) 119 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg)
118 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings, OnGetPermissionSettings) 120 IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnGetSitesWithData)
119 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission, OnSetDefaultPermission) 121 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnClearSiteData)
120 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnSetSitePermission) 122 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses,
121 IPC_MESSAGE_UNHANDLED(return BrokerSideDispatcher::OnMessageReceived(msg)) 123 OnDeauthorizeContentLicenses)
122 IPC_END_MESSAGE_MAP() 124 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings,
123 return true; 125 OnGetPermissionSettings)
126 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission, OnSetDefaultPermission)
127 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnSetSitePermission)
128 IPC_MESSAGE_UNHANDLED(return false)
129 IPC_END_MESSAGE_MAP()
130 }
131
132 return false;
124 } 133 }
125 134
126 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted( 135 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted(
127 uint32_t request_id, 136 uint32_t request_id,
128 bool success, 137 bool success,
129 PP_Flash_BrowserOperations_Permission default_permission, 138 PP_Flash_BrowserOperations_Permission default_permission,
130 const ppapi::FlashSiteSettings& sites) { 139 const ppapi::FlashSiteSettings& sites) {
131 Send(new PpapiHostMsg_GetPermissionSettingsResult( 140 Send(new PpapiHostMsg_GetPermissionSettingsResult(
132 request_id, success, default_permission, sites)); 141 request_id, success, default_permission, sites));
133 } 142 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 data_str.c_str(), setting_type, 331 data_str.c_str(), setting_type,
323 static_cast<uint32_t>(sites.size()), site_array.get()); 332 static_cast<uint32_t>(sites.size()), site_array.get());
324 333
325 return PP_ToBool(result); 334 return PP_ToBool(result);
326 } 335 }
327 336
328 return false; 337 return false;
329 } 338 }
330 339
331 } // namespace content 340 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698