| 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 "webkit/plugins/ppapi/plugin_object.h" | 5 #include "webkit/plugins/ppapi/plugin_object.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "third_party/npapi/bindings/npapi.h" | 12 #include "third_party/npapi/bindings/npapi.h" |
| 13 #include "third_party/npapi/bindings/npruntime.h" | 13 #include "third_party/npapi/bindings/npruntime.h" |
| 14 #include "ppapi/c/dev/ppb_var_deprecated.h" | 14 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 15 #include "ppapi/c/dev/ppp_class_deprecated.h" | 15 #include "ppapi/c/dev/ppp_class_deprecated.h" |
| 16 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
| 17 #include "ppapi/c/pp_var.h" | 17 #include "ppapi/c/pp_var.h" |
| 18 #include "ppapi/shared_impl/ppapi_globals.h" |
| 18 #include "ppapi/shared_impl/var.h" | 19 #include "ppapi/shared_impl/var.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 20 #include "webkit/plugins/ppapi/npapi_glue.h" | 21 #include "webkit/plugins/ppapi/npapi_glue.h" |
| 21 #include "webkit/plugins/ppapi/plugin_module.h" | 22 #include "webkit/plugins/ppapi/plugin_module.h" |
| 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 23 #include "webkit/plugins/ppapi/resource_tracker.h" | 24 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 24 #include "webkit/plugins/ppapi/string.h" | 25 #include "webkit/plugins/ppapi/string.h" |
| 25 | 26 |
| 27 using ppapi::PpapiGlobals; |
| 26 using ppapi::StringVar; | 28 using ppapi::StringVar; |
| 27 using ppapi::Var; | 29 using ppapi::Var; |
| 28 using WebKit::WebBindings; | 30 using WebKit::WebBindings; |
| 29 | 31 |
| 30 namespace webkit { | 32 namespace webkit { |
| 31 namespace ppapi { | 33 namespace ppapi { |
| 32 | 34 |
| 33 namespace { | 35 namespace { |
| 34 | 36 |
| 35 const char kInvalidValueException[] = "Error: Invalid value"; | 37 const char kInvalidValueException[] = "Error: Invalid value"; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 NPObjectAccessorWithIdentifier accessor(object, property_name, true); | 145 NPObjectAccessorWithIdentifier accessor(object, property_name, true); |
| 144 if (!accessor.is_valid()) | 146 if (!accessor.is_valid()) |
| 145 return false; | 147 return false; |
| 146 | 148 |
| 147 PPResultAndExceptionToNPResult result_converter( | 149 PPResultAndExceptionToNPResult result_converter( |
| 148 accessor.object()->GetNPObject(), NULL); | 150 accessor.object()->GetNPObject(), NULL); |
| 149 PP_Var value_var = NPVariantToPPVar(accessor.object()->instance(), value); | 151 PP_Var value_var = NPVariantToPPVar(accessor.object()->instance(), value); |
| 150 accessor.object()->ppp_class()->SetProperty( | 152 accessor.object()->ppp_class()->SetProperty( |
| 151 accessor.object()->ppp_class_data(), accessor.identifier(), value_var, | 153 accessor.object()->ppp_class_data(), accessor.identifier(), value_var, |
| 152 result_converter.exception()); | 154 result_converter.exception()); |
| 153 ResourceTracker::Get()->GetVarTracker()->ReleaseVar(value_var); | 155 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(value_var); |
| 154 return result_converter.CheckExceptionForNoResult(); | 156 return result_converter.CheckExceptionForNoResult(); |
| 155 } | 157 } |
| 156 | 158 |
| 157 bool WrapperClass_RemoveProperty(NPObject* object, NPIdentifier property_name) { | 159 bool WrapperClass_RemoveProperty(NPObject* object, NPIdentifier property_name) { |
| 158 NPObjectAccessorWithIdentifier accessor(object, property_name, true); | 160 NPObjectAccessorWithIdentifier accessor(object, property_name, true); |
| 159 if (!accessor.is_valid()) | 161 if (!accessor.is_valid()) |
| 160 return false; | 162 return false; |
| 161 | 163 |
| 162 PPResultAndExceptionToNPResult result_converter( | 164 PPResultAndExceptionToNPResult result_converter( |
| 163 accessor.object()->GetNPObject(), NULL); | 165 accessor.object()->GetNPObject(), NULL); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 210 } |
| 209 } | 211 } |
| 210 } | 212 } |
| 211 | 213 |
| 212 // This will actually throw the exception, either from GetAllPropertyNames, | 214 // This will actually throw the exception, either from GetAllPropertyNames, |
| 213 // or if anything was set during the conversion process. | 215 // or if anything was set during the conversion process. |
| 214 result_converter.CheckExceptionForNoResult(); | 216 result_converter.CheckExceptionForNoResult(); |
| 215 | 217 |
| 216 // Release the PP_Var that the plugin allocated. On success, they will all | 218 // Release the PP_Var that the plugin allocated. On success, they will all |
| 217 // be converted to NPVariants, and on failure, we want them to just go away. | 219 // be converted to NPVariants, and on failure, we want them to just go away. |
| 218 ::ppapi::VarTracker* var_tracker = ResourceTracker::Get()->GetVarTracker(); | 220 ::ppapi::VarTracker* var_tracker = PpapiGlobals::Get()->GetVarTracker(); |
| 219 for (uint32_t i = 0; i < property_count; ++i) | 221 for (uint32_t i = 0; i < property_count; ++i) |
| 220 var_tracker->ReleaseVar(properties[i]); | 222 var_tracker->ReleaseVar(properties[i]); |
| 221 free(properties); | 223 free(properties); |
| 222 return result_converter.success(); | 224 return result_converter.success(); |
| 223 } | 225 } |
| 224 | 226 |
| 225 bool WrapperClass_Construct(NPObject* object, const NPVariant* argv, | 227 bool WrapperClass_Construct(NPObject* object, const NPVariant* argv, |
| 226 uint32_t argc, NPVariant* result) { | 228 uint32_t argc, NPVariant* result) { |
| 227 PluginObject* obj = PluginObject::FromNPObject(object); | 229 PluginObject* obj = PluginObject::FromNPObject(object); |
| 228 if (!obj) | 230 if (!obj) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 // static | 350 // static |
| 349 NPObject* PluginObject::AllocateObjectWrapper() { | 351 NPObject* PluginObject::AllocateObjectWrapper() { |
| 350 NPObjectWrapper* wrapper = new NPObjectWrapper; | 352 NPObjectWrapper* wrapper = new NPObjectWrapper; |
| 351 memset(wrapper, 0, sizeof(NPObjectWrapper)); | 353 memset(wrapper, 0, sizeof(NPObjectWrapper)); |
| 352 return wrapper; | 354 return wrapper; |
| 353 } | 355 } |
| 354 | 356 |
| 355 } // namespace ppapi | 357 } // namespace ppapi |
| 356 } // namespace webkit | 358 } // namespace webkit |
| 357 | 359 |
| OLD | NEW |