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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/extensions/binding_generating_native_handler.h"
6
7 #include "chrome/renderer/extensions/module_system.h"
8 #include "chrome/renderer/extensions/v8_schema_registry.h"
9
10 namespace extensions {
11
12 BindingGeneratingNativeHandler::BindingGeneratingNativeHandler(
13 ModuleSystem* module_system,
14 V8SchemaRegistry* schema_registry,
15 const std::string& api_name,
16 const std::string& bind_to)
17 : module_system_(module_system),
18 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.
19 api_name_(api_name),
20 bind_to_(bind_to) {
21 }
22
23 v8::Handle<v8::Object> BindingGeneratingNativeHandler::NewInstance() {
24 v8::Handle<v8::Object> binding = v8::Handle<v8::Object>::Cast(
25 v8::Handle<v8::Object>::Cast(module_system_->Require(
26 "binding"))->Get(v8::String::New("Binding")));
27 v8::Handle<v8::Function> create = v8::Handle<v8::Function>::Cast(
28 binding->Get(v8::String::New("create")));
29 v8::Handle<v8::Value> argv[] = { v8::String::New(api_name_.c_str()) };
30 v8::Handle<v8::Object> binding_instance = v8::Handle<v8::Object>::Cast(
31 create->Call(binding, 1, argv));
32 v8::Handle<v8::Function> generate = v8::Handle<v8::Function>::Cast(
33 binding_instance->Get(v8::String::New("generate")));
34 v8::Handle<v8::Value> compiled_schema;
35 {
36 v8::TryCatch try_catch;
37 compiled_schema = generate->Call(binding_instance, 0, NULL);
38 if (try_catch.HasCaught()) {
39 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.
40 return v8::Object::New();
41 }
42 }
43 v8::Handle<v8::Object> object = v8::Object::New();
44 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.
45 return object;
46 }
47
48 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698