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

Side by Side Diff: src/trusted/plugin/ppapi/scriptable_handle_ppapi.cc

Issue 7292002: Remove plugin connection to PPAPI scriptable objects (var deprecated). Also (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 5 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) 2011 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2011 The Native Client 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 <assert.h> 5 #include <assert.h>
6 #include <sstream> 6 #include <sstream>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "native_client/src/include/nacl_macros.h" 10 #include "native_client/src/include/nacl_macros.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const char* caller) { 64 const char* caller) {
65 uintptr_t id = handle()->browser_interface()->StringToIdentifier(call_name); 65 uintptr_t id = handle()->browser_interface()->StringToIdentifier(call_name);
66 PLUGIN_PRINTF(("ScriptableHandlePpapi::%s (id=%"NACL_PRIxPTR")\n", 66 PLUGIN_PRINTF(("ScriptableHandlePpapi::%s (id=%"NACL_PRIxPTR")\n",
67 caller, id)); 67 caller, id));
68 return handle()->HasMethod(id, call_type); 68 return handle()->HasMethod(id, call_type);
69 } 69 }
70 70
71 71
72 bool ScriptableHandlePpapi::HasProperty(const pp::Var& name, 72 bool ScriptableHandlePpapi::HasProperty(const pp::Var& name,
73 pp::Var* exception) { 73 pp::Var* exception) {
74 UNREFERENCED_PARAMETER(exception);
74 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasProperty (this=%p, name=%s)\n", 75 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasProperty (this=%p, name=%s)\n",
75 static_cast<void*>(this), name.DebugString().c_str())); 76 static_cast<void*>(this), name.DebugString().c_str()));
76 if (!name.is_string() && !name.is_int()) 77 if (!name.is_string() && !name.is_int())
77 return false; 78 return false;
78 bool has_property = false; 79 bool has_property =
79 if (scriptable_proxy_.is_undefined()) { 80 HasCallType(PROPERTY_GET, NameAsString(name), "HasProperty");
80 has_property = HasCallType(PROPERTY_GET, NameAsString(name), "HasProperty");
81 } else {
82 has_property = scriptable_proxy_.HasProperty(name, exception);
83 }
84 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasProperty (has_property=%d)\n", 81 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasProperty (has_property=%d)\n",
85 has_property)); 82 has_property));
86 return has_property; 83 return has_property;
87 } 84 }
88 85
89 86
90 bool ScriptableHandlePpapi::HasMethod(const pp::Var& name, pp::Var* exception) { 87 bool ScriptableHandlePpapi::HasMethod(const pp::Var& name, pp::Var* exception) {
88 UNREFERENCED_PARAMETER(exception);
91 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasMethod (this=%p, name='%s')\n", 89 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasMethod (this=%p, name='%s')\n",
92 static_cast<void*>(this), name.DebugString().c_str())); 90 static_cast<void*>(this), name.DebugString().c_str()));
93 if (!name.is_string()) 91 if (!name.is_string())
94 return false; 92 return false;
95 bool has_method = false; 93 bool has_method =
96 if (scriptable_proxy_.is_undefined()) { 94 HasCallType(METHOD_CALL, name.AsString(), "HasMethod");
97 has_method = HasCallType(METHOD_CALL, name.AsString(), "HasMethod");
98 } else {
99 has_method = scriptable_proxy_.HasMethod(name, exception);
100 }
101 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasMethod (has_method=%d)\n", 95 PLUGIN_PRINTF(("ScriptableHandlePpapi::HasMethod (has_method=%d)\n",
102 has_method)); 96 has_method));
103 return has_method; 97 return has_method;
104 } 98 }
105 99
106 100
107 pp::Var ScriptableHandlePpapi::Invoke(CallType call_type, 101 pp::Var ScriptableHandlePpapi::Invoke(CallType call_type,
108 nacl::string call_name, 102 nacl::string call_name,
109 const char* caller, 103 const char* caller,
110 const std::vector<pp::Var>& args, 104 const std::vector<pp::Var>& args,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 190 }
197 if (call_type == PROPERTY_GET) assert(output_length == 1); 191 if (call_type == PROPERTY_GET) assert(output_length == 1);
198 return retvar; 192 return retvar;
199 } 193 }
200 194
201 195
202 pp::Var ScriptableHandlePpapi::GetProperty(const pp::Var& name, 196 pp::Var ScriptableHandlePpapi::GetProperty(const pp::Var& name,
203 pp::Var* exception) { 197 pp::Var* exception) {
204 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetProperty (name=%s)\n", 198 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetProperty (name=%s)\n",
205 name.DebugString().c_str())); 199 name.DebugString().c_str()));
206 pp::Var property; 200 pp::Var property =
207 if (scriptable_proxy_.is_undefined()) { 201 Invoke(PROPERTY_GET, NameAsString(name), "GetProperty",
208 property = Invoke(PROPERTY_GET, NameAsString(name), "GetProperty", 202 std::vector<pp::Var>(), exception);
209 std::vector<pp::Var>(), exception);
210 } else {
211 property = scriptable_proxy_.GetProperty(name, exception);
212 }
213 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetProperty (property=%s)\n", 203 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetProperty (property=%s)\n",
214 property.DebugString().c_str())); 204 property.DebugString().c_str()));
215 return property; 205 return property;
216 } 206 }
217 207
218 208
219 void ScriptableHandlePpapi::SetProperty(const pp::Var& name, 209 void ScriptableHandlePpapi::SetProperty(const pp::Var& name,
220 const pp::Var& value, 210 const pp::Var& value,
221 pp::Var* exception) { 211 pp::Var* exception) {
222 PLUGIN_PRINTF(("ScriptableHandlePpapi::SetProperty (name=%s, value=%s)\n", 212 PLUGIN_PRINTF(("ScriptableHandlePpapi::SetProperty (name=%s, value=%s)\n",
223 name.DebugString().c_str(), value.DebugString().c_str())); 213 name.DebugString().c_str(), value.DebugString().c_str()));
224 if (scriptable_proxy_.is_undefined()) { 214 std::vector<pp::Var> args;
225 std::vector<pp::Var> args; 215 args.push_back(pp::Var(pp::Var::DontManage(), value.pp_var()));
226 args.push_back(pp::Var(pp::Var::DontManage(), value.pp_var())); 216 Invoke(PROPERTY_SET, NameAsString(name), "SetProperty", args, exception);
227 Invoke(PROPERTY_SET, NameAsString(name), "SetProperty", args, exception);
228 } else {
229 scriptable_proxy_.SetProperty(name, value, exception);
230 }
231
232 std::string exception_string("NULL"); 217 std::string exception_string("NULL");
233 if (exception != NULL) { 218 if (exception != NULL) {
234 exception_string = exception->DebugString(); 219 exception_string = exception->DebugString();
235 } 220 }
236 PLUGIN_PRINTF(("ScriptableHandlePpapi::SetProperty (exception=%s)\n", 221 PLUGIN_PRINTF(("ScriptableHandlePpapi::SetProperty (exception=%s)\n",
237 exception_string.c_str())); 222 exception_string.c_str()));
238 } 223 }
239 224
240 225
241 void ScriptableHandlePpapi::RemoveProperty(const pp::Var& name, 226 void ScriptableHandlePpapi::RemoveProperty(const pp::Var& name,
242 pp::Var* exception) { 227 pp::Var* exception) {
243 PLUGIN_PRINTF(("ScriptableHandlePpapi::RemoveProperty (name=%s)\n", 228 PLUGIN_PRINTF(("ScriptableHandlePpapi::RemoveProperty (name=%s)\n",
244 name.DebugString().c_str())); 229 name.DebugString().c_str()));
245 Error(NameAsString(name), "RemoveProperty", 230 Error(NameAsString(name), "RemoveProperty",
246 "property removal is not supported", exception); 231 "property removal is not supported", exception);
247 } 232 }
248 233
249 // TODO(polina): should methods also be added? 234 // TODO(polina): should methods also be added?
250 // This is currently never called and the exact semantics is not clear. 235 // This is currently never called and the exact semantics is not clear.
251 // http://code.google.com/p/chromium/issues/detail?id=51089 236 // http://code.google.com/p/chromium/issues/detail?id=51089
252 void ScriptableHandlePpapi::GetAllPropertyNames( 237 void ScriptableHandlePpapi::GetAllPropertyNames(
253 std::vector<pp::Var>* properties, 238 std::vector<pp::Var>* properties,
254 pp::Var* exception) { 239 pp::Var* exception) {
240 UNREFERENCED_PARAMETER(exception);
255 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetAllPropertyNames ()\n")); 241 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetAllPropertyNames ()\n"));
256 if (scriptable_proxy_.is_undefined()) { 242 std::vector<uintptr_t>* ids = handle()->GetPropertyIdentifiers();
257 std::vector<uintptr_t>* ids = handle()->GetPropertyIdentifiers(); 243 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetAllPropertyNames "
258 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetAllPropertyNames " 244 "(ids=%"NACL_PRIuS")\n", ids->size()));
259 "(ids=%"NACL_PRIuS")\n", ids->size())); 245 for (size_t i = 0; i < ids->size(); ++i) {
260 for (size_t i = 0; i < ids->size(); ++i) { 246 nacl::string name =
261 nacl::string name = 247 handle()->browser_interface()->IdentifierToString(ids->at(i));
262 handle()->browser_interface()->IdentifierToString(ids->at(i)); 248 properties->push_back(pp::Var(name));
263 properties->push_back(pp::Var(name));
264 }
265 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetAllPropertyNames "
266 "(properties=%"NACL_PRIuS")\n", properties->size()));
267 } else {
268 scriptable_proxy_.GetAllPropertyNames(properties, exception);
269 } 249 }
250 PLUGIN_PRINTF(("ScriptableHandlePpapi::GetAllPropertyNames "
251 "(properties=%"NACL_PRIuS")\n", properties->size()));
270 } 252 }
271 253
272 254
273 pp::Var ScriptableHandlePpapi::Call(const pp::Var& name, 255 pp::Var ScriptableHandlePpapi::Call(const pp::Var& name,
274 const std::vector<pp::Var>& args, 256 const std::vector<pp::Var>& args,
275 pp::Var* exception) { 257 pp::Var* exception) {
276 PLUGIN_PRINTF(("ScriptableHandlePpapi::Call (name=%s, %"NACL_PRIuS 258 PLUGIN_PRINTF(("ScriptableHandlePpapi::Call (name=%s, %"NACL_PRIuS
277 " args)\n", name.DebugString().c_str(), args.size())); 259 " args)\n", name.DebugString().c_str(), args.size()));
278 if (name.is_undefined()) // invoke default 260 if (name.is_undefined()) // invoke default
279 return pp::Var(); 261 return pp::Var();
280 assert(name.is_string()); 262 assert(name.is_string());
281 pp::Var return_var; 263 pp::Var return_var =
282 if (scriptable_proxy_.is_undefined()) { 264 Invoke(METHOD_CALL, name.AsString(), "Call", args, exception);
283 return_var = Invoke(METHOD_CALL, name.AsString(), "Call", args, exception);
284 } else {
285 uint32_t argc = static_cast<uint32_t>(args.size());
286 pp::Var* args_array = NULL;
287 // Check that array has at least 1 element. Visual Studio's STL will
288 // throw an exception if we access args[0] in DEBUG configurations.
289 if (argc > 0) {
290 // STL vectors are guaranteed to use continguous memory, so we can use
291 // some pointer magic to convert the vector into an array.
292 args_array = const_cast<pp::Var*>(&args[0]);
293 }
294 return_var = scriptable_proxy_.Call(name, argc, args_array, exception);
295 }
296 PLUGIN_PRINTF(("ScriptableHandlePpapi::Call (return=%s)\n", 265 PLUGIN_PRINTF(("ScriptableHandlePpapi::Call (return=%s)\n",
297 return_var.DebugString().c_str())); 266 return_var.DebugString().c_str()));
298 return return_var; 267 return return_var;
299 } 268 }
300 269
301 270
302 pp::Var ScriptableHandlePpapi::Construct(const std::vector<pp::Var>& args, 271 pp::Var ScriptableHandlePpapi::Construct(const std::vector<pp::Var>& args,
303 pp::Var* exception) { 272 pp::Var* exception) {
304 PLUGIN_PRINTF(("ScriptableHandlePpapi::Construct (%"NACL_PRIuS 273 PLUGIN_PRINTF(("ScriptableHandlePpapi::Construct (%"NACL_PRIuS
305 " args)\n", args.size())); 274 " args)\n", args.size()));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 static_cast<void*>(this), static_cast<void*>(handle()))); 341 static_cast<void*>(this), static_cast<void*>(handle())));
373 handle()->Delete(); 342 handle()->Delete();
374 set_handle(NULL); 343 set_handle(NULL);
375 } 344 }
376 PLUGIN_PRINTF(("ScriptableHandlePpapi::~ScriptableHandlePpapi " 345 PLUGIN_PRINTF(("ScriptableHandlePpapi::~ScriptableHandlePpapi "
377 "(this=%p, return)\n", 346 "(this=%p, return)\n",
378 static_cast<void*>(this))); 347 static_cast<void*>(this)));
379 } 348 }
380 349
381 } // namespace plugin 350 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698