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

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

Issue 11361052: Browser Plugin: Implement autosize (Embedder-side code) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 42a185fb42dadd6fd7faa587939780ca3c0700bd..42f74dd7d1f0c54aff0f6f31093c6368e0acd548 100644
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc
@@ -36,6 +36,7 @@ namespace content {
namespace {
const char kAddEventListener[] = "addEventListener";
+const char kAutoSizeAttribute[] = "autoSize";
const char kBackMethod[] = "back";
const char kCanGoBack[] = "canGoBack";
const char kCanGoForward[] = "canGoForward";
@@ -43,6 +44,10 @@ const char kContentWindow[] = "contentWindow";
const char kForwardMethod[] = "forward";
const char kGetProcessId[] = "getProcessId";
const char kGoMethod[] = "go";
+const char kMaxHeightAttribute[] = "maxHeight";
+const char kMaxWidthAttribute[] = "maxWidth";
+const char kMinHeightAttribute[] = "minHeight";
+const char kMinWidthAttribute[] = "minWidth";
const char kPartitionAttribute[] = "partition";
const char kReloadMethod[] = "reload";
const char kRemoveEventListener[] = "removeEventListener";
@@ -67,6 +72,26 @@ bool IdentifierIsSrcAttribute(NPIdentifier identifier) {
return WebBindings::getStringIdentifier(kSrcAttribute) == identifier;
}
+bool IdentifierIsMaxHeightAttribute(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kMaxHeightAttribute) == identifier;
+}
+
+bool IdentifierIsMaxWidthAttribute(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kMaxWidthAttribute) == identifier;
+}
+
+bool IdentifierIsMinHeightAttribute(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kMinHeightAttribute) == identifier;
+}
+
+bool IdentifierIsMinWidthAttribute(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kMinWidthAttribute) == identifier;
+}
+
+bool IdentifierIsAutoSizeAttribute(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kAutoSizeAttribute) == identifier;
+}
+
int Int32FromNPVariant(const NPVariant& variant) {
if (NPVARIANT_IS_INT32(variant))
return NPVARIANT_TO_INT32(variant);
@@ -145,7 +170,12 @@ bool BrowserPluginBindingsInvokeDefault(NPObject* np_obj,
bool BrowserPluginBindingsHasProperty(NPObject* np_obj, NPIdentifier name) {
return IdentifierIsSrcAttribute(name) ||
IdentifierIsContentWindow(name) ||
- IdentifierIsPartitionAttribute(name);
+ IdentifierIsPartitionAttribute(name) ||
+ IdentifierIsAutoSizeAttribute(name) ||
+ IdentifierIsMaxHeightAttribute(name) ||
+ IdentifierIsMaxWidthAttribute(name) ||
+ IdentifierIsMinHeightAttribute(name) ||
+ IdentifierIsMinWidthAttribute(name);
}
bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
@@ -176,6 +206,36 @@ bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
return true;
}
+ if (IdentifierIsAutoSizeAttribute(name)) {
+ bool autosize = bindings->instance()->GetAutoSizeAttribute();
+ BOOLEAN_TO_NPVARIANT(autosize, *result);
+ return true;
+ }
+
+ if (IdentifierIsMaxHeightAttribute(name)) {
+ int maxheight = bindings->instance()->GetMaxHeightAttribute();
+ INT32_TO_NPVARIANT(maxheight, *result);
+ return true;
+ }
+
+ if (IdentifierIsMaxWidthAttribute(name)) {
+ int maxwidth = bindings->instance()->GetMaxWidthAttribute();
+ INT32_TO_NPVARIANT(maxwidth, *result);
+ return true;
+ }
+
+ if (IdentifierIsMinHeightAttribute(name)) {
+ int minheight = bindings->instance()->GetMinHeightAttribute();
+ INT32_TO_NPVARIANT(minheight, *result);
+ return true;
+ }
+
+ if (IdentifierIsMinWidthAttribute(name)) {
+ int minwidth = bindings->instance()->GetMinWidthAttribute();
+ INT32_TO_NPVARIANT(minwidth, *result);
+ return true;
+ }
+
if (IdentifierIsPartitionAttribute(name)) {
std::string partition_id = bindings->instance()->GetPartitionAttribute();
return StringToNPVariant(partition_id, result);
@@ -215,6 +275,36 @@ bool BrowserPluginBindingsSetProperty(NPObject* np_obj, NPIdentifier name,
return true;
}
+ if (IdentifierIsAutoSizeAttribute(name)) {
+ bool autosize = NPVARIANT_TO_BOOLEAN(*variant);
+ bindings->instance()->SetAutoSizeAttribute(autosize);
+ return true;
+ }
+
+ if (IdentifierIsMaxHeightAttribute(name)) {
+ int maxheight = Int32FromNPVariant(*variant);
+ bindings->instance()->SetMaxHeightAttribute(maxheight);
+ return true;
+ }
+
+ if (IdentifierIsMaxWidthAttribute(name)) {
+ int maxwidth = Int32FromNPVariant(*variant);
+ bindings->instance()->SetMaxWidthAttribute(maxwidth);
+ return true;
+ }
+
+ if (IdentifierIsMinHeightAttribute(name)) {
+ int minheight = Int32FromNPVariant(*variant);
jam 2012/11/02 19:11:10 ditto
Fady Samuel 2012/11/02 20:32:23 Done.
+ bindings->instance()->SetMinHeightAttribute(minheight);
+ return true;
+ }
+
+ if (IdentifierIsMinWidthAttribute(name)) {
+ int minwidth = Int32FromNPVariant(*variant);
+ bindings->instance()->SetMinWidthAttribute(minwidth);
+ return true;
+ }
+
return false;
}

Powered by Google App Engine
This is Rietveld 408576698