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

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

Issue 10928237: Add support for parsing a 'partition' attribute on the <browser> tag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Testing Created 8 years, 3 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 aaa7ba97310e32e78c369a0defb5d8e7196cb84a..67a0552b362a426f077184526b55ff7c2daa61b9 100644
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc
@@ -40,6 +40,7 @@ namespace {
const char kAddEventListener[] = "addEventListener";
const char kGetProcessId[] = "getProcessId";
+const char kPartitionAttribute[] = "partition";
const char kReloadMethod[] = "reload";
const char kRemoveEventListener[] = "removeEventListener";
const char kSrcAttribute[] = "src";
@@ -74,6 +75,10 @@ bool IdentifierIsSrcAttribute(NPIdentifier identifier) {
return WebBindings::getStringIdentifier(kSrcAttribute) == identifier;
}
+bool IdentifierIsPartitionAttribute(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kPartitionAttribute) == identifier;
+}
+
std::string StringFromNPVariant(const NPVariant& variant) {
if (!NPVARIANT_IS_STRING(variant))
return std::string();
@@ -207,7 +212,8 @@ bool BrowserPluginBindingsInvokeDefault(NPObject* np_obj,
}
bool BrowserPluginBindingsHasProperty(NPObject* np_obj, NPIdentifier name) {
- return IdentifierIsSrcAttribute(name);
+ return IdentifierIsSrcAttribute(name) ||
+ IdentifierIsPartitionAttribute(name);
}
bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
@@ -215,18 +221,29 @@ bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
if (!np_obj)
return false;
+ if (!result)
+ return false;
+
if (IdentifierIsAddEventListener(name) ||
IdentifierIsRemoveEventListener(name))
return false;
+ // All attributes from here on rely on the bindings, so retrieve it once and
+ // return on failure.
+ BrowserPluginBindings* bindings = GetBindings(np_obj);
+ if (!bindings)
+ return false;
+
if (IdentifierIsSrcAttribute(name)) {
- BrowserPluginBindings* bindings = GetBindings(np_obj);
- if (!bindings)
- return false;
std::string src = bindings->instance()->GetSrcAttribute();
return StringToNPVariant(src, result);
}
+ if (IdentifierIsPartitionAttribute(name)) {
+ std::string partition_id = bindings->instance()->GetPartitionAttribute();
+ return StringToNPVariant(partition_id, result);
+ }
+
return false;
}
@@ -234,15 +251,33 @@ bool BrowserPluginBindingsSetProperty(NPObject* np_obj, NPIdentifier name,
const NPVariant* variant) {
if (!np_obj)
return false;
+ if (!variant)
+ return false;
+
+ // All attributes from here on rely on the bindings, so retrieve it once and
+ // return on failure.
+ BrowserPluginBindings* bindings = GetBindings(np_obj);
+ if (!bindings)
+ return false;
if (IdentifierIsSrcAttribute(name)) {
std::string src = StringFromNPVariant(*variant);
- BrowserPluginBindings* bindings = GetBindings(np_obj);
- if (!bindings)
- return false;
bindings->instance()->SetSrcAttribute(src);
return true;
}
+
+ if (IdentifierIsPartitionAttribute(name)) {
+ std::string partition_id = StringFromNPVariant(*variant);
+ std::string error_message;
+ if (!bindings->instance()->SetPartitionAttribute(partition_id,
+ error_message)) {
+ WebBindings::setException(
+ np_obj, static_cast<const NPUTF8 *>(error_message.c_str()));
+ return false;
+ }
+ return true;
+ }
+
return false;
}
« 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