| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 }; | 229 }; |
| 230 | 230 |
| 231 class BrowserPluginBindingAttach: public BrowserPluginMethodBinding { | 231 class BrowserPluginBindingAttach: public BrowserPluginMethodBinding { |
| 232 public: | 232 public: |
| 233 BrowserPluginBindingAttach() | 233 BrowserPluginBindingAttach() |
| 234 : BrowserPluginMethodBinding(browser_plugin::kMethodInternalAttach, 2) {} | 234 : BrowserPluginMethodBinding(browser_plugin::kMethodInternalAttach, 2) {} |
| 235 | 235 |
| 236 virtual bool Invoke(BrowserPluginBindings* bindings, | 236 virtual bool Invoke(BrowserPluginBindings* bindings, |
| 237 const NPVariant* args, | 237 const NPVariant* args, |
| 238 NPVariant* result) OVERRIDE { | 238 NPVariant* result) OVERRIDE { |
| 239 bool attached = InvokeHelper(bindings, args); |
| 240 BOOLEAN_TO_NPVARIANT(attached, *result); |
| 241 return true; |
| 242 } |
| 243 |
| 244 private: |
| 245 bool InvokeHelper(BrowserPluginBindings* bindings, const NPVariant* args) { |
| 239 if (!bindings->instance()->render_view()) | 246 if (!bindings->instance()->render_view()) |
| 240 return false; | 247 return false; |
| 241 | 248 |
| 242 int instance_id = IntFromNPVariant(args[0]); | 249 int instance_id = IntFromNPVariant(args[0]); |
| 243 if (!instance_id) | 250 if (!instance_id) |
| 244 return false; | 251 return false; |
| 245 | 252 |
| 246 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 253 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 247 v8::Handle<v8::Value> obj(blink::WebBindings::toV8Value(&args[1])); | 254 v8::Handle<v8::Value> obj(blink::WebBindings::toV8Value(&args[1])); |
| 248 scoped_ptr<base::Value> value( | 255 scoped_ptr<base::Value> value( |
| 249 converter->FromV8Value(obj, bindings->instance()->render_view()-> | 256 converter->FromV8Value(obj, bindings->instance()->render_view()-> |
| 250 GetWebView()->mainFrame()->mainWorldScriptContext())); | 257 GetWebView()->mainFrame()->mainWorldScriptContext())); |
| 251 if (!value) | 258 if (!value) |
| 252 return false; | 259 return false; |
| 253 | 260 |
| 254 if (!value->IsType(base::Value::TYPE_DICTIONARY)) | 261 if (!value->IsType(base::Value::TYPE_DICTIONARY)) |
| 255 return false; | 262 return false; |
| 256 | 263 |
| 257 scoped_ptr<base::DictionaryValue> extra_params( | 264 scoped_ptr<base::DictionaryValue> extra_params( |
| 258 static_cast<base::DictionaryValue*>(value.release())); | 265 static_cast<base::DictionaryValue*>(value.release())); |
| 259 bindings->instance()->Attach(instance_id, extra_params.Pass()); | 266 bindings->instance()->Attach(instance_id, extra_params.Pass()); |
| 260 return true; | 267 return true; |
| 261 } | 268 } |
| 262 | |
| 263 private: | |
| 264 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttach); | 269 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttach); |
| 265 }; | 270 }; |
| 266 | 271 |
| 267 // BrowserPluginPropertyBinding ------------------------------------------------ | 272 // BrowserPluginPropertyBinding ------------------------------------------------ |
| 268 | 273 |
| 269 class BrowserPluginPropertyBinding { | 274 class BrowserPluginPropertyBinding { |
| 270 public: | 275 public: |
| 271 explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) {} | 276 explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) {} |
| 272 virtual ~BrowserPluginPropertyBinding() {} | 277 virtual ~BrowserPluginPropertyBinding() {} |
| 273 const std::string& name() const { return name_; } | 278 const std::string& name() const { return name_; } |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 for (PropertyBindingList::iterator iter = property_bindings_.begin(); | 709 for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
| 705 iter != property_bindings_.end(); | 710 iter != property_bindings_.end(); |
| 706 ++iter) { | 711 ++iter) { |
| 707 if ((*iter)->MatchesName(name)) | 712 if ((*iter)->MatchesName(name)) |
| 708 return (*iter)->GetProperty(this, result); | 713 return (*iter)->GetProperty(this, result); |
| 709 } | 714 } |
| 710 return false; | 715 return false; |
| 711 } | 716 } |
| 712 | 717 |
| 713 } // namespace content | 718 } // namespace content |
| OLD | NEW |