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
3 // found in the LICENSE file.
5 #include "content/renderer/browser_plugin/browser_plugin_bindings.h"
10 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_split.h"
15 #include "base/strings/utf_string_conversions.h"
16 #include "content/common/browser_plugin/browser_plugin_constants.h"
17 #include "content/public/renderer/v8_value_converter.h"
18 #include "content/renderer/browser_plugin/browser_plugin.h"
19 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/web/WebBindings.h"
21 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h"
22 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebElement.h"
24 #include "third_party/WebKit/public/web/WebFrame.h"
25 #include "third_party/WebKit/public/web/WebNode.h"
26 #include "third_party/WebKit/public/web/WebPluginContainer.h"
27 #include "third_party/WebKit/public/web/WebView.h"
28 #include "third_party/npapi/bindings/npapi.h"
29 #include "v8/include/v8.h"
31 using blink::WebBindings
;
32 using blink::WebElement
;
33 using blink::WebDOMEvent
;
34 using blink::WebDOMMessageEvent
;
35 using blink::WebPluginContainer
;
36 using blink::WebString
;
42 BrowserPluginBindings
* GetBindings(NPObject
* object
) {
43 return static_cast<BrowserPluginBindings::BrowserPluginNPObject
*>(object
)->
44 message_channel
.get();
47 std::string
StringFromNPVariant(const NPVariant
& variant
) {
48 if (!NPVARIANT_IS_STRING(variant
))
50 const NPString
& np_string
= NPVARIANT_TO_STRING(variant
);
51 return std::string(np_string
.UTF8Characters
, np_string
.UTF8Length
);
54 bool StringToNPVariant(const std::string
&in
, NPVariant
*variant
) {
55 size_t length
= in
.size();
56 NPUTF8
*chars
= static_cast<NPUTF8
*>(malloc(length
));
58 VOID_TO_NPVARIANT(*variant
);
61 memcpy(chars
, in
.c_str(), length
);
62 STRINGN_TO_NPVARIANT(chars
, length
, *variant
);
66 // Depending on where the attribute comes from it could be a string, int32,
67 // or a double. Javascript tends to produce an int32 or a string, but setting
68 // the value from the developer tools console may also produce a double.
69 int IntFromNPVariant(const NPVariant
& variant
) {
71 switch (variant
.type
) {
72 case NPVariantType_Double
:
73 value
= NPVARIANT_TO_DOUBLE(variant
);
75 case NPVariantType_Int32
:
76 value
= NPVARIANT_TO_INT32(variant
);
78 case NPVariantType_String
:
79 base::StringToInt(StringFromNPVariant(variant
), &value
);
87 //------------------------------------------------------------------------------
88 // Implementations of NPClass functions. These are here to:
89 // - Implement src attribute.
90 //------------------------------------------------------------------------------
91 NPObject
* BrowserPluginBindingsAllocate(NPP npp
, NPClass
* the_class
) {
92 return new BrowserPluginBindings::BrowserPluginNPObject
;
95 void BrowserPluginBindingsDeallocate(NPObject
* object
) {
96 BrowserPluginBindings::BrowserPluginNPObject
* instance
=
97 static_cast<BrowserPluginBindings::BrowserPluginNPObject
*>(object
);
101 bool BrowserPluginBindingsHasMethod(NPObject
* np_obj
, NPIdentifier name
) {
105 BrowserPluginBindings
* bindings
= GetBindings(np_obj
);
109 return bindings
->HasMethod(name
);
112 bool BrowserPluginBindingsInvoke(NPObject
* np_obj
, NPIdentifier name
,
113 const NPVariant
* args
, uint32 arg_count
,
118 BrowserPluginBindings
* bindings
= GetBindings(np_obj
);
122 return bindings
->InvokeMethod(name
, args
, arg_count
, result
);
125 bool BrowserPluginBindingsInvokeDefault(NPObject
* np_obj
,
126 const NPVariant
* args
,
133 bool BrowserPluginBindingsHasProperty(NPObject
* np_obj
, NPIdentifier name
) {
137 BrowserPluginBindings
* bindings
= GetBindings(np_obj
);
141 return bindings
->HasProperty(name
);
144 bool BrowserPluginBindingsGetProperty(NPObject
* np_obj
, NPIdentifier name
,
152 // All attributes from here on rely on the bindings, so retrieve it once and
153 // return on failure.
154 BrowserPluginBindings
* bindings
= GetBindings(np_obj
);
158 return bindings
->GetProperty(name
, result
);
161 bool BrowserPluginBindingsSetProperty(NPObject
* np_obj
, NPIdentifier name
,
162 const NPVariant
* variant
) {
168 // All attributes from here on rely on the bindings, so retrieve it once and
169 // return on failure.
170 BrowserPluginBindings
* bindings
= GetBindings(np_obj
);
174 if (variant
->type
== NPVariantType_Null
)
175 return bindings
->RemoveProperty(np_obj
, name
);
177 return bindings
->SetProperty(np_obj
, name
, variant
);
180 bool BrowserPluginBindingsEnumerate(NPObject
*np_obj
, NPIdentifier
**value
,
186 NPClass browser_plugin_message_class
= {
187 NP_CLASS_STRUCT_VERSION
,
188 &BrowserPluginBindingsAllocate
,
189 &BrowserPluginBindingsDeallocate
,
191 &BrowserPluginBindingsHasMethod
,
192 &BrowserPluginBindingsInvoke
,
193 &BrowserPluginBindingsInvokeDefault
,
194 &BrowserPluginBindingsHasProperty
,
195 &BrowserPluginBindingsGetProperty
,
196 &BrowserPluginBindingsSetProperty
,
198 &BrowserPluginBindingsEnumerate
,
203 // BrowserPluginMethodBinding --------------------------------------------------
205 class BrowserPluginMethodBinding
{
207 BrowserPluginMethodBinding(const char name
[], uint32 arg_count
)
209 arg_count_(arg_count
) {
212 virtual ~BrowserPluginMethodBinding() {}
214 bool MatchesName(NPIdentifier name
) const {
215 return WebBindings::getStringIdentifier(name_
.c_str()) == name
;
218 uint32
arg_count() const { return arg_count_
; }
220 virtual bool Invoke(BrowserPluginBindings
* bindings
,
221 const NPVariant
* args
,
222 NPVariant
* result
) = 0;
228 DISALLOW_COPY_AND_ASSIGN(BrowserPluginMethodBinding
);
231 class BrowserPluginBindingAttach
: public BrowserPluginMethodBinding
{
233 BrowserPluginBindingAttach()
234 : BrowserPluginMethodBinding(browser_plugin::kMethodInternalAttach
, 2) {}
236 virtual bool Invoke(BrowserPluginBindings
* bindings
,
237 const NPVariant
* args
,
238 NPVariant
* result
) OVERRIDE
{
239 if (!bindings
->instance()->render_view())
242 int instance_id
= IntFromNPVariant(args
[0]);
246 scoped_ptr
<V8ValueConverter
> converter(V8ValueConverter::create());
247 v8::Handle
<v8::Value
> obj(blink::WebBindings::toV8Value(&args
[1]));
248 scoped_ptr
<base::Value
> value(
249 converter
->FromV8Value(obj
, bindings
->instance()->render_view()->
250 GetWebView()->mainFrame()->mainWorldScriptContext()));
254 if (!value
->IsType(base::Value::TYPE_DICTIONARY
))
257 scoped_ptr
<base::DictionaryValue
> extra_params(
258 static_cast<base::DictionaryValue
*>(value
.release()));
259 bindings
->instance()->Attach(instance_id
, extra_params
.Pass());
264 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttach
);
267 // BrowserPluginPropertyBinding ------------------------------------------------
269 class BrowserPluginPropertyBinding
{
271 explicit BrowserPluginPropertyBinding(const char name
[]) : name_(name
) {}
272 virtual ~BrowserPluginPropertyBinding() {}
273 const std::string
& name() const { return name_
; }
274 bool MatchesName(NPIdentifier name
) const {
275 return WebBindings::getStringIdentifier(name_
.c_str()) == name
;
277 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
278 NPVariant
* result
) = 0;
279 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
281 const NPVariant
* variant
) = 0;
282 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
283 NPObject
* np_obj
) = 0;
284 // Updates the DOM Attribute value with the current property value.
285 void UpdateDOMAttribute(BrowserPluginBindings
* bindings
,
286 std::string new_value
) {
287 bindings
->instance()->UpdateDOMAttribute(name(), new_value
);
292 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBinding
);
295 class BrowserPluginPropertyBindingAllowTransparency
296 : public BrowserPluginPropertyBinding
{
298 BrowserPluginPropertyBindingAllowTransparency()
299 : BrowserPluginPropertyBinding(
300 browser_plugin::kAttributeAllowTransparency
) {
302 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
303 NPVariant
* result
) OVERRIDE
{
304 bool allow_transparency
=
305 bindings
->instance()->GetAllowTransparencyAttribute();
306 BOOLEAN_TO_NPVARIANT(allow_transparency
, *result
);
309 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
311 const NPVariant
* variant
) OVERRIDE
{
312 std::string value
= StringFromNPVariant(*variant
);
313 if (!bindings
->instance()->HasDOMAttribute(name())) {
314 UpdateDOMAttribute(bindings
, value
);
315 bindings
->instance()->ParseAllowTransparencyAttribute();
317 UpdateDOMAttribute(bindings
, value
);
321 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
322 NPObject
* np_obj
) OVERRIDE
{
323 bindings
->instance()->RemoveDOMAttribute(name());
324 bindings
->instance()->ParseAllowTransparencyAttribute();
327 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAllowTransparency
);
330 class BrowserPluginPropertyBindingAutoSize
331 : public BrowserPluginPropertyBinding
{
333 BrowserPluginPropertyBindingAutoSize()
334 : BrowserPluginPropertyBinding(browser_plugin::kAttributeAutoSize
) {
336 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
337 NPVariant
* result
) OVERRIDE
{
338 bool auto_size
= bindings
->instance()->GetAutoSizeAttribute();
339 BOOLEAN_TO_NPVARIANT(auto_size
, *result
);
342 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
344 const NPVariant
* variant
) OVERRIDE
{
345 std::string value
= StringFromNPVariant(*variant
);
346 if (!bindings
->instance()->HasDOMAttribute(name())) {
347 UpdateDOMAttribute(bindings
, value
);
348 bindings
->instance()->ParseAutoSizeAttribute();
350 UpdateDOMAttribute(bindings
, value
);
354 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
355 NPObject
* np_obj
) OVERRIDE
{
356 bindings
->instance()->RemoveDOMAttribute(name());
357 bindings
->instance()->ParseAutoSizeAttribute();
360 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAutoSize
);
363 class BrowserPluginPropertyBindingContentWindow
364 : public BrowserPluginPropertyBinding
{
366 BrowserPluginPropertyBindingContentWindow()
367 : BrowserPluginPropertyBinding(browser_plugin::kAttributeContentWindow
) {
369 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
370 NPVariant
* result
) OVERRIDE
{
371 NPObject
* obj
= bindings
->instance()->GetContentWindow();
373 result
->type
= NPVariantType_Object
;
374 result
->value
.objectValue
= WebBindings::retainObject(obj
);
378 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
380 const NPVariant
* variant
) OVERRIDE
{
383 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
384 NPObject
* np_obj
) OVERRIDE
{}
386 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingContentWindow
);
389 class BrowserPluginPropertyBindingMaxHeight
390 : public BrowserPluginPropertyBinding
{
392 BrowserPluginPropertyBindingMaxHeight()
393 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMaxHeight
) {
395 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
396 NPVariant
* result
) OVERRIDE
{
397 int max_height
= bindings
->instance()->GetMaxHeightAttribute();
398 INT32_TO_NPVARIANT(max_height
, *result
);
401 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
403 const NPVariant
* variant
) OVERRIDE
{
404 int new_value
= IntFromNPVariant(*variant
);
405 if (bindings
->instance()->GetMaxHeightAttribute() != new_value
) {
406 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
407 bindings
->instance()->ParseSizeContraintsChanged();
411 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
412 NPObject
* np_obj
) OVERRIDE
{
413 bindings
->instance()->RemoveDOMAttribute(name());
414 bindings
->instance()->ParseSizeContraintsChanged();
417 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxHeight
);
420 class BrowserPluginPropertyBindingMaxWidth
421 : public BrowserPluginPropertyBinding
{
423 BrowserPluginPropertyBindingMaxWidth()
424 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMaxWidth
) {
426 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
427 NPVariant
* result
) OVERRIDE
{
428 int max_width
= bindings
->instance()->GetMaxWidthAttribute();
429 INT32_TO_NPVARIANT(max_width
, *result
);
432 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
434 const NPVariant
* variant
) OVERRIDE
{
435 int new_value
= IntFromNPVariant(*variant
);
436 if (bindings
->instance()->GetMaxWidthAttribute() != new_value
) {
437 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
438 bindings
->instance()->ParseSizeContraintsChanged();
442 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
443 NPObject
* np_obj
) OVERRIDE
{
444 bindings
->instance()->RemoveDOMAttribute(name());
445 bindings
->instance()->ParseSizeContraintsChanged();
448 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxWidth
);
451 class BrowserPluginPropertyBindingMinHeight
452 : public BrowserPluginPropertyBinding
{
454 BrowserPluginPropertyBindingMinHeight()
455 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMinHeight
) {
457 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
458 NPVariant
* result
) OVERRIDE
{
459 int min_height
= bindings
->instance()->GetMinHeightAttribute();
460 INT32_TO_NPVARIANT(min_height
, *result
);
463 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
465 const NPVariant
* variant
) OVERRIDE
{
466 int new_value
= IntFromNPVariant(*variant
);
467 if (bindings
->instance()->GetMinHeightAttribute() != new_value
) {
468 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
469 bindings
->instance()->ParseSizeContraintsChanged();
473 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
474 NPObject
* np_obj
) OVERRIDE
{
475 bindings
->instance()->RemoveDOMAttribute(name());
476 bindings
->instance()->ParseSizeContraintsChanged();
479 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinHeight
);
482 class BrowserPluginPropertyBindingMinWidth
483 : public BrowserPluginPropertyBinding
{
485 BrowserPluginPropertyBindingMinWidth()
486 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMinWidth
) {
488 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
489 NPVariant
* result
) OVERRIDE
{
490 int min_width
= bindings
->instance()->GetMinWidthAttribute();
491 INT32_TO_NPVARIANT(min_width
, *result
);
494 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
496 const NPVariant
* variant
) OVERRIDE
{
497 int new_value
= IntFromNPVariant(*variant
);
498 if (bindings
->instance()->GetMinWidthAttribute() != new_value
) {
499 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
500 bindings
->instance()->ParseSizeContraintsChanged();
504 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
505 NPObject
* np_obj
) OVERRIDE
{
506 bindings
->instance()->RemoveDOMAttribute(name());
507 bindings
->instance()->ParseSizeContraintsChanged();
510 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth
);
513 class BrowserPluginPropertyBindingName
514 : public BrowserPluginPropertyBinding
{
516 BrowserPluginPropertyBindingName()
517 : BrowserPluginPropertyBinding(browser_plugin::kAttributeName
) {
519 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
520 NPVariant
* result
) OVERRIDE
{
521 std::string name
= bindings
->instance()->GetNameAttribute();
522 return StringToNPVariant(name
, result
);
524 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
526 const NPVariant
* variant
) OVERRIDE
{
527 std::string new_value
= StringFromNPVariant(*variant
);
528 if (bindings
->instance()->GetNameAttribute() != new_value
) {
529 UpdateDOMAttribute(bindings
, new_value
);
530 bindings
->instance()->ParseNameAttribute();
534 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
535 NPObject
* np_obj
) OVERRIDE
{
536 bindings
->instance()->RemoveDOMAttribute(name());
537 bindings
->instance()->ParseNameAttribute();
540 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingName
);
543 class BrowserPluginPropertyBindingPartition
544 : public BrowserPluginPropertyBinding
{
546 BrowserPluginPropertyBindingPartition()
547 : BrowserPluginPropertyBinding(browser_plugin::kAttributePartition
) {
549 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
550 NPVariant
* result
) OVERRIDE
{
551 std::string partition_id
= bindings
->instance()->GetPartitionAttribute();
552 return StringToNPVariant(partition_id
, result
);
554 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
556 const NPVariant
* variant
) OVERRIDE
{
557 std::string new_value
= StringFromNPVariant(*variant
);
558 std::string old_value
= bindings
->instance()->GetPartitionAttribute();
559 if (old_value
!= new_value
) {
560 UpdateDOMAttribute(bindings
, new_value
);
561 std::string error_message
;
562 if (!bindings
->instance()->ParsePartitionAttribute(&error_message
)) {
563 // Reset to old value on error.
564 UpdateDOMAttribute(bindings
, old_value
);
565 // Exceptions must be set as the last operation before returning to
567 WebBindings::setException(
568 np_obj
, static_cast<const NPUTF8
*>(error_message
.c_str()));
574 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
575 NPObject
* np_obj
) OVERRIDE
{
576 std::string error_message
;
577 if (bindings
->instance()->CanRemovePartitionAttribute(&error_message
)) {
578 bindings
->instance()->RemoveDOMAttribute(name());
580 WebBindings::setException(
581 np_obj
, static_cast<const NPUTF8
*>(error_message
.c_str()));
585 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingPartition
);
588 class BrowserPluginPropertyBindingSrc
: public BrowserPluginPropertyBinding
{
590 BrowserPluginPropertyBindingSrc()
591 : BrowserPluginPropertyBinding(browser_plugin::kAttributeSrc
) {
593 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
594 NPVariant
* result
) OVERRIDE
{
595 std::string src
= bindings
->instance()->GetSrcAttribute();
596 return StringToNPVariant(src
, result
);
598 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
600 const NPVariant
* variant
) OVERRIDE
{
601 std::string new_value
= StringFromNPVariant(*variant
);
602 // We should not be issuing navigation IPCs if we attempt to set the
603 // src property to the empty string. Instead, we want to simply restore
604 // the src attribute back to its old value.
605 if (new_value
.empty()) {
608 std::string old_value
= bindings
->instance()->GetSrcAttribute();
609 // If the new value was empty then we're effectively resetting the
610 // attribute to the old value here. This will be picked up by <webview>'s
611 // mutation observer and will restore the src attribute after it has been
613 UpdateDOMAttribute(bindings
, new_value
);
614 std::string error_message
;
615 if (!bindings
->instance()->ParseSrcAttribute(&error_message
)) {
616 // Reset to old value on error.
617 UpdateDOMAttribute(bindings
, old_value
);
618 // Exceptions must be set as the last operation before returning to
620 WebBindings::setException(
621 np_obj
, static_cast<const NPUTF8
*>(error_message
.c_str()));
626 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
627 NPObject
* np_obj
) OVERRIDE
{
628 bindings
->instance()->RemoveDOMAttribute(name());
631 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingSrc
);
635 // BrowserPluginBindings ------------------------------------------------------
637 BrowserPluginBindings::BrowserPluginNPObject::BrowserPluginNPObject() {
640 BrowserPluginBindings::BrowserPluginNPObject::~BrowserPluginNPObject() {
643 BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin
* instance
)
644 : instance_(instance
),
646 weak_ptr_factory_(this) {
648 WebBindings::createObject(instance
->pluginNPP(),
649 &browser_plugin_message_class
);
650 np_object_
= static_cast<BrowserPluginBindings::BrowserPluginNPObject
*>(obj
);
651 np_object_
->message_channel
= weak_ptr_factory_
.GetWeakPtr();
653 method_bindings_
.push_back(new BrowserPluginBindingAttach
);
655 property_bindings_
.push_back(
656 new BrowserPluginPropertyBindingAllowTransparency
);
657 property_bindings_
.push_back(new BrowserPluginPropertyBindingAutoSize
);
658 property_bindings_
.push_back(new BrowserPluginPropertyBindingContentWindow
);
659 property_bindings_
.push_back(new BrowserPluginPropertyBindingMaxHeight
);
660 property_bindings_
.push_back(new BrowserPluginPropertyBindingMaxWidth
);
661 property_bindings_
.push_back(new BrowserPluginPropertyBindingMinHeight
);
662 property_bindings_
.push_back(new BrowserPluginPropertyBindingMinWidth
);
663 property_bindings_
.push_back(new BrowserPluginPropertyBindingName
);
664 property_bindings_
.push_back(new BrowserPluginPropertyBindingPartition
);
665 property_bindings_
.push_back(new BrowserPluginPropertyBindingSrc
);
668 BrowserPluginBindings::~BrowserPluginBindings() {
669 WebBindings::releaseObject(np_object_
);
672 bool BrowserPluginBindings::HasMethod(NPIdentifier name
) const {
673 for (BindingList::const_iterator iter
= method_bindings_
.begin();
674 iter
!= method_bindings_
.end();
676 if ((*iter
)->MatchesName(name
))
682 bool BrowserPluginBindings::InvokeMethod(NPIdentifier name
,
683 const NPVariant
* args
,
686 for (BindingList::iterator iter
= method_bindings_
.begin();
687 iter
!= method_bindings_
.end();
689 if ((*iter
)->MatchesName(name
) && (*iter
)->arg_count() == arg_count
)
690 return (*iter
)->Invoke(this, args
, result
);
695 bool BrowserPluginBindings::HasProperty(NPIdentifier name
) const {
696 for (PropertyBindingList::const_iterator iter
= property_bindings_
.begin();
697 iter
!= property_bindings_
.end();
699 if ((*iter
)->MatchesName(name
))
705 bool BrowserPluginBindings::SetProperty(NPObject
* np_obj
,
707 const NPVariant
* variant
) {
708 for (PropertyBindingList::iterator iter
= property_bindings_
.begin();
709 iter
!= property_bindings_
.end();
711 if ((*iter
)->MatchesName(name
)) {
712 if ((*iter
)->SetProperty(this, np_obj
, variant
)) {
721 bool BrowserPluginBindings::RemoveProperty(NPObject
* np_obj
,
723 for (PropertyBindingList::iterator iter
= property_bindings_
.begin();
724 iter
!= property_bindings_
.end();
726 if ((*iter
)->MatchesName(name
)) {
727 (*iter
)->RemoveProperty(this, np_obj
);
734 bool BrowserPluginBindings::GetProperty(NPIdentifier name
, NPVariant
* result
) {
735 for (PropertyBindingList::iterator iter
= property_bindings_
.begin();
736 iter
!= property_bindings_
.end();
738 if ((*iter
)->MatchesName(name
))
739 return (*iter
)->GetProperty(this, result
);
744 } // namespace content