Index: content/renderer/browser_plugin/browser_plugin_bindings.cc |
diff --git a/content/renderer/browser_plugin/browser_plugin_bindings.cc b/content/renderer/browser_plugin/browser_plugin_bindings.cc |
index 2bf0387fe1f25c8b4d64758759bdc5ca61564800..682a80e3f7fc1a3d14a8b5c835f4f1a7bfde26a9 100644 |
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc |
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc |
@@ -13,7 +13,9 @@ |
#include "base/string_number_conversions.h" |
#include "base/string_split.h" |
#include "base/utf_string_conversions.h" |
-#include "content/renderer/browser_plugin/browser_plugin.h" |
+#include "content/public/renderer/browser_plugin/browser_plugin_method_binding.h" |
+#include "content/public/renderer/browser_plugin/browser_plugin_property_binding.h" |
+#include "content/renderer/browser_plugin/browser_plugin_impl.h" |
#include "third_party/npapi/bindings/npapi.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
@@ -204,44 +206,40 @@ NPClass browser_plugin_message_class = { |
} // namespace |
-// BrowserPluginMethodBinding -------------------------------------------------- |
+// Method Bindings ------------------------------------------------------------ |
-class BrowserPluginMethodBinding { |
+class BrowserPluginMethodBindingImpl : public BrowserPluginMethodBinding { |
public: |
- BrowserPluginMethodBinding(const char name[], uint32 arg_count) |
+ BrowserPluginMethodBindingImpl(const char name[], uint32 arg_count) |
: name_(name), |
arg_count_(arg_count) { |
} |
- virtual ~BrowserPluginMethodBinding() {} |
+ virtual ~BrowserPluginMethodBindingImpl() {} |
- bool MatchesName(NPIdentifier name) const { |
- return WebBindings::getStringIdentifier(name_.c_str()) == name; |
+ virtual bool MatchesName(const NPIdentifier& name) const OVERRIDE { |
+ return WebKit::WebBindings::getStringIdentifier(name_.c_str()) == name; |
} |
- uint32 arg_count() const { return arg_count_; } |
- |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
- const NPVariant* args, |
- NPVariant* result) = 0; |
+ virtual uint32 GetArgCount() const OVERRIDE { return arg_count_; } |
private: |
std::string name_; |
uint32 arg_count_; |
- DISALLOW_COPY_AND_ASSIGN(BrowserPluginMethodBinding); |
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginMethodBindingImpl); |
}; |
-class BrowserPluginBindingBack : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingBack : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingBack() |
- : BrowserPluginMethodBinding(kMethodBack, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodBack, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- bindings->instance()->Back(); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->Back(); |
return true; |
} |
@@ -249,16 +247,17 @@ class BrowserPluginBindingBack : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingBack); |
}; |
-class BrowserPluginBindingCanGoBack : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingCanGoBack : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingCanGoBack() |
- : BrowserPluginMethodBinding(kMethodCanGoBack, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodCanGoBack, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- BOOLEAN_TO_NPVARIANT(bindings->instance()->CanGoBack(), *result); |
+ BOOLEAN_TO_NPVARIANT( |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->CanGoBack(), *result); |
return true; |
} |
@@ -266,16 +265,18 @@ class BrowserPluginBindingCanGoBack : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingCanGoBack); |
}; |
-class BrowserPluginBindingCanGoForward : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingCanGoForward : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingCanGoForward() |
- : BrowserPluginMethodBinding(kMethodCanGoForward, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodCanGoForward, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- BOOLEAN_TO_NPVARIANT(bindings->instance()->CanGoForward(), *result); |
+ BOOLEAN_TO_NPVARIANT( |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->CanGoForward(), |
+ *result); |
return true; |
} |
@@ -283,16 +284,16 @@ class BrowserPluginBindingCanGoForward : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingCanGoForward); |
}; |
-class BrowserPluginBindingForward : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingForward : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingForward() |
- : BrowserPluginMethodBinding(kMethodForward, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodForward, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- bindings->instance()->Forward(); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->Forward(); |
return true; |
} |
@@ -300,16 +301,17 @@ class BrowserPluginBindingForward : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingForward); |
}; |
-class BrowserPluginBindingGetProcessID : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingGetProcessID : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingGetProcessID() |
- : BrowserPluginMethodBinding(kMethodGetProcessId, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodGetProcessId, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- int process_id = bindings->instance()->process_id(); |
+ int process_id = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->process_id(); |
INT32_TO_NPVARIANT(process_id, *result); |
return true; |
} |
@@ -318,16 +320,17 @@ class BrowserPluginBindingGetProcessID : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGetProcessID); |
}; |
-class BrowserPluginBindingGo : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingGo : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingGo() |
- : BrowserPluginMethodBinding(kMethodGo, 1) { |
+ : BrowserPluginMethodBindingImpl(kMethodGo, 1) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- bindings->instance()->Go(Int32FromNPVariant(args[0])); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->Go( |
+ Int32FromNPVariant(args[0])); |
return true; |
} |
@@ -335,16 +338,16 @@ class BrowserPluginBindingGo : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGo); |
}; |
-class BrowserPluginBindingReload : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingReload : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingReload() |
- : BrowserPluginMethodBinding(kMethodReload, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodReload, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- bindings->instance()->Reload(); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->Reload(); |
return true; |
} |
@@ -352,16 +355,16 @@ class BrowserPluginBindingReload : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingReload); |
}; |
-class BrowserPluginBindingStop : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingStop : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingStop() |
- : BrowserPluginMethodBinding(kMethodStop, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodStop, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- bindings->instance()->Stop(); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->Stop(); |
return true; |
} |
@@ -369,16 +372,16 @@ class BrowserPluginBindingStop : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingStop); |
}; |
-class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
+class BrowserPluginBindingTerminate : public BrowserPluginMethodBindingImpl { |
public: |
BrowserPluginBindingTerminate() |
- : BrowserPluginMethodBinding(kMethodTerminate, 0) { |
+ : BrowserPluginMethodBindingImpl(kMethodTerminate, 0) { |
} |
- virtual bool Invoke(BrowserPluginBindings* bindings, |
+ virtual bool Invoke(BrowserPlugin* browser_plugin, |
const NPVariant* args, |
NPVariant* result) OVERRIDE { |
- bindings->instance()->TerminateGuest(); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)->TerminateGuest(); |
sadrul
2013/01/09 15:21:54
no-op comment: All these static_casts seem a bit a
Fady Samuel
2013/01/09 17:41:24
Sigh, neither can I :-(
|
return true; |
} |
@@ -386,77 +389,76 @@ class BrowserPluginBindingTerminate : public BrowserPluginMethodBinding { |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingTerminate); |
}; |
-// BrowserPluginPropertyBinding ------------------------------------------------ |
+// Property Bindings ---------------------------------------------------------- |
-class BrowserPluginPropertyBinding { |
+class BrowserPluginPropertyBindingImpl : public BrowserPluginPropertyBinding { |
public: |
- explicit BrowserPluginPropertyBinding(const char name[]) : name_(name) { |
+ explicit BrowserPluginPropertyBindingImpl(const char name[]) : name_(name) { |
} |
- virtual ~BrowserPluginPropertyBinding() {} |
- const std::string& name() const { return name_; } |
- bool MatchesName(NPIdentifier name) const { |
- return WebBindings::getStringIdentifier(name_.c_str()) == name; |
+ |
+ virtual ~BrowserPluginPropertyBindingImpl() {} |
+ |
+ virtual const std::string& GetName() const OVERRIDE { |
+ return name_; |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
- NPVariant* result) = 0; |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
- NPObject* np_obj, |
- const NPVariant* variant) = 0; |
- virtual std::string GetDOMAttributeValue(BrowserPlugin* browser_plugin) = 0; |
- // Updates the DOM Attribute value with the current property value. |
- void UpdateDOMAttribute(BrowserPluginBindings* bindings) { |
- bindings->instance()->UpdateDOMAttribute(name(), |
- GetDOMAttributeValue(bindings->instance())); |
+ |
+ virtual bool MatchesName(NPIdentifier name) const OVERRIDE { |
+ return WebKit::WebBindings::getStringIdentifier(name_.c_str()) == name; |
} |
+ |
private: |
std::string name_; |
- DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBinding); |
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingImpl); |
}; |
class BrowserPluginPropertyBindingAutoSize |
- : public BrowserPluginPropertyBinding { |
+ : public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingAutoSize() : |
- BrowserPluginPropertyBinding(kAttributeAutoSize) { |
+ BrowserPluginPropertyBindingImpl(kAttributeAutoSize) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- bool auto_size = bindings->instance()->auto_size_attribute(); |
+ bool auto_size = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->auto_size_attribute(); |
BOOLEAN_TO_NPVARIANT(auto_size, *result); |
return true; |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
bool auto_size = NPVARIANT_TO_BOOLEAN(*variant); |
- bindings->instance()->SetAutoSizeAttribute(auto_size); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ SetAutoSizeAttribute(auto_size); |
return true; |
} |
virtual std::string GetDOMAttributeValue( |
BrowserPlugin* browser_plugin) OVERRIDE { |
- return browser_plugin->auto_size_attribute() ? "true" : "false"; |
+ return static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ auto_size_attribute() ? "true" : "false"; |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAutoSize); |
}; |
class BrowserPluginPropertyBindingContentWindow |
- : public BrowserPluginPropertyBinding { |
+ : public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingContentWindow() : |
- BrowserPluginPropertyBinding(kAttributeContentWindow) { |
+ BrowserPluginPropertyBindingImpl(kAttributeContentWindow) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- NPObject* obj = bindings->instance()->GetContentWindow(); |
+ NPObject* obj = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->GetContentWindow(); |
if (obj) { |
result->type = NPVariantType_Object; |
result->value.objectValue = WebBindings::retainObject(obj); |
} |
return true; |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
return false; |
@@ -469,131 +471,144 @@ class BrowserPluginPropertyBindingContentWindow |
}; |
class BrowserPluginPropertyBindingMaxHeight |
- : public BrowserPluginPropertyBinding { |
+ : public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingMaxHeight() : |
- BrowserPluginPropertyBinding(kAttributeMaxHeight) { |
+ BrowserPluginPropertyBindingImpl(kAttributeMaxHeight) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- int max_height = bindings->instance()->max_height_attribute(); |
+ int max_height = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->max_height_attribute(); |
INT32_TO_NPVARIANT(max_height, *result); |
return true; |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
int max_height = Int32FromNPVariant(*variant); |
- bindings->instance()->SetMaxHeightAttribute(max_height); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ SetMaxHeightAttribute(max_height); |
return true; |
} |
virtual std::string GetDOMAttributeValue( |
BrowserPlugin* browser_plugin) OVERRIDE { |
- return base::IntToString(browser_plugin->max_height_attribute()); |
+ return base::IntToString(static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ max_height_attribute()); |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxHeight); |
}; |
class BrowserPluginPropertyBindingMaxWidth |
- : public BrowserPluginPropertyBinding { |
+ : public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingMaxWidth() : |
- BrowserPluginPropertyBinding(kAttributeMaxWidth) { |
+ BrowserPluginPropertyBindingImpl(kAttributeMaxWidth) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- int max_width = bindings->instance()->max_width_attribute(); |
+ int max_width = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->max_width_attribute(); |
INT32_TO_NPVARIANT(max_width, *result); |
return true; |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
int max_width = Int32FromNPVariant(*variant); |
- bindings->instance()->SetMaxWidthAttribute(max_width); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ SetMaxWidthAttribute(max_width); |
return true; |
} |
virtual std::string GetDOMAttributeValue( |
BrowserPlugin* browser_plugin) OVERRIDE { |
- return base::IntToString(browser_plugin->max_width_attribute()); |
+ return base::IntToString(static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ max_width_attribute()); |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxWidth); |
}; |
class BrowserPluginPropertyBindingMinHeight |
- : public BrowserPluginPropertyBinding { |
+ : public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingMinHeight() : |
- BrowserPluginPropertyBinding(kAttributeMinHeight) { |
+ BrowserPluginPropertyBindingImpl(kAttributeMinHeight) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- int min_height = bindings->instance()->min_height_attribute(); |
+ int min_height = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->min_height_attribute(); |
INT32_TO_NPVARIANT(min_height, *result); |
return true; |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
int min_height = Int32FromNPVariant(*variant); |
- bindings->instance()->SetMinHeightAttribute(min_height); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ SetMinHeightAttribute(min_height); |
return true; |
} |
virtual std::string GetDOMAttributeValue( |
BrowserPlugin* browser_plugin) OVERRIDE { |
- return base::IntToString(browser_plugin->min_height_attribute()); |
+ return base::IntToString(static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->min_height_attribute()); |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinHeight); |
}; |
class BrowserPluginPropertyBindingMinWidth |
- : public BrowserPluginPropertyBinding { |
+ : public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingMinWidth() : |
- BrowserPluginPropertyBinding(kAttributeMinWidth) { |
+ BrowserPluginPropertyBindingImpl(kAttributeMinWidth) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- int min_width = bindings->instance()->min_width_attribute(); |
+ int min_width = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->min_width_attribute(); |
INT32_TO_NPVARIANT(min_width, *result); |
return true; |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
int min_width = Int32FromNPVariant(*variant); |
- bindings->instance()->SetMinWidthAttribute(min_width); |
+ static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ SetMinWidthAttribute(min_width); |
return true; |
} |
virtual std::string GetDOMAttributeValue( |
BrowserPlugin* browser_plugin) OVERRIDE { |
- return base::IntToString(browser_plugin->min_width_attribute()); |
+ return base::IntToString(static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->min_width_attribute()); |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth); |
}; |
class BrowserPluginPropertyBindingPartition |
- : public BrowserPluginPropertyBinding { |
+ : public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingPartition() : |
- BrowserPluginPropertyBinding(kAttributePartition) { |
+ BrowserPluginPropertyBindingImpl(kAttributePartition) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- std::string partition_id = bindings->instance()->GetPartitionAttribute(); |
+ std::string partition_id = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->GetPartitionAttribute(); |
return StringToNPVariant(partition_id, result); |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
std::string partition_id = StringFromNPVariant(*variant); |
std::string error_message; |
- if (!bindings->instance()->SetPartitionAttribute(partition_id, |
- &error_message)) { |
+ if (!static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ SetPartitionAttribute(partition_id, &error_message)) { |
WebBindings::setException( |
np_obj, static_cast<const NPUTF8 *>(error_message.c_str())); |
return false; |
@@ -602,28 +617,32 @@ class BrowserPluginPropertyBindingPartition |
} |
virtual std::string GetDOMAttributeValue( |
BrowserPlugin* browser_plugin) OVERRIDE { |
- return browser_plugin->GetPartitionAttribute(); |
+ return static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ GetPartitionAttribute(); |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingPartition); |
}; |
-class BrowserPluginPropertyBindingSrc : public BrowserPluginPropertyBinding { |
+class BrowserPluginPropertyBindingSrc : |
+ public BrowserPluginPropertyBindingImpl { |
public: |
BrowserPluginPropertyBindingSrc() : |
- BrowserPluginPropertyBinding(kAttributeSrc) { |
+ BrowserPluginPropertyBindingImpl(kAttributeSrc) { |
} |
- virtual bool GetProperty(BrowserPluginBindings* bindings, |
+ virtual bool GetProperty(BrowserPlugin* browser_plugin, |
NPVariant* result) OVERRIDE { |
- std::string src = bindings->instance()->src_attribute(); |
+ std::string src = static_cast<BrowserPluginImpl*>( |
+ browser_plugin)->src_attribute(); |
return StringToNPVariant(src, result); |
} |
- virtual bool SetProperty(BrowserPluginBindings* bindings, |
+ virtual bool SetProperty(BrowserPlugin* browser_plugin, |
NPObject* np_obj, |
const NPVariant* variant) OVERRIDE { |
std::string src = StringFromNPVariant(*variant); |
std::string error_message; |
- if (!bindings->instance()->SetSrcAttribute(src, &error_message)) { |
+ if (!static_cast<BrowserPluginImpl*>(browser_plugin)-> |
+ SetSrcAttribute(src, &error_message)) { |
WebBindings::setException( |
np_obj, static_cast<const NPUTF8 *>(error_message.c_str())); |
return false; |
@@ -632,7 +651,7 @@ class BrowserPluginPropertyBindingSrc : public BrowserPluginPropertyBinding { |
} |
virtual std::string GetDOMAttributeValue( |
BrowserPlugin* browser_plugin) OVERRIDE { |
- return browser_plugin->src_attribute(); |
+ return static_cast<BrowserPluginImpl*>(browser_plugin)->src_attribute(); |
} |
private: |
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingSrc); |
@@ -647,7 +666,7 @@ BrowserPluginBindings::BrowserPluginNPObject::BrowserPluginNPObject() { |
BrowserPluginBindings::BrowserPluginNPObject::~BrowserPluginNPObject() { |
} |
-BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance) |
+BrowserPluginBindings::BrowserPluginBindings(BrowserPluginImpl* instance) |
: instance_(instance), |
np_object_(NULL), |
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
@@ -697,8 +716,8 @@ bool BrowserPluginBindings::InvokeMethod(NPIdentifier name, |
for (BindingList::iterator iter = method_bindings_.begin(); |
iter != method_bindings_.end(); |
++iter) { |
- if ((*iter)->MatchesName(name) && (*iter)->arg_count() == arg_count) |
- return (*iter)->Invoke(this, args, result); |
+ if ((*iter)->MatchesName(name) && (*iter)->GetArgCount() == arg_count) |
+ return (*iter)->Invoke(instance(), args, result); |
} |
return false; |
} |
@@ -719,9 +738,11 @@ bool BrowserPluginBindings::SetProperty(NPObject* np_obj, |
for (PropertyBindingList::iterator iter = property_bindings_.begin(); |
iter != property_bindings_.end(); |
++iter) { |
- if ((*iter)->MatchesName(name)) { |
- if ((*iter)->SetProperty(this, np_obj, variant)) { |
- (*iter)->UpdateDOMAttribute(this); |
+ BrowserPluginPropertyBinding* property = *iter; |
+ if (property->MatchesName(name)) { |
+ if (property->SetProperty(instance(), np_obj, variant)) { |
+ instance()->UpdateDOMAttribute( |
+ property->GetName(), property->GetDOMAttributeValue(instance())); |
return true; |
} |
break; |
@@ -735,9 +756,19 @@ bool BrowserPluginBindings::GetProperty(NPIdentifier name, NPVariant* result) { |
iter != property_bindings_.end(); |
++iter) { |
if ((*iter)->MatchesName(name)) |
- return (*iter)->GetProperty(this, result); |
+ return (*iter)->GetProperty(instance(), result); |
} |
return false; |
} |
+void BrowserPluginBindings::AddMethodBinding( |
+ BrowserPluginMethodBinding* method_binding) { |
+ method_bindings_.push_back(method_binding); |
+} |
+ |
+void BrowserPluginBindings::AddPropertyBinding( |
+ BrowserPluginPropertyBinding* property_binding) { |
+ property_bindings_.push_back(property_binding); |
+} |
+ |
} // namespace content |