Share same native bindings code on both renderer and browser.
This commit is contained in:
parent
993cf1cc61
commit
5948bff23f
16 changed files with 206 additions and 122 deletions
38
browser/api/atom_browser_bindings.cc
Normal file
38
browser/api/atom_browser_bindings.cc
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "browser/api/atom_browser_bindings.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
using node::node_isolate;
|
||||
|
||||
namespace atom {
|
||||
|
||||
AtomBrowserBindings::AtomBrowserBindings() {
|
||||
}
|
||||
|
||||
AtomBrowserBindings::~AtomBrowserBindings() {
|
||||
}
|
||||
|
||||
void AtomBrowserBindings::AfterLoad() {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
||||
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Handle<v8::Object> global = node::g_context->Global();
|
||||
v8::Handle<v8::Object> atom =
|
||||
global->Get(v8::String::New("__atom"))->ToObject();
|
||||
DCHECK(!atom.IsEmpty());
|
||||
|
||||
browser_main_parts_ = v8::Persistent<v8::Object>::New(
|
||||
node_isolate,
|
||||
atom->Get(v8::String::New("browserMainParts"))->ToObject());
|
||||
DCHECK(!browser_main_parts_.IsEmpty());
|
||||
}
|
||||
|
||||
} // namespace atom
|
Loading…
Add table
Add a link
Reference in a new issue