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

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

Issue 299753011: Move allocate instance id to chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: HasPermission function moved Created 6 years, 6 months 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 624e19f88e5f65047960943516d472f3ece0ade7..6758242b9a83186c9926df14c6f4ac8ee077509b 100644
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc
@@ -51,18 +51,6 @@ std::string StringFromNPVariant(const NPVariant& variant) {
return std::string(np_string.UTF8Characters, np_string.UTF8Length);
}
-bool StringToNPVariant(const std::string &in, NPVariant *variant) {
- size_t length = in.size();
- NPUTF8 *chars = static_cast<NPUTF8 *>(malloc(length));
- if (!chars) {
- VOID_TO_NPVARIANT(*variant);
- return false;
- }
- memcpy(chars, in.c_str(), length);
- STRINGN_TO_NPVARIANT(chars, length, *variant);
- return true;
-}
-
// Depending on where the attribute comes from it could be a string, int32,
// or a double. Javascript tends to produce an int32 or a string, but setting
// the value from the developer tools console may also produce a double.
@@ -515,97 +503,6 @@ class BrowserPluginPropertyBindingMinWidth
DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingMinWidth);
};
-class BrowserPluginPropertyBindingPartition
- : public BrowserPluginPropertyBinding {
- public:
- BrowserPluginPropertyBindingPartition()
- : BrowserPluginPropertyBinding(browser_plugin::kAttributePartition) {
- }
- virtual bool GetProperty(BrowserPluginBindings* bindings,
- NPVariant* result) OVERRIDE {
- std::string partition_id = bindings->instance()->GetPartitionAttribute();
- return StringToNPVariant(partition_id, result);
- }
- virtual bool SetProperty(BrowserPluginBindings* bindings,
- NPObject* np_obj,
- const NPVariant* variant) OVERRIDE {
- std::string new_value = StringFromNPVariant(*variant);
- std::string old_value = bindings->instance()->GetPartitionAttribute();
- if (old_value != new_value) {
- UpdateDOMAttribute(bindings, new_value);
- std::string error_message;
- if (!bindings->instance()->ParsePartitionAttribute(&error_message)) {
- // Reset to old value on error.
- UpdateDOMAttribute(bindings, old_value);
- // Exceptions must be set as the last operation before returning to
- // script.
- WebBindings::setException(
- np_obj, static_cast<const NPUTF8 *>(error_message.c_str()));
- return false;
- }
- }
- return true;
- }
- virtual void RemoveProperty(BrowserPluginBindings* bindings,
- NPObject* np_obj) OVERRIDE {
- std::string error_message;
- if (bindings->instance()->CanRemovePartitionAttribute(&error_message)) {
- bindings->instance()->RemoveDOMAttribute(name());
- } else {
- WebBindings::setException(
- np_obj, static_cast<const NPUTF8 *>(error_message.c_str()));
- }
- }
- private:
- DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingPartition);
-};
-
-class BrowserPluginPropertyBindingSrc : public BrowserPluginPropertyBinding {
- public:
- BrowserPluginPropertyBindingSrc()
- : BrowserPluginPropertyBinding(browser_plugin::kAttributeSrc) {
- }
- virtual bool GetProperty(BrowserPluginBindings* bindings,
- NPVariant* result) OVERRIDE {
- std::string src = bindings->instance()->GetSrcAttribute();
- return StringToNPVariant(src, result);
- }
- virtual bool SetProperty(BrowserPluginBindings* bindings,
- NPObject* np_obj,
- const NPVariant* variant) OVERRIDE {
- std::string new_value = StringFromNPVariant(*variant);
- // We should not be issuing navigation IPCs if we attempt to set the
- // src property to the empty string. Instead, we want to simply restore
- // the src attribute back to its old value.
- if (new_value.empty()) {
- return true;
- }
- std::string old_value = bindings->instance()->GetSrcAttribute();
- // If the new value was empty then we're effectively resetting the
- // attribute to the old value here. This will be picked up by <webview>'s
- // mutation observer and will restore the src attribute after it has been
- // removed.
- UpdateDOMAttribute(bindings, new_value);
- std::string error_message;
- if (!bindings->instance()->ParseSrcAttribute(&error_message)) {
- // Reset to old value on error.
- UpdateDOMAttribute(bindings, old_value);
- // Exceptions must be set as the last operation before returning to
- // script.
- WebBindings::setException(
- np_obj, static_cast<const NPUTF8 *>(error_message.c_str()));
- return false;
- }
- return true;
- }
- virtual void RemoveProperty(BrowserPluginBindings* bindings,
- NPObject* np_obj) OVERRIDE {
- bindings->instance()->RemoveDOMAttribute(name());
- }
- private:
- DISALLOW_COPY_AND_ASSIGN(BrowserPluginPropertyBindingSrc);
-};
-
// BrowserPluginBindings ------------------------------------------------------
@@ -635,8 +532,6 @@ BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance)
property_bindings_.push_back(new BrowserPluginPropertyBindingMaxWidth);
property_bindings_.push_back(new BrowserPluginPropertyBindingMinHeight);
property_bindings_.push_back(new BrowserPluginPropertyBindingMinWidth);
- property_bindings_.push_back(new BrowserPluginPropertyBindingPartition);
- property_bindings_.push_back(new BrowserPluginPropertyBindingSrc);
}
BrowserPluginBindings::~BrowserPluginBindings() {
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | content/renderer/browser_plugin/browser_plugin_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698