Share same native bindings code on both renderer and browser.

This commit is contained in:
Cheng Zhao 2013-04-21 14:53:26 +08:00
parent 993cf1cc61
commit 5948bff23f
16 changed files with 206 additions and 122 deletions

View file

@ -7,6 +7,7 @@
#include <algorithm>
#include <vector>
#include "common/api/atom_bindings.h"
#include "common/node_bindings.h"
#include "renderer/atom_renderer_client.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
@ -67,6 +68,7 @@ void AtomRenderViewObserver::DidClearWindowObject(WebFrame* frame) {
web_frames().push_back(frame);
renderer_client_->node_bindings()->BindTo(frame);
renderer_client_->atom_bindings()->BindToFrame(frame);
}
void AtomRenderViewObserver::FrameWillClose(WebFrame* frame) {

View file

@ -4,6 +4,7 @@
#include "renderer/atom_renderer_client.h"
#include "common/api/atom_bindings.h"
#include "common/node_bindings.h"
#include "renderer/atom_render_view_observer.h"
#include "vendor/node/src/node_internals.h"
@ -15,7 +16,8 @@ extern void SetNodeContext(v8::Persistent<v8::Context> context);
namespace atom {
AtomRendererClient::AtomRendererClient()
: node_bindings_(NodeBindings::Create(false)) {
: atom_bindings_(new AtomBindings),
node_bindings_(NodeBindings::Create(false)) {
}
AtomRendererClient::~AtomRendererClient() {

View file

@ -9,6 +9,7 @@
namespace atom {
class AtomBindings;
class NodeBindings;
class AtomRendererClient : public content::ContentRendererClient {
@ -16,12 +17,14 @@ class AtomRendererClient : public content::ContentRendererClient {
AtomRendererClient();
virtual ~AtomRendererClient();
AtomBindings* 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<NodeBindings> node_bindings_;
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);