| OLD | NEW |
| 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/renderer/browser_plugin/browser_plugin_bindings.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" | 21 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
| 22 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
| 23 #include "third_party/WebKit/public/web/WebElement.h" | 23 #include "third_party/WebKit/public/web/WebElement.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebNode.h" | 25 #include "third_party/WebKit/public/web/WebNode.h" |
| 26 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 26 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 27 #include "third_party/WebKit/public/web/WebView.h" | 27 #include "third_party/WebKit/public/web/WebView.h" |
| 28 #include "third_party/npapi/bindings/npapi.h" | 28 #include "third_party/npapi/bindings/npapi.h" |
| 29 #include "v8/include/v8.h" | 29 #include "v8/include/v8.h" |
| 30 | 30 |
| 31 using WebKit::WebBindings; | 31 using blink::WebBindings; |
| 32 using WebKit::WebElement; | 32 using blink::WebElement; |
| 33 using WebKit::WebDOMEvent; | 33 using blink::WebDOMEvent; |
| 34 using WebKit::WebDOMMessageEvent; | 34 using blink::WebDOMMessageEvent; |
| 35 using WebKit::WebPluginContainer; | 35 using blink::WebPluginContainer; |
| 36 using WebKit::WebString; | 36 using blink::WebString; |
| 37 | 37 |
| 38 namespace content { | 38 namespace content { |
| 39 | 39 |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 BrowserPluginBindings* GetBindings(NPObject* object) { | 42 BrowserPluginBindings* GetBindings(NPObject* object) { |
| 43 return static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(object)-> | 43 return static_cast<BrowserPluginBindings::BrowserPluginNPObject*>(object)-> |
| 44 message_channel.get(); | 44 message_channel.get(); |
| 45 } | 45 } |
| 46 | 46 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 browser_plugin::kMethodInternalAttach, 1) { | 235 browser_plugin::kMethodInternalAttach, 1) { |
| 236 } | 236 } |
| 237 | 237 |
| 238 virtual bool Invoke(BrowserPluginBindings* bindings, | 238 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 239 const NPVariant* args, | 239 const NPVariant* args, |
| 240 NPVariant* result) OVERRIDE { | 240 NPVariant* result) OVERRIDE { |
| 241 if (!bindings->instance()->render_view()) | 241 if (!bindings->instance()->render_view()) |
| 242 return false; | 242 return false; |
| 243 | 243 |
| 244 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 244 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 245 v8::Handle<v8::Value> obj(WebKit::WebBindings::toV8Value(&args[0])); | 245 v8::Handle<v8::Value> obj(blink::WebBindings::toV8Value(&args[0])); |
| 246 scoped_ptr<base::Value> value( | 246 scoped_ptr<base::Value> value( |
| 247 converter->FromV8Value(obj, bindings->instance()->render_view()-> | 247 converter->FromV8Value(obj, bindings->instance()->render_view()-> |
| 248 GetWebView()->mainFrame()->mainWorldScriptContext())); | 248 GetWebView()->mainFrame()->mainWorldScriptContext())); |
| 249 if (!value) | 249 if (!value) |
| 250 return false; | 250 return false; |
| 251 | 251 |
| 252 if (!value->IsType(Value::TYPE_DICTIONARY)) | 252 if (!value->IsType(Value::TYPE_DICTIONARY)) |
| 253 return false; | 253 return false; |
| 254 | 254 |
| 255 scoped_ptr<base::DictionaryValue> extra_params( | 255 scoped_ptr<base::DictionaryValue> extra_params( |
| 256 static_cast<base::DictionaryValue*>(value.release())); | 256 static_cast<base::DictionaryValue*>(value.release())); |
| 257 bindings->instance()->Attach(extra_params.Pass()); | 257 bindings->instance()->Attach(extra_params.Pass()); |
| 258 return true; | 258 return true; |
| 259 } | 259 } |
| 260 | 260 |
| 261 private: | 261 private: |
| 262 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttach); | 262 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttach); |
| 263 }; | 263 }; |
| 264 | 264 |
| 265 class BrowserPluginBindingAttachWindowTo : public BrowserPluginMethodBinding { | 265 class BrowserPluginBindingAttachWindowTo : public BrowserPluginMethodBinding { |
| 266 public: | 266 public: |
| 267 BrowserPluginBindingAttachWindowTo() | 267 BrowserPluginBindingAttachWindowTo() |
| 268 : BrowserPluginMethodBinding( | 268 : BrowserPluginMethodBinding( |
| 269 browser_plugin::kMethodInternalAttachWindowTo, 2) { | 269 browser_plugin::kMethodInternalAttachWindowTo, 2) { |
| 270 } | 270 } |
| 271 | 271 |
| 272 virtual bool Invoke(BrowserPluginBindings* bindings, | 272 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 273 const NPVariant* args, | 273 const NPVariant* args, |
| 274 NPVariant* result) OVERRIDE { | 274 NPVariant* result) OVERRIDE { |
| 275 WebKit::WebNode node; | 275 blink::WebNode node; |
| 276 WebBindings::getNode(NPVARIANT_TO_OBJECT(args[0]), &node); | 276 WebBindings::getNode(NPVARIANT_TO_OBJECT(args[0]), &node); |
| 277 int window_id = IntFromNPVariant(args[1]); | 277 int window_id = IntFromNPVariant(args[1]); |
| 278 BOOLEAN_TO_NPVARIANT(BrowserPlugin::AttachWindowTo(node, window_id), | 278 BOOLEAN_TO_NPVARIANT(BrowserPlugin::AttachWindowTo(node, window_id), |
| 279 *result); | 279 *result); |
| 280 return true; | 280 return true; |
| 281 } | 281 } |
| 282 | 282 |
| 283 private: | 283 private: |
| 284 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttachWindowTo); | 284 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttachWindowTo); |
| 285 }; | 285 }; |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 719 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 720 iter != property_bindings_.end(); | 720 iter != property_bindings_.end(); |
| 721 ++iter) { | 721 ++iter) { |
| 722 if ((*iter)->MatchesName(name)) | 722 if ((*iter)->MatchesName(name)) |
| 723 return (*iter)->GetProperty(this, result); | 723 return (*iter)->GetProperty(this, result); |
| 724 } | 724 } |
| 725 return false; | 725 return false; |
| 726 } | 726 } |
| 727 | 727 |
| 728 } // namespace content | 728 } // namespace content |
| OLD | NEW |