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

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: BrowserPluginHostMsg_AutoSize_Params had an int instead of bool for enable: fixed 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..13be91ae6ed0765f80d1d2865c56b2de1a40011a 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,
@@ -163,7 +193,7 @@ bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
return false;
if (IdentifierIsSrcAttribute(name)) {
- std::string src = bindings->instance()->GetSrcAttribute();
+ std::string src = bindings->instance()->src_attribute();
return StringToNPVariant(src, result);
}
@@ -176,6 +206,36 @@ bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
return true;
}
+ if (IdentifierIsAutoSizeAttribute(name)) {
+ bool autosize = bindings->instance()->auto_size_attribute();
+ BOOLEAN_TO_NPVARIANT(autosize, *result);
+ return true;
+ }
+
+ if (IdentifierIsMaxHeightAttribute(name)) {
+ int max_height = bindings->instance()->max_height_attribute();
+ INT32_TO_NPVARIANT(max_height, *result);
+ return true;
+ }
+
+ if (IdentifierIsMaxWidthAttribute(name)) {
+ int max_width = bindings->instance()->max_width_attribute();
+ INT32_TO_NPVARIANT(max_width, *result);
+ return true;
+ }
+
+ if (IdentifierIsMinHeightAttribute(name)) {
+ int min_height = bindings->instance()->min_height_attribute();
+ INT32_TO_NPVARIANT(min_height, *result);
+ return true;
+ }
+
+ if (IdentifierIsMinWidthAttribute(name)) {
+ int min_width = bindings->instance()->min_width_attribute();
+ INT32_TO_NPVARIANT(min_width, *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 max_height = Int32FromNPVariant(*variant);
+ bindings->instance()->SetMaxHeightAttribute(max_height);
+ return true;
+ }
+
+ if (IdentifierIsMaxWidthAttribute(name)) {
+ int max_width = Int32FromNPVariant(*variant);
+ bindings->instance()->SetMaxWidthAttribute(max_width);
+ return true;
+ }
+
+ if (IdentifierIsMinHeightAttribute(name)) {
+ int min_height = Int32FromNPVariant(*variant);
+ bindings->instance()->SetMinHeightAttribute(min_height);
+ return true;
+ }
+
+ if (IdentifierIsMinWidthAttribute(name)) {
+ int min_width = Int32FromNPVariant(*variant);
+ bindings->instance()->SetMinWidthAttribute(min_width);
+ 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