Index: chrome/renderer/extensions/webstore_bindings.cc |
diff --git a/chrome/renderer/extensions/webstore_bindings.cc b/chrome/renderer/extensions/webstore_bindings.cc |
index 5991e6a3c11328a3e79d192a1f56b4b33a75ca94..7214db9c6de04649527ed36ab71f05a1eb7a489e 100644 |
--- a/chrome/renderer/extensions/webstore_bindings.cc |
+++ b/chrome/renderer/extensions/webstore_bindings.cc |
@@ -13,7 +13,6 @@ |
#include "grit/renderer_resources.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
#include "v8/include/v8.h" |
@@ -48,69 +47,17 @@ const char kInvalidWebstoreItemUrlError[] = |
// (successful or not) via OnInlineWebstoreInstallResponse. |
int g_next_install_id = 0; |
-class WebstoreBindingsHandler : public ChromeV8ExtensionHandler { |
- public: |
- WebstoreBindingsHandler( |
- ExtensionDispatcher* dispatcher, ChromeV8Context* context); |
- |
- // ChromeV8ExtensionHandler |
- virtual v8::Handle<v8::Value> HandleNativeFunction( |
- const std::string& name, |
- const v8::Arguments& arguments) OVERRIDE; |
- |
- // IPC::Channel::Listener |
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
- |
- private: |
- v8::Handle<v8::Value> Install(const v8::Arguments& args); |
- |
- void OnInlineWebstoreInstallResponse( |
- int install_id, bool success, const std::string& error); |
- |
- // Extracts a Web Store item ID from a <link rel="chrome-webstore-item" |
- // href="https://chrome.google.com/webstore/detail/id"> node found in the |
- // frame. On success, true will be returned and the |webstore_item_id| |
- // parameter will be populated with the ID. On failure, false will be returned |
- // and |error| will be populated with the error. |
- static bool GetWebstoreItemIdFromFrame( |
- WebFrame* frame, const std::string& preferred_store_link_url, |
- std::string* webstore_item_id, std::string* error); |
- |
- ExtensionDispatcher* dispatcher_; |
- DISALLOW_COPY_AND_ASSIGN(WebstoreBindingsHandler); |
-}; |
- |
} // anonymous namespace |
-WebstoreBindings::WebstoreBindings(ExtensionDispatcher* dispatcher) |
- : ChromeV8Extension("extensions/webstore.js", IDR_WEBSTORE_BINDINGS_JS, |
- dispatcher) { |
-} |
- |
-ChromeV8ExtensionHandler* WebstoreBindings::CreateHandler( |
- ChromeV8Context* context) { |
- return new WebstoreBindingsHandler(extension_dispatcher(), context); |
-} |
- |
-WebstoreBindingsHandler::WebstoreBindingsHandler( |
- ExtensionDispatcher* dispatcher, |
+WebstoreBindings::WebstoreBindings(ExtensionDispatcher* dispatcher, |
ChromeV8Context* context) |
- : ChromeV8ExtensionHandler(context), |
- dispatcher_(dispatcher) { |
-} |
- |
-v8::Handle<v8::Value> WebstoreBindingsHandler::HandleNativeFunction( |
- const std::string& name, const v8::Arguments& args) { |
- if (name == "Install") { |
- return Install(args); |
- } else { |
- CHECK(false) << "Unknown native function: " << name; |
- } |
- |
- return v8::Undefined(); |
+ : ChromeV8Extension(dispatcher), |
+ ChromeV8ExtensionHandler(context) { |
+ RouteFunction("Install", |
+ base::Bind(&WebstoreBindings::Install, base::Unretained(this))); |
} |
-v8::Handle<v8::Value> WebstoreBindingsHandler::Install( |
+v8::Handle<v8::Value> WebstoreBindings::Install( |
const v8::Arguments& args) { |
WebFrame* frame = WebFrame::frameForCurrentContext(); |
if (!frame || !frame->view()) |
@@ -161,7 +108,7 @@ v8::Handle<v8::Value> WebstoreBindingsHandler::Install( |
} |
// static |
-bool WebstoreBindingsHandler::GetWebstoreItemIdFromFrame( |
+bool WebstoreBindings::GetWebstoreItemIdFromFrame( |
WebFrame* frame, const std::string& preferred_store_link_url, |
std::string* webstore_item_id, std::string* error) { |
if (frame != frame->top()) { |
@@ -247,8 +194,8 @@ bool WebstoreBindingsHandler::GetWebstoreItemIdFromFrame( |
return false; |
} |
-bool WebstoreBindingsHandler::OnMessageReceived(const IPC::Message& message) { |
- IPC_BEGIN_MESSAGE_MAP(WebstoreBindingsHandler, message) |
+bool WebstoreBindings::OnMessageReceived(const IPC::Message& message) { |
+ IPC_BEGIN_MESSAGE_MAP(WebstoreBindings, message) |
IPC_MESSAGE_HANDLER(ExtensionMsg_InlineWebstoreInstallResponse, |
OnInlineWebstoreInstallResponse) |
IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") |
@@ -256,7 +203,7 @@ bool WebstoreBindingsHandler::OnMessageReceived(const IPC::Message& message) { |
return true; |
} |
-void WebstoreBindingsHandler::OnInlineWebstoreInstallResponse( |
+void WebstoreBindings::OnInlineWebstoreInstallResponse( |
int install_id, |
bool success, |
const std::string& error) { |