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

Unified Diff: chrome/renderer/extensions/chrome_webstore_bindings.cc

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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: chrome/renderer/extensions/chrome_webstore_bindings.cc
diff --git a/chrome/renderer/extensions/chrome_webstore_bindings.cc b/chrome/renderer/extensions/chrome_webstore_bindings.cc
index 9f8ed4f1a62687ef41a1cb7df6543fad292586db..f3f1b6f3999a94bfc2d41ac6e7e3bf25a8c7c91b 100644
--- a/chrome/renderer/extensions/chrome_webstore_bindings.cc
+++ b/chrome/renderer/extensions/chrome_webstore_bindings.cc
@@ -7,10 +7,12 @@
#include "base/lazy_instance.h"
#include "base/string_util.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/renderer/extensions/chrome_v8_extension.h"
#include "chrome/renderer/extensions/extension_helper.h"
#include "chrome/renderer/weak_v8_function_map.h"
#include "content/public/renderer/render_view.h"
#include "googleurl/src/gurl.h"
+#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"
@@ -24,6 +26,8 @@ using WebKit::WebFrame;
using WebKit::WebNode;
using WebKit::WebNodeList;
+class ExtensionDispatcher;
+
namespace {
const char kWebstoreV8ExtensionName[] = "v8/ChromeWebstore";
@@ -57,27 +61,14 @@ base::LazyInstance<WeakV8FunctionMap> g_failure_callbacks =
} // anonymous namespace
-class ExtensionImpl : public v8::Extension {
+class ExtensionImpl : public ChromeV8Extension {
public:
- ExtensionImpl() :
- v8::Extension(
- kWebstoreV8ExtensionName,
- "var chrome = chrome || {};"
- "if (!chrome.webstore) {"
- " chrome.webstore = new function() {"
- " native function Install(preferredStoreUrl, onSuccess, onFailure);"
- " this.install = Install;"
- " };"
- "}") {
- }
+ explicit ExtensionImpl(ExtensionDispatcher* dispatcher) :
+ ChromeV8Extension(kWebstoreV8ExtensionName, IDR_WEBSTORE_BINDINGS_JS,
+ dispatcher) {}
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
- v8::Handle<v8::String> name) {
- if (name->Equals(v8::String::New("Install"))) {
- return v8::FunctionTemplate::New(Install);
- } else {
- return v8::Handle<v8::FunctionTemplate>();
- }
+ virtual void SetNativeFunctions(v8::Handle<v8::Object> object) OVERRIDE {
+ RouteFunctionToStatic("WebStoreInstall", Install, object);
}
static v8::Handle<v8::Value> Install(const v8::Arguments& args) {
@@ -226,8 +217,9 @@ class ExtensionImpl : public v8::Extension {
};
// static
-v8::Extension* ChromeWebstoreExtension::Get() {
- return new ExtensionImpl();
+ChromeV8Extension* ChromeWebstoreExtension::Get(
+ ExtensionDispatcher* dispatcher) {
+ return new ExtensionImpl(dispatcher);
}
// static

Powered by Google App Engine
This is Rietveld 408576698