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(
235 browser_plugin::kMethodInternalAttach
, 1) {
238 virtual bool Invoke(BrowserPluginBindings
* bindings
,
239 const NPVariant
* args
,
240 NPVariant
* result
) OVERRIDE
{
241 if (!bindings
->instance()->render_view())
244 scoped_ptr
<V8ValueConverter
> converter(V8ValueConverter::create());
245 v8::Handle
<v8::Value
> obj(blink::WebBindings::toV8Value(&args
[0]));
246 scoped_ptr
<base::Value
> value(
247 converter
->FromV8Value(obj
, bindings
->instance()->render_view()->
248 GetWebView()->mainFrame()->mainWorldScriptContext()));
252 if (!value
->IsType(base::Value::TYPE_DICTIONARY
))
255 scoped_ptr
<base::DictionaryValue
> extra_params(
256 static_cast<base::DictionaryValue
*>(value
.release()));
257 bindings
->instance()->Attach(extra_params
.Pass());
262 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttach
);
265 class BrowserPluginBindingAttachWindowTo
: public BrowserPluginMethodBinding
{
267 BrowserPluginBindingAttachWindowTo()
268 : BrowserPluginMethodBinding(
269 browser_plugin::kMethodInternalAttachWindowTo
, 2) {
272 virtual bool Invoke(BrowserPluginBindings
* bindings
,
273 const NPVariant
* args
,
274 NPVariant
* result
) OVERRIDE
{
276 WebBindings::getNode(NPVARIANT_TO_OBJECT(args
[0]), &node
);
277 int window_id
= IntFromNPVariant(args
[1]);
278 BOOLEAN_TO_NPVARIANT(BrowserPlugin::AttachWindowTo(node
, window_id
),
284 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttachWindowTo
);
287 // BrowserPluginPropertyBinding ------------------------------------------------
289 class BrowserPluginPropertyBinding
{
291 explicit BrowserPluginPropertyBinding(const char name
[]) : name_(name
) {}
292 virtual ~BrowserPluginPropertyBinding() {}
293 const std::string
& name() const { return name_
; }
294 bool MatchesName(NPIdentifier name
) const {
295 return WebBindings::getStringIdentifier(name_
.c_str()) == name
;
297 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
298 NPVariant
* result
) = 0;
299 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
301 const NPVariant
* variant
) = 0;
302 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
303 NPObject
* np_obj
) = 0;
304 // Updates the DOM Attribute value with the current property value.
305 void UpdateDOMAttribute(BrowserPluginBindings
* bindings
,
306 std::string new_value
) {
307 bindings
->instance()->UpdateDOMAttribute(name(), new_value
);
312 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBinding
);
315 class BrowserPluginPropertyBindingAllowTransparency
316 : public BrowserPluginPropertyBinding
{
318 BrowserPluginPropertyBindingAllowTransparency()
319 : BrowserPluginPropertyBinding(
320 browser_plugin::kAttributeAllowTransparency
) {
322 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
323 NPVariant
* result
) OVERRIDE
{
324 bool allow_transparency
=
325 bindings
->instance()->GetAllowTransparencyAttribute();
326 BOOLEAN_TO_NPVARIANT(allow_transparency
, *result
);
329 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
331 const NPVariant
* variant
) OVERRIDE
{
332 std::string value
= StringFromNPVariant(*variant
);
333 if (!bindings
->instance()->HasDOMAttribute(name())) {
334 UpdateDOMAttribute(bindings
, value
);
335 bindings
->instance()->ParseAllowTransparencyAttribute();
337 UpdateDOMAttribute(bindings
, value
);
341 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
342 NPObject
* np_obj
) OVERRIDE
{
343 bindings
->instance()->RemoveDOMAttribute(name());
344 bindings
->instance()->ParseAllowTransparencyAttribute();
347 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAllowTransparency
);
350 class BrowserPluginPropertyBindingAutoSize
351 : public BrowserPluginPropertyBinding
{
353 BrowserPluginPropertyBindingAutoSize()
354 : BrowserPluginPropertyBinding(browser_plugin::kAttributeAutoSize
) {
356 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
357 NPVariant
* result
) OVERRIDE
{
358 bool auto_size
= bindings
->instance()->GetAutoSizeAttribute();
359 BOOLEAN_TO_NPVARIANT(auto_size
, *result
);
362 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
364 const NPVariant
* variant
) OVERRIDE
{
365 std::string value
= StringFromNPVariant(*variant
);
366 if (!bindings
->instance()->HasDOMAttribute(name())) {
367 UpdateDOMAttribute(bindings
, value
);
368 bindings
->instance()->ParseAutoSizeAttribute();
370 UpdateDOMAttribute(bindings
, value
);
374 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
375 NPObject
* np_obj
) OVERRIDE
{
376 bindings
->instance()->RemoveDOMAttribute(name());
377 bindings
->instance()->ParseAutoSizeAttribute();
380 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAutoSize
);
383 class BrowserPluginPropertyBindingContentWindow
384 : public BrowserPluginPropertyBinding
{
386 BrowserPluginPropertyBindingContentWindow()
387 : BrowserPluginPropertyBinding(browser_plugin::kAttributeContentWindow
) {
389 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
390 NPVariant
* result
) OVERRIDE
{
391 NPObject
* obj
= bindings
->instance()->GetContentWindow();
393 result
->type
= NPVariantType_Object
;
394 result
->value
.objectValue
= WebBindings::retainObject(obj
);
398 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
400 const NPVariant
* variant
) OVERRIDE
{
403 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
404 NPObject
* np_obj
) OVERRIDE
{}
406 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingContentWindow
);
409 class BrowserPluginPropertyBindingMaxHeight
410 : public BrowserPluginPropertyBinding
{
412 BrowserPluginPropertyBindingMaxHeight()
413 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMaxHeight
) {
415 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
416 NPVariant
* result
) OVERRIDE
{
417 int max_height
= bindings
->instance()->GetMaxHeightAttribute();
418 INT32_TO_NPVARIANT(max_height
, *result
);
421 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
423 const NPVariant
* variant
) OVERRIDE
{
424 int new_value
= IntFromNPVariant(*variant
);
425 if (bindings
->instance()->GetMaxHeightAttribute() != new_value
) {
426 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
427 bindings
->instance()->ParseSizeContraintsChanged();
431 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
432 NPObject
* np_obj
) OVERRIDE
{
433 bindings
->instance()->RemoveDOMAttribute(name());
434 bindings
->instance()->ParseSizeContraintsChanged();
437 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxHeight
);
440 class BrowserPluginPropertyBindingMaxWidth
441 : public BrowserPluginPropertyBinding
{
443 BrowserPluginPropertyBindingMaxWidth()
444 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMaxWidth
) {
446 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
447 NPVariant
* result
) OVERRIDE
{
448 int max_width
= bindings
->instance()->GetMaxWidthAttribute();
449 INT32_TO_NPVARIANT(max_width
, *result
);
452 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
454 const NPVariant
* variant
) OVERRIDE
{
455 int new_value
= IntFromNPVariant(*variant
);
456 if (bindings
->instance()->GetMaxWidthAttribute() != new_value
) {
457 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
458 bindings
->instance()->ParseSizeContraintsChanged();
462 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
463 NPObject
* np_obj
) OVERRIDE
{
464 bindings
->instance()->RemoveDOMAttribute(name());
465 bindings
->instance()->ParseSizeContraintsChanged();
468 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxWidth
);
471 class BrowserPluginPropertyBindingMinHeight
472 : public BrowserPluginPropertyBinding
{
474 BrowserPluginPropertyBindingMinHeight()
475 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMinHeight
) {
477 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
478 NPVariant
* result
) OVERRIDE
{
479 int min_height
= bindings
->instance()->GetMinHeightAttribute();
480 INT32_TO_NPVARIANT(min_height
, *result
);
483 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
485 const NPVariant
* variant
) OVERRIDE
{
486 int new_value
= IntFromNPVariant(*variant
);
487 if (bindings
->instance()->GetMinHeightAttribute() != new_value
) {
488 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
489 bindings
->instance()->ParseSizeContraintsChanged();
493 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
494 NPObject
* np_obj
) OVERRIDE
{
495 bindings
->instance()->RemoveDOMAttribute(name());
496 bindings
->instance()->ParseSizeContraintsChanged();
499 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinHeight
);
502 class BrowserPluginPropertyBindingMinWidth
503 : public BrowserPluginPropertyBinding
{
505 BrowserPluginPropertyBindingMinWidth()
506 : BrowserPluginPropertyBinding(browser_plugin::kAttributeMinWidth
) {
508 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
509 NPVariant
* result
) OVERRIDE
{
510 int min_width
= bindings
->instance()->GetMinWidthAttribute();
511 INT32_TO_NPVARIANT(min_width
, *result
);
514 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
516 const NPVariant
* variant
) OVERRIDE
{
517 int new_value
= IntFromNPVariant(*variant
);
518 if (bindings
->instance()->GetMinWidthAttribute() != new_value
) {
519 UpdateDOMAttribute(bindings
, base::IntToString(new_value
));
520 bindings
->instance()->ParseSizeContraintsChanged();
524 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
525 NPObject
* np_obj
) OVERRIDE
{
526 bindings
->instance()->RemoveDOMAttribute(name());
527 bindings
->instance()->ParseSizeContraintsChanged();
530 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth
);
533 class BrowserPluginPropertyBindingName
534 : public BrowserPluginPropertyBinding
{
536 BrowserPluginPropertyBindingName()
537 : BrowserPluginPropertyBinding(browser_plugin::kAttributeName
) {
539 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
540 NPVariant
* result
) OVERRIDE
{
541 std::string name
= bindings
->instance()->GetNameAttribute();
542 return StringToNPVariant(name
, result
);
544 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
546 const NPVariant
* variant
) OVERRIDE
{
547 std::string new_value
= StringFromNPVariant(*variant
);
548 if (bindings
->instance()->GetNameAttribute() != new_value
) {
549 UpdateDOMAttribute(bindings
, new_value
);
550 bindings
->instance()->ParseNameAttribute();
554 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
555 NPObject
* np_obj
) OVERRIDE
{
556 bindings
->instance()->RemoveDOMAttribute(name());
557 bindings
->instance()->ParseNameAttribute();
560 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingName
);
563 class BrowserPluginPropertyBindingPartition
564 : public BrowserPluginPropertyBinding
{
566 BrowserPluginPropertyBindingPartition()
567 : BrowserPluginPropertyBinding(browser_plugin::kAttributePartition
) {
569 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
570 NPVariant
* result
) OVERRIDE
{
571 std::string partition_id
= bindings
->instance()->GetPartitionAttribute();
572 return StringToNPVariant(partition_id
, result
);
574 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
576 const NPVariant
* variant
) OVERRIDE
{
577 std::string new_value
= StringFromNPVariant(*variant
);
578 std::string old_value
= bindings
->instance()->GetPartitionAttribute();
579 if (old_value
!= new_value
) {
580 UpdateDOMAttribute(bindings
, new_value
);
581 std::string error_message
;
582 if (!bindings
->instance()->ParsePartitionAttribute(&error_message
)) {
583 // Reset to old value on error.
584 UpdateDOMAttribute(bindings
, old_value
);
585 // Exceptions must be set as the last operation before returning to
587 WebBindings::setException(
588 np_obj
, static_cast<const NPUTF8
*>(error_message
.c_str()));
594 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
595 NPObject
* np_obj
) OVERRIDE
{
596 std::string error_message
;
597 if (bindings
->instance()->CanRemovePartitionAttribute(&error_message
)) {
598 bindings
->instance()->RemoveDOMAttribute(name());
600 WebBindings::setException(
601 np_obj
, static_cast<const NPUTF8
*>(error_message
.c_str()));
605 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingPartition
);
608 class BrowserPluginPropertyBindingSrc
: public BrowserPluginPropertyBinding
{
610 BrowserPluginPropertyBindingSrc()
611 : BrowserPluginPropertyBinding(browser_plugin::kAttributeSrc
) {
613 virtual bool GetProperty(BrowserPluginBindings
* bindings
,
614 NPVariant
* result
) OVERRIDE
{
615 std::string src
= bindings
->instance()->GetSrcAttribute();
616 return StringToNPVariant(src
, result
);
618 virtual bool SetProperty(BrowserPluginBindings
* bindings
,
620 const NPVariant
* variant
) OVERRIDE
{
621 std::string new_value
= StringFromNPVariant(*variant
);
622 // We should not be issuing navigation IPCs if we attempt to set the
623 // src property to the empty string. Instead, we want to simply restore
624 // the src attribute back to its old value.
625 if (new_value
.empty()) {
628 std::string old_value
= bindings
->instance()->GetSrcAttribute();
629 // If the new value was empty then we're effectively resetting the
630 // attribute to the old value here. This will be picked up by <webview>'s
631 // mutation observer and will restore the src attribute after it has been
633 UpdateDOMAttribute(bindings
, new_value
);
634 std::string error_message
;
635 if (!bindings
->instance()->ParseSrcAttribute(&error_message
)) {
636 // Reset to old value on error.
637 UpdateDOMAttribute(bindings
, old_value
);
638 // Exceptions must be set as the last operation before returning to
640 WebBindings::setException(
641 np_obj
, static_cast<const NPUTF8
*>(error_message
.c_str()));
646 virtual void RemoveProperty(BrowserPluginBindings
* bindings
,
647 NPObject
* np_obj
) OVERRIDE
{
648 bindings
->instance()->RemoveDOMAttribute(name());
651 DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingSrc
);
655 // BrowserPluginBindings ------------------------------------------------------
657 BrowserPluginBindings::BrowserPluginNPObject::BrowserPluginNPObject() {
660 BrowserPluginBindings::BrowserPluginNPObject::~BrowserPluginNPObject() {
663 BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin
* instance
)
664 : instance_(instance
),
666 weak_ptr_factory_(this) {
668 WebBindings::createObject(instance
->pluginNPP(),
669 &browser_plugin_message_class
);
670 np_object_
= static_cast<BrowserPluginBindings::BrowserPluginNPObject
*>(obj
);
671 np_object_
->message_channel
= weak_ptr_factory_
.GetWeakPtr();
673 method_bindings_
.push_back(new BrowserPluginBindingAttach
);
674 method_bindings_
.push_back(new BrowserPluginBindingAttachWindowTo
);
676 property_bindings_
.push_back(
677 new BrowserPluginPropertyBindingAllowTransparency
);
678 property_bindings_
.push_back(new BrowserPluginPropertyBindingAutoSize
);
679 property_bindings_
.push_back(new BrowserPluginPropertyBindingContentWindow
);
680 property_bindings_
.push_back(new BrowserPluginPropertyBindingMaxHeight
);
681 property_bindings_
.push_back(new BrowserPluginPropertyBindingMaxWidth
);
682 property_bindings_
.push_back(new BrowserPluginPropertyBindingMinHeight
);
683 property_bindings_
.push_back(new BrowserPluginPropertyBindingMinWidth
);
684 property_bindings_
.push_back(new BrowserPluginPropertyBindingName
);
685 property_bindings_
.push_back(new BrowserPluginPropertyBindingPartition
);
686 property_bindings_
.push_back(new BrowserPluginPropertyBindingSrc
);
689 BrowserPluginBindings::~BrowserPluginBindings() {
690 WebBindings::releaseObject(np_object_
);
693 bool BrowserPluginBindings::HasMethod(NPIdentifier name
) const {
694 for (BindingList::const_iterator iter
= method_bindings_
.begin();
695 iter
!= method_bindings_
.end();
697 if ((*iter
)->MatchesName(name
))
703 bool BrowserPluginBindings::InvokeMethod(NPIdentifier name
,
704 const NPVariant
* args
,
707 for (BindingList::iterator iter
= method_bindings_
.begin();
708 iter
!= method_bindings_
.end();
710 if ((*iter
)->MatchesName(name
) && (*iter
)->arg_count() == arg_count
)
711 return (*iter
)->Invoke(this, args
, result
);
716 bool BrowserPluginBindings::HasProperty(NPIdentifier name
) const {
717 for (PropertyBindingList::const_iterator iter
= property_bindings_
.begin();
718 iter
!= property_bindings_
.end();
720 if ((*iter
)->MatchesName(name
))
726 bool BrowserPluginBindings::SetProperty(NPObject
* np_obj
,
728 const NPVariant
* variant
) {
729 for (PropertyBindingList::iterator iter
= property_bindings_
.begin();
730 iter
!= property_bindings_
.end();
732 if ((*iter
)->MatchesName(name
)) {
733 if ((*iter
)->SetProperty(this, np_obj
, variant
)) {
742 bool BrowserPluginBindings::RemoveProperty(NPObject
* np_obj
,
744 for (PropertyBindingList::iterator iter
= property_bindings_
.begin();
745 iter
!= property_bindings_
.end();
747 if ((*iter
)->MatchesName(name
)) {
748 (*iter
)->RemoveProperty(this, np_obj
);
755 bool BrowserPluginBindings::GetProperty(NPIdentifier name
, NPVariant
* result
) {
756 for (PropertyBindingList::iterator iter
= property_bindings_
.begin();
757 iter
!= property_bindings_
.end();
759 if ((*iter
)->MatchesName(name
))
760 return (*iter
)->GetProperty(this, result
);
765 } // namespace content