Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: content/renderer/browser_plugin/browser_plugin_bindings.cc

Issue 11418261: Browser Plugin: Update DOM Node attributes when properties are updated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed spacing Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 306c489243dd8e42fa9d43b91cf57d39d0c69d0e..8b7f0cc175a2f47d749ee1e621020845b1e6fc66 100644
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/string16.h"
+#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"
@@ -392,6 +393,7 @@ class BrowserPluginPropertyBinding {
explicit BrowserPluginPropertyBinding(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;
}
@@ -400,6 +402,14 @@ class BrowserPluginPropertyBinding {
virtual bool SetProperty(BrowserPluginBindings* bindings,
NPObject* np_obj,
const NPVariant* variant) = 0;
+ virtual std::string GetDOMAttributeValue(BrowserPlugin* browser_plugin) {
+ return std::string();
sadrul 2012/12/04 01:28:46 Like SetProperty/GetProperty, keep this pure here.
Fady Samuel 2012/12/04 01:57:30 Done. I agree, making this pure virtual is better
+ }
+ // Updates the DOM Attribute value with the current property value.
+ void UpdateDOMAttribute(BrowserPluginBindings* bindings) {
+ bindings->instance()->UpdateDOMAttribute(name(),
+ GetDOMAttributeValue(bindings->instance()));
+ }
private:
std::string name_;
@@ -414,17 +424,21 @@ class BrowserPluginPropertyBindingAutoSize
}
virtual bool GetProperty(BrowserPluginBindings* bindings,
NPVariant* result) OVERRIDE {
- bool autosize = bindings->instance()->auto_size_attribute();
- BOOLEAN_TO_NPVARIANT(autosize, *result);
+ bool auto_size = bindings->instance()->auto_size_attribute();
+ BOOLEAN_TO_NPVARIANT(auto_size, *result);
return true;
}
virtual bool SetProperty(BrowserPluginBindings* bindings,
NPObject* np_obj,
const NPVariant* variant) OVERRIDE {
- bool autosize = NPVARIANT_TO_BOOLEAN(*variant);
- bindings->instance()->SetAutoSizeAttribute(autosize);
+ bool auto_size = NPVARIANT_TO_BOOLEAN(*variant);
+ bindings->instance()->SetAutoSizeAttribute(auto_size);
return true;
}
+ virtual std::string GetDOMAttributeValue(
+ BrowserPlugin* browser_plugin) OVERRIDE {
+ return browser_plugin->auto_size_attribute() ? "true" : "false";
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingAutoSize);
};
@@ -472,6 +486,10 @@ class BrowserPluginPropertyBindingMaxHeight
bindings->instance()->SetMaxHeightAttribute(max_height);
return true;
}
+ virtual std::string GetDOMAttributeValue(
+ BrowserPlugin* browser_plugin) OVERRIDE {
+ return base::IntToString(browser_plugin->max_height_attribute());
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxHeight);
};
@@ -495,6 +513,10 @@ class BrowserPluginPropertyBindingMaxWidth
bindings->instance()->SetMaxWidthAttribute(max_width);
return true;
}
+ virtual std::string GetDOMAttributeValue(
+ BrowserPlugin* browser_plugin) OVERRIDE {
+ return base::IntToString(browser_plugin->max_width_attribute());
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMaxWidth);
};
@@ -518,6 +540,10 @@ class BrowserPluginPropertyBindingMinHeight
bindings->instance()->SetMinHeightAttribute(min_height);
return true;
}
+ virtual std::string GetDOMAttributeValue(
+ BrowserPlugin* browser_plugin) OVERRIDE {
+ return base::IntToString(browser_plugin->min_height_attribute());
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinHeight);
};
@@ -541,6 +567,10 @@ class BrowserPluginPropertyBindingMinWidth
bindings->instance()->SetMinWidthAttribute(min_width);
return true;
}
+ virtual std::string GetDOMAttributeValue(
+ BrowserPlugin* browser_plugin) OVERRIDE {
+ return base::IntToString(browser_plugin->min_width_attribute());
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth);
};
@@ -569,6 +599,10 @@ class BrowserPluginPropertyBindingPartition
}
return true;
}
+ virtual std::string GetDOMAttributeValue(
+ BrowserPlugin* browser_plugin) OVERRIDE {
+ return browser_plugin->GetPartitionAttribute();
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingPartition);
};
@@ -595,6 +629,10 @@ class BrowserPluginPropertyBindingSrc : public BrowserPluginPropertyBinding {
}
return true;
}
+ virtual std::string GetDOMAttributeValue(
+ BrowserPlugin* browser_plugin) OVERRIDE {
+ return browser_plugin->src_attribute();
+ }
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingSrc);
};
@@ -680,8 +718,13 @@ bool BrowserPluginBindings::SetProperty(NPObject* np_obj,
for (PropertyBindingList::iterator iter = property_bindings_.begin();
iter != property_bindings_.end();
++iter) {
- if ((*iter)->MatchesName(name))
- return (*iter)->SetProperty(this, np_obj, variant);
+ if ((*iter)->MatchesName(name)) {
+ if ((*iter)->SetProperty(this, np_obj, variant)) {
+ (*iter)->UpdateDOMAttribute(this);
+ return true;
+ }
+ break;
+ }
}
return false;
}

Powered by Google App Engine
This is Rietveld 408576698