Separate AtomBindings for renderer.
This commit is contained in:
parent
2ba3ce740c
commit
a7c3bdbf5d
8 changed files with 68 additions and 26 deletions
2
atom.gyp
2
atom.gyp
|
@ -52,6 +52,8 @@
|
||||||
'common/options_switches.h',
|
'common/options_switches.h',
|
||||||
'common/v8_value_converter_impl.cc',
|
'common/v8_value_converter_impl.cc',
|
||||||
'common/v8_value_converter_impl.h',
|
'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.cc',
|
||||||
'renderer/atom_render_view_observer.h',
|
'renderer/atom_render_view_observer.h',
|
||||||
'renderer/atom_renderer_client.cc',
|
'renderer/atom_renderer_client.cc',
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "common/api/atom_bindings.h"
|
#include "common/api/atom_bindings.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
|
||||||
#include "vendor/node/src/node.h"
|
#include "vendor/node/src/node.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -72,20 +71,4 @@ v8::Handle<v8::Value> AtomBindings::Binding(const v8::Arguments& args) {
|
||||||
v8::String::New("No such module")));
|
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
|
} // namespace atom
|
||||||
|
|
|
@ -23,9 +23,6 @@ class AtomBindings {
|
||||||
// load native code from atom-shell instead.
|
// load native code from atom-shell instead.
|
||||||
virtual void BindTo(v8::Handle<v8::Object> process);
|
virtual void BindTo(v8::Handle<v8::Object> process);
|
||||||
|
|
||||||
// Call BindTo for process object of the frame.
|
|
||||||
void BindToFrame(WebKit::WebFrame* frame);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static v8::Handle<v8::Value> Binding(const v8::Arguments& args);
|
static v8::Handle<v8::Value> Binding(const v8::Arguments& args);
|
||||||
|
|
||||||
|
|
34
renderer/api/atom_renderer_bindings.cc
Normal file
34
renderer/api/atom_renderer_bindings.cc
Normal file
|
@ -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
|
26
renderer/api/atom_renderer_bindings.h
Normal file
26
renderer/api/atom_renderer_bindings.h
Normal file
|
@ -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 <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/api/atom_bindings.h"
|
|
||||||
#include "common/node_bindings.h"
|
#include "common/node_bindings.h"
|
||||||
|
#include "renderer/api/atom_renderer_bindings.h"
|
||||||
#include "renderer/atom_renderer_client.h"
|
#include "renderer/atom_renderer_client.h"
|
||||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#include "renderer/atom_renderer_client.h"
|
#include "renderer/atom_renderer_client.h"
|
||||||
|
|
||||||
#include "common/api/atom_bindings.h"
|
|
||||||
#include "common/node_bindings.h"
|
#include "common/node_bindings.h"
|
||||||
|
#include "renderer/api/atom_renderer_bindings.h"
|
||||||
#include "renderer/atom_render_view_observer.h"
|
#include "renderer/atom_render_view_observer.h"
|
||||||
#include "vendor/node/src/node_internals.h"
|
#include "vendor/node/src/node_internals.h"
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ extern void SetNodeContext(v8::Persistent<v8::Context> context);
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
AtomRendererClient::AtomRendererClient()
|
AtomRendererClient::AtomRendererClient()
|
||||||
: atom_bindings_(new AtomBindings),
|
: atom_bindings_(new AtomRendererBindings),
|
||||||
node_bindings_(NodeBindings::Create(false)) {
|
node_bindings_(NodeBindings::Create(false)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class AtomBindings;
|
class AtomRendererBindings;
|
||||||
class NodeBindings;
|
class NodeBindings;
|
||||||
|
|
||||||
class AtomRendererClient : public content::ContentRendererClient {
|
class AtomRendererClient : public content::ContentRendererClient {
|
||||||
|
@ -17,14 +17,14 @@ class AtomRendererClient : public content::ContentRendererClient {
|
||||||
AtomRendererClient();
|
AtomRendererClient();
|
||||||
virtual ~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(); }
|
NodeBindings* node_bindings() const { return node_bindings_.get(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void RenderThreadStarted() OVERRIDE;
|
virtual void RenderThreadStarted() OVERRIDE;
|
||||||
virtual void RenderViewCreated(content::RenderView*) OVERRIDE;
|
virtual void RenderViewCreated(content::RenderView*) OVERRIDE;
|
||||||
|
|
||||||
scoped_ptr<AtomBindings> atom_bindings_;
|
scoped_ptr<AtomRendererBindings> atom_bindings_;
|
||||||
scoped_ptr<NodeBindings> node_bindings_;
|
scoped_ptr<NodeBindings> node_bindings_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
|
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue