Separate AtomBindings for renderer.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 22 Apr 2013 08:27:34 +0000 (16:27 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 22 Apr 2013 08:27:52 +0000 (16:27 +0800)
atom.gyp
common/api/atom_bindings.cc
common/api/atom_bindings.h
renderer/api/atom_renderer_bindings.cc [new file with mode: 0644]
renderer/api/atom_renderer_bindings.h [new file with mode: 0644]
renderer/atom_render_view_observer.cc
renderer/atom_renderer_client.cc
renderer/atom_renderer_client.h

index 0f3b3ed..8182e82 100644 (file)
--- a/atom.gyp
+++ b/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',
index 75f589e..bbaf0e5 100644 (file)
@@ -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
index e778fa5..fac8c2f 100644 (file)
@@ -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);
 
diff --git a/renderer/api/atom_renderer_bindings.cc b/renderer/api/atom_renderer_bindings.cc
new file mode 100644 (file)
index 0000000..3b2a600
--- /dev/null
@@ -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
diff --git a/renderer/api/atom_renderer_bindings.h b/renderer/api/atom_renderer_bindings.h
new file mode 100644 (file)
index 0000000..1c18d03
--- /dev/null
@@ -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_
index 615434c..e9e5fbe 100644 (file)
@@ -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"
index 1029bdb..8e27865 100644 (file)
@@ -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)) {
 }
 
index 2cc0716..9ebd375 100644 (file)
@@ -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);