OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/pepper/plugin_object.h" | 5 #include "content/renderer/pepper/plugin_object.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 gin::CreateHandle(instance->GetIsolate(), | 87 gin::CreateHandle(instance->GetIsolate(), |
88 new PluginObject(instance, ppp_class, ppp_class_data)); | 88 new PluginObject(instance, ppp_class, ppp_class_data)); |
89 ScopedPPVar result = try_catch.FromV8(object.ToV8()); | 89 ScopedPPVar result = try_catch.FromV8(object.ToV8()); |
90 DCHECK(!try_catch.HasException()); | 90 DCHECK(!try_catch.HasException()); |
91 return result.Release(); | 91 return result.Release(); |
92 } | 92 } |
93 | 93 |
94 v8::Local<v8::Value> PluginObject::GetNamedProperty( | 94 v8::Local<v8::Value> PluginObject::GetNamedProperty( |
95 v8::Isolate* isolate, | 95 v8::Isolate* isolate, |
96 const std::string& identifier) { | 96 const std::string& identifier) { |
| 97 if (!instance_) { |
| 98 std::string error = "Property " + identifier + " does not exist."; |
| 99 isolate->ThrowException( |
| 100 v8::Exception::ReferenceError(gin::StringToV8(isolate, error))); |
| 101 return v8::Local<v8::Value>(); |
| 102 } |
97 ScopedPPVar identifier_var(ScopedPPVar::PassRef(), | 103 ScopedPPVar identifier_var(ScopedPPVar::PassRef(), |
98 StringVar::StringToPPVar(identifier)); | 104 StringVar::StringToPPVar(identifier)); |
99 return GetPropertyOrMethod(instance_->GetIsolate(), identifier_var.get()); | 105 return GetPropertyOrMethod(instance_->GetIsolate(), identifier_var.get()); |
100 } | 106 } |
101 | 107 |
102 bool PluginObject::SetNamedProperty(v8::Isolate* isolate, | 108 bool PluginObject::SetNamedProperty(v8::Isolate* isolate, |
103 const std::string& identifier, | 109 const std::string& identifier, |
104 v8::Local<v8::Value> value) { | 110 v8::Local<v8::Value> value) { |
105 if (!instance_) | 111 if (!instance_) { |
| 112 std::string error = "Property " + identifier + " does not exist."; |
| 113 isolate->ThrowException( |
| 114 v8::Exception::ReferenceError(gin::StringToV8(isolate, error))); |
106 return false; | 115 return false; |
| 116 } |
107 ScopedPPVar identifier_var(ScopedPPVar::PassRef(), | 117 ScopedPPVar identifier_var(ScopedPPVar::PassRef(), |
108 StringVar::StringToPPVar(identifier)); | 118 StringVar::StringToPPVar(identifier)); |
109 V8VarConverter var_converter(instance_->pp_instance(), | 119 V8VarConverter var_converter(instance_->pp_instance(), |
110 V8VarConverter::kAllowObjectVars); | 120 V8VarConverter::kAllowObjectVars); |
111 PepperTryCatchV8 try_catch(instance_, &var_converter, isolate); | 121 PepperTryCatchV8 try_catch(instance_, &var_converter, isolate); |
112 | 122 |
113 bool has_property = | 123 bool has_property = |
114 ppp_class_->HasProperty(ppp_class_data_, identifier_var.get(), | 124 ppp_class_->HasProperty(ppp_class_data_, identifier_var.get(), |
115 try_catch.exception()); | 125 try_catch.exception()); |
116 if (try_catch.ThrowException()) | 126 if (try_catch.ThrowException()) |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 return function_template; | 293 return function_template; |
284 function_template = | 294 function_template = |
285 gin::CreateFunctionTemplate( | 295 gin::CreateFunctionTemplate( |
286 isolate, base::Bind(&PluginObject::Call, weak_factory_.GetWeakPtr(), | 296 isolate, base::Bind(&PluginObject::Call, weak_factory_.GetWeakPtr(), |
287 name)); | 297 name)); |
288 template_cache_.Set(name, function_template); | 298 template_cache_.Set(name, function_template); |
289 return function_template; | 299 return function_template; |
290 } | 300 } |
291 | 301 |
292 } // namespace content | 302 } // namespace content |
OLD | NEW |