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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apitest.js Created 7 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/binding_generating_native_handler.cc
diff --git a/chrome/renderer/extensions/binding_generating_native_handler.cc b/chrome/renderer/extensions/binding_generating_native_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d04df4033d075e8cbfa2a3aef38af4901a3dbdac
--- /dev/null
+++ b/chrome/renderer/extensions/binding_generating_native_handler.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/binding_generating_native_handler.h"
+
+#include "chrome/renderer/extensions/module_system.h"
+#include "chrome/renderer/extensions/v8_schema_registry.h"
+
+namespace extensions {
+
+BindingGeneratingNativeHandler::BindingGeneratingNativeHandler(
+ ModuleSystem* module_system,
+ V8SchemaRegistry* schema_registry,
+ const std::string& api_name,
+ const std::string& bind_to)
+ : module_system_(module_system),
+ schema_registry_(schema_registry),
not at google - send to devlin 2013/02/13 01:45:49 schema_registry unused?
cduvall 2013/02/15 00:40:28 Done.
+ api_name_(api_name),
+ bind_to_(bind_to) {
+}
+
+v8::Handle<v8::Object> BindingGeneratingNativeHandler::NewInstance() {
+ v8::Handle<v8::Object> binding = v8::Handle<v8::Object>::Cast(
+ v8::Handle<v8::Object>::Cast(module_system_->Require(
+ "binding"))->Get(v8::String::New("Binding")));
+ v8::Handle<v8::Function> create = v8::Handle<v8::Function>::Cast(
+ binding->Get(v8::String::New("create")));
+ v8::Handle<v8::Value> argv[] = { v8::String::New(api_name_.c_str()) };
+ v8::Handle<v8::Object> binding_instance = v8::Handle<v8::Object>::Cast(
+ create->Call(binding, 1, argv));
+ v8::Handle<v8::Function> generate = v8::Handle<v8::Function>::Cast(
+ binding_instance->Get(v8::String::New("generate")));
+ v8::Handle<v8::Value> compiled_schema;
+ {
+ v8::TryCatch try_catch;
+ compiled_schema = generate->Call(binding_instance, 0, NULL);
+ if (try_catch.HasCaught()) {
+ module_system_->LogExceptionToConsole(try_catch);
not at google - send to devlin 2013/02/13 01:45:49 Doesn't seem like it should be module system's res
cduvall 2013/02/15 00:40:28 Now the exception is logged in binding.js.
+ return v8::Object::New();
+ }
+ }
+ v8::Handle<v8::Object> object = v8::Object::New();
+ object->Set(v8::String::New(bind_to_.c_str()), compiled_schema);
not at google - send to devlin 2013/02/13 01:45:49 I'll need to get koz@ to look at this, I think thi
koz (OOO until 15th September) 2013/02/14 06:21:13 You don't need to declare it a v8::Local, but it w
cduvall 2013/02/15 00:40:28 Done.
+ return object;
+}
+
+} // extensions

Powered by Google App Engine
This is Rietveld 408576698