| 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/npapi_glue.h" | 5 #include "content/renderer/pepper/npapi_glue.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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "content/renderer/pepper/host_array_buffer_var.h" | 10 #include "content/renderer/pepper/host_array_buffer_var.h" |
| 11 #include "content/renderer/pepper/host_globals.h" | 11 #include "content/renderer/pepper/host_globals.h" |
| 12 #include "content/renderer/pepper/host_var_tracker.h" | 12 #include "content/renderer/pepper/host_var_tracker.h" |
| 13 #include "content/renderer/pepper/npobject_var.h" | 13 #include "content/renderer/pepper/npobject_var.h" |
| 14 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 14 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 15 #include "content/renderer/pepper/plugin_module.h" | 15 #include "content/renderer/pepper/plugin_module.h" |
| 16 #include "content/renderer/pepper/plugin_object.h" | 16 #include "content/renderer/pepper/plugin_object.h" |
| 17 #include "ppapi/c/pp_var.h" | 17 #include "ppapi/c/pp_var.h" |
| 18 #include "third_party/npapi/bindings/npapi.h" | 18 #include "third_party/npapi/bindings/npapi.h" |
| 19 #include "third_party/npapi/bindings/npruntime.h" | 19 #include "third_party/npapi/bindings/npruntime.h" |
| 20 #include "third_party/WebKit/public/web/WebBindings.h" | 20 #include "third_party/WebKit/public/web/WebBindings.h" |
| 21 #include "third_party/WebKit/public/web/WebDocument.h" | 21 #include "third_party/WebKit/public/web/WebDocument.h" |
| 22 #include "third_party/WebKit/public/web/WebElement.h" | 22 #include "third_party/WebKit/public/web/WebElement.h" |
| 23 #include "third_party/WebKit/public/web/WebFrame.h" | 23 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 24 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 24 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 25 #include "v8/include/v8.h" | 25 #include "v8/include/v8.h" |
| 26 | 26 |
| 27 using ppapi::NPObjectVar; | 27 using ppapi::NPObjectVar; |
| 28 using ppapi::PpapiGlobals; | 28 using ppapi::PpapiGlobals; |
| 29 using ppapi::StringVar; | 29 using ppapi::StringVar; |
| 30 using ppapi::Var; | 30 using ppapi::Var; |
| 31 using blink::WebArrayBuffer; | 31 using blink::WebArrayBuffer; |
| 32 using blink::WebBindings; | 32 using blink::WebBindings; |
| 33 using blink::WebFrame; | 33 using blink::WebLocalFrame; |
| 34 using blink::WebPluginContainer; | 34 using blink::WebPluginContainer; |
| 35 | 35 |
| 36 namespace content { | 36 namespace content { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 const char kInvalidPluginValue[] = "Error: Plugin returned invalid value."; | 40 const char kInvalidPluginValue[] = "Error: Plugin returned invalid value."; |
| 41 | 41 |
| 42 PP_Var NPObjectToPPVarImpl(PepperPluginInstanceImpl* instance, | 42 PP_Var NPObjectToPPVarImpl(PepperPluginInstanceImpl* instance, |
| 43 NPObject* object, | 43 NPObject* object, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 return PP_MakeInt32(int_value); | 173 return PP_MakeInt32(int_value); |
| 174 } | 174 } |
| 175 | 175 |
| 176 PP_Var NPObjectToPPVar(PepperPluginInstanceImpl* instance, NPObject* object) { | 176 PP_Var NPObjectToPPVar(PepperPluginInstanceImpl* instance, NPObject* object) { |
| 177 WebPluginContainer* container = instance->container(); | 177 WebPluginContainer* container = instance->container(); |
| 178 // It's possible that container() is NULL if the plugin has been removed from | 178 // It's possible that container() is NULL if the plugin has been removed from |
| 179 // the DOM (but the PluginInstance is not destroyed yet). | 179 // the DOM (but the PluginInstance is not destroyed yet). |
| 180 if (!container) | 180 if (!container) |
| 181 return PP_MakeUndefined(); | 181 return PP_MakeUndefined(); |
| 182 WebFrame* frame = container->element().document().frame(); | 182 WebLocalFrame* frame = container->element().document().frame(); |
| 183 if (!frame) | 183 if (!frame) |
| 184 return PP_MakeUndefined(); | 184 return PP_MakeUndefined(); |
| 185 | 185 |
| 186 v8::HandleScope scope(instance->GetIsolate()); | 186 v8::HandleScope scope(instance->GetIsolate()); |
| 187 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); | 187 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 188 return NPObjectToPPVarImpl(instance, object, context); | 188 return NPObjectToPPVarImpl(instance, object, context); |
| 189 } | 189 } |
| 190 | 190 |
| 191 PP_Var NPObjectToPPVarForTest(PepperPluginInstanceImpl* instance, | 191 PP_Var NPObjectToPPVarForTest(PepperPluginInstanceImpl* instance, |
| 192 NPObject* object) { | 192 NPObject* object) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 // static | 356 // static |
| 357 void TryCatch::Catch(void* self, const char* message) { | 357 void TryCatch::Catch(void* self, const char* message) { |
| 358 static_cast<TryCatch*>(self)->SetException(message); | 358 static_cast<TryCatch*>(self)->SetException(message); |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace content | 361 } // namespace content |
| OLD | NEW |