зеркало из https://github.com/electron/electron.git
Separate AtomBindings for renderer.
This commit is contained in:
Родитель
2ba3ce740c
Коммит
a7c3bdbf5d
2
atom.gyp
2
atom.gyp
|
@ -52,6 +52,8 @@
|
|||
'common/options_switches.h',
|
||||
'common/v8_value_converter_impl.cc',
|
||||
'common/v8_value_converter_impl.h',
|
||||
'renderer/api/atom_renderer_bindings.cc',
|
||||
'renderer/api/atom_renderer_bindings.h',
|
||||
'renderer/atom_render_view_observer.cc',
|
||||
'renderer/atom_render_view_observer.h',
|
||||
'renderer/atom_renderer_client.cc',
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "common/api/atom_bindings.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -72,20 +71,4 @@ v8::Handle<v8::Value> AtomBindings::Binding(const v8::Arguments& args) {
|
|||
v8::String::New("No such module")));
|
||||
}
|
||||
|
||||
void AtomBindings::BindToFrame(WebKit::WebFrame* frame) {
|
||||
v8::HandleScope handle_scope;
|
||||
|
||||
v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
|
||||
if (context.IsEmpty())
|
||||
return;
|
||||
|
||||
v8::Context::Scope scope(context);
|
||||
|
||||
v8::Handle<v8::Object> process =
|
||||
context->Global()->Get(v8::String::New("process"))->ToObject();
|
||||
DCHECK(!process.IsEmpty());
|
||||
|
||||
AtomBindings::BindTo(process);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -23,9 +23,6 @@ class AtomBindings {
|
|||
// load native code from atom-shell instead.
|
||||
virtual void BindTo(v8::Handle<v8::Object> process);
|
||||
|
||||
// Call BindTo for process object of the frame.
|
||||
void BindToFrame(WebKit::WebFrame* frame);
|
||||
|
||||
private:
|
||||
static v8::Handle<v8::Value> Binding(const v8::Arguments& args);
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// 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 "renderer/api/atom_renderer_bindings.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
AtomRendererBindings::AtomRendererBindings() {
|
||||
}
|
||||
|
||||
AtomRendererBindings::~AtomRendererBindings() {
|
||||
}
|
||||
|
||||
void AtomRendererBindings::BindToFrame(WebKit::WebFrame* frame) {
|
||||
v8::HandleScope handle_scope;
|
||||
|
||||
v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
|
||||
if (context.IsEmpty())
|
||||
return;
|
||||
|
||||
v8::Context::Scope scope(context);
|
||||
|
||||
v8::Handle<v8::Object> process =
|
||||
context->Global()->Get(v8::String::New("process"))->ToObject();
|
||||
DCHECK(!process.IsEmpty());
|
||||
|
||||
AtomBindings::BindTo(process);
|
||||
}
|
||||
|
||||
} // namespace atom
|
|
@ -0,0 +1,26 @@
|
|||
// 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.
|
||||
|
||||
#ifndef ATOM_RENDERER_API_ATOM_RENDERER_BINDINGS_
|
||||
#define ATOM_RENDERER_API_ATOM_RENDERER_BINDINGS_
|
||||
|
||||
#include "common/api/atom_bindings.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class AtomRendererBindings : public AtomBindings {
|
||||
public:
|
||||
AtomRendererBindings();
|
||||
virtual ~AtomRendererBindings();
|
||||
|
||||
// Call BindTo for process object of the frame.
|
||||
void BindToFrame(WebKit::WebFrame* frame);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRendererBindings);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_RENDERER_API_ATOM_BINDINGS_
|
|
@ -7,8 +7,8 @@
|
|||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "common/api/atom_bindings.h"
|
||||
#include "common/node_bindings.h"
|
||||
#include "renderer/api/atom_renderer_bindings.h"
|
||||
#include "renderer/atom_renderer_client.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include "renderer/atom_renderer_client.h"
|
||||
|
||||
#include "common/api/atom_bindings.h"
|
||||
#include "common/node_bindings.h"
|
||||
#include "renderer/api/atom_renderer_bindings.h"
|
||||
#include "renderer/atom_render_view_observer.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
|
@ -16,7 +16,7 @@ extern void SetNodeContext(v8::Persistent<v8::Context> context);
|
|||
namespace atom {
|
||||
|
||||
AtomRendererClient::AtomRendererClient()
|
||||
: atom_bindings_(new AtomBindings),
|
||||
: atom_bindings_(new AtomRendererBindings),
|
||||
node_bindings_(NodeBindings::Create(false)) {
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
class AtomBindings;
|
||||
class AtomRendererBindings;
|
||||
class NodeBindings;
|
||||
|
||||
class AtomRendererClient : public content::ContentRendererClient {
|
||||
|
@ -17,14 +17,14 @@ class AtomRendererClient : public content::ContentRendererClient {
|
|||
AtomRendererClient();
|
||||
virtual ~AtomRendererClient();
|
||||
|
||||
AtomBindings* atom_bindings() const { return atom_bindings_.get(); }
|
||||
AtomRendererBindings* atom_bindings() const { return atom_bindings_.get(); }
|
||||
NodeBindings* node_bindings() const { return node_bindings_.get(); }
|
||||
|
||||
private:
|
||||
virtual void RenderThreadStarted() OVERRIDE;
|
||||
virtual void RenderViewCreated(content::RenderView*) OVERRIDE;
|
||||
|
||||
scoped_ptr<AtomBindings> atom_bindings_;
|
||||
scoped_ptr<AtomRendererBindings> atom_bindings_;
|
||||
scoped_ptr<NodeBindings> node_bindings_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
|
||||
|
|
Загрузка…
Ссылка в новой задаче