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

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

Issue 10825018: Add GetSitesWithData and FreeSiteList methods to PPP_Flash_BrowserOperations interface and hook the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 context->request_id, PP_ToBool(success), default_permission, site_vector); 70 context->request_id, PP_ToBool(success), default_permission, site_vector);
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 BrokerProcessDispatcher::BrokerProcessDispatcher( 75 BrokerProcessDispatcher::BrokerProcessDispatcher(
76 PP_GetInterface_Func get_plugin_interface, 76 PP_GetInterface_Func get_plugin_interface,
77 PP_ConnectInstance_Func connect_instance) 77 PP_ConnectInstance_Func connect_instance)
78 : ppapi::proxy::BrokerSideDispatcher(connect_instance), 78 : ppapi::proxy::BrokerSideDispatcher(connect_instance),
79 get_plugin_interface_(get_plugin_interface), 79 get_plugin_interface_(get_plugin_interface),
80 flash_browser_operations_1_3_(NULL),
80 flash_browser_operations_1_2_(NULL), 81 flash_browser_operations_1_2_(NULL),
81 flash_browser_operations_1_0_(NULL) { 82 flash_browser_operations_1_0_(NULL) {
82 ChildProcess::current()->AddRefProcess(); 83 ChildProcess::current()->AddRefProcess();
83 84
84 if (get_plugin_interface) { 85 if (get_plugin_interface) {
85 flash_browser_operations_1_0_ = 86 flash_browser_operations_1_0_ =
86 static_cast<const PPP_Flash_BrowserOperations_1_0*>( 87 static_cast<const PPP_Flash_BrowserOperations_1_0*>(
87 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0)); 88 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_0));
88 89
89 flash_browser_operations_1_2_ = 90 flash_browser_operations_1_2_ =
90 static_cast<const PPP_Flash_BrowserOperations_1_2*>( 91 static_cast<const PPP_Flash_BrowserOperations_1_2*>(
91 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2)); 92 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_2));
93
94 flash_browser_operations_1_3_ =
95 static_cast<const PPP_Flash_BrowserOperations_1_3*>(
96 get_plugin_interface_(PPP_FLASH_BROWSEROPERATIONS_INTERFACE_1_3));
92 } 97 }
93 } 98 }
94 99
95 BrokerProcessDispatcher::~BrokerProcessDispatcher() { 100 BrokerProcessDispatcher::~BrokerProcessDispatcher() {
96 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()"; 101 DVLOG(1) << "BrokerProcessDispatcher::~BrokerProcessDispatcher()";
97 // Don't free the process right away. This timer allows the child process 102 // Don't free the process right away. This timer allows the child process
98 // to be re-used if the user rapidly goes to a new page that requires this 103 // to be re-used if the user rapidly goes to a new page that requires this
99 // plugin. This is the case for common plugins where they may be used on a 104 // plugin. This is the case for common plugins where they may be used on a
100 // source and destination page of a navigation. We don't want to tear down 105 // source and destination page of a navigation. We don't want to tear down
101 // and re-start processes each time in these cases. 106 // and re-start processes each time in these cases.
102 MessageLoop::current()->PostDelayedTask( 107 MessageLoop::current()->PostDelayedTask(
103 FROM_HERE, 108 FROM_HERE,
104 base::Bind(&ChildProcess::ReleaseProcess, 109 base::Bind(&ChildProcess::ReleaseProcess,
105 base::Unretained(ChildProcess::current())), 110 base::Unretained(ChildProcess::current())),
106 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds)); 111 base::TimeDelta::FromSeconds(kBrokerReleaseTimeSeconds));
107 } 112 }
108 113
109 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) { 114 bool BrokerProcessDispatcher::OnMessageReceived(const IPC::Message& msg) {
110 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg) 115 IPC_BEGIN_MESSAGE_MAP(BrokerProcessDispatcher, msg)
116 IPC_MESSAGE_HANDLER(PpapiMsg_GetSitesWithData, OnMsgGetSitesWithData)
111 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnMsgClearSiteData) 117 IPC_MESSAGE_HANDLER(PpapiMsg_ClearSiteData, OnMsgClearSiteData)
112 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses, 118 IPC_MESSAGE_HANDLER(PpapiMsg_DeauthorizeContentLicenses,
113 OnMsgDeauthorizeContentLicenses) 119 OnMsgDeauthorizeContentLicenses)
114 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings, 120 IPC_MESSAGE_HANDLER(PpapiMsg_GetPermissionSettings,
115 OnMsgGetPermissionSettings) 121 OnMsgGetPermissionSettings)
116 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission, 122 IPC_MESSAGE_HANDLER(PpapiMsg_SetDefaultPermission,
117 OnMsgSetDefaultPermission) 123 OnMsgSetDefaultPermission)
118 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnMsgSetSitePermission) 124 IPC_MESSAGE_HANDLER(PpapiMsg_SetSitePermission, OnMsgSetSitePermission)
119 IPC_MESSAGE_UNHANDLED(return BrokerSideDispatcher::OnMessageReceived(msg)) 125 IPC_MESSAGE_UNHANDLED(return BrokerSideDispatcher::OnMessageReceived(msg))
120 IPC_END_MESSAGE_MAP() 126 IPC_END_MESSAGE_MAP()
121 return true; 127 return true;
122 } 128 }
123 129
124 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted( 130 void BrokerProcessDispatcher::OnGetPermissionSettingsCompleted(
125 uint32 request_id, 131 uint32 request_id,
126 bool success, 132 bool success,
127 PP_Flash_BrowserOperations_Permission default_permission, 133 PP_Flash_BrowserOperations_Permission default_permission,
128 const ppapi::FlashSiteSettings& sites) { 134 const ppapi::FlashSiteSettings& sites) {
129 Send(new PpapiHostMsg_GetPermissionSettingsResult( 135 Send(new PpapiHostMsg_GetPermissionSettingsResult(
130 request_id, success, default_permission, sites)); 136 request_id, success, default_permission, sites));
131 } 137 }
132 138
139 void BrokerProcessDispatcher::OnMsgGetSitesWithData(
140 uint32 request_id,
141 const FilePath& plugin_data_path) {
142 std::vector<std::string> sites;
143 GetSitesWithData(plugin_data_path, &sites);
144 Send(new PpapiHostMsg_GetSitesWithDataResult(request_id, sites));
145 }
146
133 void BrokerProcessDispatcher::OnMsgClearSiteData( 147 void BrokerProcessDispatcher::OnMsgClearSiteData(
148 uint32 request_id,
134 const FilePath& plugin_data_path, 149 const FilePath& plugin_data_path,
135 const std::string& site, 150 const std::string& site,
136 uint64 flags, 151 uint64 flags,
137 uint64 max_age) { 152 uint64 max_age) {
138 Send(new PpapiHostMsg_ClearSiteDataResult( 153 Send(new PpapiHostMsg_ClearSiteDataResult(
139 ClearSiteData(plugin_data_path, site, flags, max_age))); 154 request_id, ClearSiteData(plugin_data_path, site, flags, max_age)));
140 } 155 }
141 156
142 void BrokerProcessDispatcher::OnMsgDeauthorizeContentLicenses( 157 void BrokerProcessDispatcher::OnMsgDeauthorizeContentLicenses(
143 uint32 request_id, 158 uint32 request_id,
144 const FilePath& plugin_data_path) { 159 const FilePath& plugin_data_path) {
145 Send(new PpapiHostMsg_DeauthorizeContentLicensesResult( 160 Send(new PpapiHostMsg_DeauthorizeContentLicensesResult(
146 request_id, DeauthorizeContentLicenses(plugin_data_path))); 161 request_id, DeauthorizeContentLicenses(plugin_data_path)));
147 } 162 }
148 163
149 void BrokerProcessDispatcher::OnMsgGetPermissionSettings( 164 void BrokerProcessDispatcher::OnMsgGetPermissionSettings(
(...skipping 29 matching lines...) Expand all
179 194
180 void BrokerProcessDispatcher::OnMsgSetSitePermission( 195 void BrokerProcessDispatcher::OnMsgSetSitePermission(
181 uint32 request_id, 196 uint32 request_id,
182 const FilePath& plugin_data_path, 197 const FilePath& plugin_data_path,
183 PP_Flash_BrowserOperations_SettingType setting_type, 198 PP_Flash_BrowserOperations_SettingType setting_type,
184 const ppapi::FlashSiteSettings& sites) { 199 const ppapi::FlashSiteSettings& sites) {
185 Send(new PpapiHostMsg_SetSitePermissionResult( 200 Send(new PpapiHostMsg_SetSitePermissionResult(
186 request_id, SetSitePermission(plugin_data_path, setting_type, sites))); 201 request_id, SetSitePermission(plugin_data_path, setting_type, sites)));
187 } 202 }
188 203
204 void BrokerProcessDispatcher::GetSitesWithData(
205 const FilePath& plugin_data_path,
206 std::vector<std::string>* site_vector) {
207 std::string data_str = ConvertPluginDataPath(plugin_data_path);
208 if (!flash_browser_operations_1_3_)
209 return;
210
211 char** sites = NULL;
212 flash_browser_operations_1_3_->GetSitesWithData(data_str.c_str(), &sites);
213 if (!sites)
214 return;
215
216 for (size_t i = 0; sites[i]; ++i)
217 site_vector->push_back(sites[i]);
218
219 flash_browser_operations_1_3_->FreeSiteList(sites);
220 }
221
189 bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path, 222 bool BrokerProcessDispatcher::ClearSiteData(const FilePath& plugin_data_path,
190 const std::string& site, 223 const std::string& site,
191 uint64 flags, 224 uint64 flags,
192 uint64 max_age) { 225 uint64 max_age) {
193 std::string data_str = ConvertPluginDataPath(plugin_data_path); 226 std::string data_str = ConvertPluginDataPath(plugin_data_path);
194 if (flash_browser_operations_1_2_) { 227 if (flash_browser_operations_1_2_) {
yzshen1 2012/07/25 23:56:24 Once we have 1.3 interface, we should try to use i
Bernhard Bauer 2012/07/26 00:18:53 Done.
195 flash_browser_operations_1_2_->ClearSiteData( 228 flash_browser_operations_1_2_->ClearSiteData(
196 data_str.c_str(), site.empty() ? NULL : site.c_str(), flags, max_age); 229 data_str.c_str(), site.empty() ? NULL : site.c_str(), flags, max_age);
197 return true; 230 return true;
198 } 231 }
199 232
200 // TODO(viettrungluu): Remove this (and the 1.0 interface) sometime after M21 233 // TODO(viettrungluu): Remove this (and the 1.0 interface) sometime after M21
201 // goes to Stable. 234 // goes to Stable.
202 if (flash_browser_operations_1_0_) { 235 if (flash_browser_operations_1_0_) {
203 flash_browser_operations_1_0_->ClearSiteData( 236 flash_browser_operations_1_0_->ClearSiteData(
204 data_str.c_str(), site.empty() ? NULL : site.c_str(), flags, max_age); 237 data_str.c_str(), site.empty() ? NULL : site.c_str(), flags, max_age);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 for (size_t i = 0; i < sites.size(); ++i) { 282 for (size_t i = 0; i < sites.size(); ++i) {
250 site_array[i].site = sites[i].site.c_str(); 283 site_array[i].site = sites[i].site.c_str();
251 site_array[i].permission = sites[i].permission; 284 site_array[i].permission = sites[i].permission;
252 } 285 }
253 286
254 PP_Bool result = flash_browser_operations_1_2_->SetSitePermission( 287 PP_Bool result = flash_browser_operations_1_2_->SetSitePermission(
255 data_str.c_str(), setting_type, sites.size(), site_array.get()); 288 data_str.c_str(), setting_type, sites.size(), site_array.get());
256 289
257 return PP_ToBool(result); 290 return PP_ToBool(result);
258 } 291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698