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

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

Issue 10960003: Browser Plugin: Implement Back, Forward, and Go. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT 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
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | content/test/data/browser_plugin_embedder.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 67a0552b362a426f077184526b55ff7c2daa61b9..2e6fafc39b20997773b3a8c37a4f753445f968c3 100644
--- a/content/renderer/browser_plugin/browser_plugin_bindings.cc
+++ b/content/renderer/browser_plugin/browser_plugin_bindings.cc
@@ -8,7 +8,6 @@
#include <string>
#include "base/bind.h"
-#include "base/logging.h"
#include "base/message_loop.h"
#include "base/string16.h"
#include "base/string_split.h"
@@ -39,7 +38,10 @@ namespace content {
namespace {
const char kAddEventListener[] = "addEventListener";
+const char kBackMethod[] = "back";
+const char kForwardMethod[] = "forward";
const char kGetProcessId[] = "getProcessId";
+const char kGoMethod[] = "go";
const char kPartitionAttribute[] = "partition";
const char kReloadMethod[] = "reload";
const char kRemoveEventListener[] = "removeEventListener";
@@ -63,6 +65,18 @@ bool IdentifierIsAddEventListener(NPIdentifier identifier) {
return WebBindings::getStringIdentifier(kAddEventListener) == identifier;
}
+bool IdentifierIsBackMethod(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kBackMethod) == identifier;
+}
+
+bool IdentifierIsForwardMethod(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kForwardMethod) == identifier;
+}
+
+bool IdentifierIsGoMethod(NPIdentifier identifier) {
+ return WebBindings::getStringIdentifier(kGoMethod) == identifier;
+}
+
bool IdentifierIsRemoveEventListener(NPIdentifier identifier) {
return WebBindings::getStringIdentifier(kRemoveEventListener) == identifier;
}
@@ -79,6 +93,16 @@ bool IdentifierIsPartitionAttribute(NPIdentifier identifier) {
return WebBindings::getStringIdentifier(kPartitionAttribute) == identifier;
}
+int Int32FromNPVariant(const NPVariant& variant) {
+ if (NPVARIANT_IS_INT32(variant))
+ return NPVARIANT_TO_INT32(variant);
+
+ if (NPVARIANT_IS_DOUBLE(variant))
+ return NPVARIANT_TO_DOUBLE(variant);
+
+ return 0;
+}
+
std::string StringFromNPVariant(const NPVariant& variant) {
if (!NPVARIANT_IS_STRING(variant))
return std::string();
@@ -129,9 +153,18 @@ bool BrowserPluginBindingsHasMethod(NPObject* np_obj, NPIdentifier name) {
if (IdentifierIsAddEventListener(name))
return true;
+ if (IdentifierIsBackMethod(name))
+ return true;
+
+ if (IdentifierIsForwardMethod(name))
+ return true;
+
if (IdentifierIsGetProcessID(name))
return true;
+ if (IdentifierIsGoMethod(name))
+ return true;
+
if (IdentifierIsReload(name))
return true;
@@ -168,6 +201,16 @@ bool BrowserPluginBindingsInvoke(NPObject* np_obj, NPIdentifier name,
return bindings->instance()->AddEventListener(event_name, function);
}
+ if (IdentifierIsBackMethod(name) && !arg_count) {
+ bindings->instance()->Back();
+ return true;
+ }
+
+ if (IdentifierIsForwardMethod(name) && !arg_count) {
+ bindings->instance()->Forward();
+ return true;
+ }
+
if (IdentifierIsGetProcessID(name) && !arg_count) {
int process_id = bindings->instance()->process_id();
result->type = NPVariantType_Int32;
@@ -175,6 +218,11 @@ bool BrowserPluginBindingsInvoke(NPObject* np_obj, NPIdentifier name,
return true;
}
+ if (IdentifierIsGoMethod(name) && arg_count == 1) {
+ bindings->instance()->Go(Int32FromNPVariant(args[0]));
+ return true;
+ }
+
if (IdentifierIsReload(name) && !arg_count) {
bindings->instance()->Reload();
return true;
@@ -224,10 +272,6 @@ bool BrowserPluginBindingsGetProperty(NPObject* np_obj, NPIdentifier name,
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);
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | content/test/data/browser_plugin_embedder.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698