]> khamidou — GitHub mirrors - electron.git/commitdiff
Load atom.js on startup.
authorCheng Zhao <zcbenz@gmail.com>
Sat, 13 Apr 2013 13:10:41 +0000 (21:10 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 13 Apr 2013 13:10:41 +0000 (21:10 +0800)
atom.gyp
browser/atom/atom.js [new file with mode: 0644]
browser/atom/atom_content_demo.js [new file with mode: 0644]
browser/atom/index.html [new file with mode: 0644]
browser/atom_browser_main_parts.cc
common/node_bindings.cc
common/node_bindings.h
vendor/node

index 48adf5f69215268ff352ee1a03c0437fe9fc97dd..fccacc4ef6c2dad0d6af8c9e7135b300611eed4b 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
                 '<(PRODUCT_DIR)/<(product_name).framework',
               ],
             },
+            {
+              'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
+              'files': [
+                'browser/atom',
+              ],
+            },
           ],
           'postbuilds': [
             {
diff --git a/browser/atom/atom.js b/browser/atom/atom.js
new file mode 100644 (file)
index 0000000..ab74fd7
--- /dev/null
@@ -0,0 +1 @@
+console.log(process.argv);
diff --git a/browser/atom/atom_content_demo.js b/browser/atom/atom_content_demo.js
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/browser/atom/index.html b/browser/atom/index.html
new file mode 100644 (file)
index 0000000..e69de29
index fc70e3df94d920cbc4a58dea6288711b2b16a84e..6d05af74668ac88b8f7161e5ca702b4154098895 100644 (file)
@@ -15,7 +15,7 @@
 namespace atom {
 
 AtomBrowserMainParts::AtomBrowserMainParts()
-    : node_bindings_(new NodeBindings) {
+    : node_bindings_(new NodeBindings(true)) {
 }
 
 AtomBrowserMainParts::~AtomBrowserMainParts() {
index f0a997ce9b9867efe05b95beaef6126fe09a4e90..bcca002da5893675d9690b0045fb290747c2fd2f 100644 (file)
@@ -5,6 +5,7 @@
 #include "common/node_bindings.h"
 
 #include "base/command_line.h"
+#include "base/files/file_path.h"
 #include "base/logging.h"
 #include "v8/include/v8.h"
 #include "vendor/node/src/node.h"
@@ -12,7 +13,8 @@
 
 namespace atom {
 
-NodeBindings::NodeBindings() {
+NodeBindings::NodeBindings(bool is_browser)
+    : is_browser_(is_browser) {
 }
 
 NodeBindings::~NodeBindings() {
@@ -23,10 +25,8 @@ void NodeBindings::Initialize() {
 
   // Convert string vector to char* array.
   std::vector<char*> argv(str_argv.size(), NULL);
-  for (size_t i = 0; i < str_argv.size(); ++i) {
-    LOG(ERROR) << str_argv[i];
+  for (size_t i = 0; i < str_argv.size(); ++i)
     argv[i] = const_cast<char*>(str_argv[i].c_str());
-  }
 
   // Init node.
   node::Init(argv.size(), &argv[0]);
@@ -39,8 +39,14 @@ void NodeBindings::Initialize() {
     v8::Context::Scope context_scope(node::g_context);
     v8::Handle<v8::Object> process = node::SetupProcessObject(
         argv.size(), &argv[0]);
+
+    // Tell node.js we are in browser or renderer.
+    v8::Handle<v8::String> type =
+        is_browser_ ? v8::String::New("browser") : v8::String::New("renderer");
+    process->Set(v8::String::New("__atom_type"), type);
+
     node::Load(process);
   }
 }
-  
-}  // namespace at
+
+}  // namespace atom
index 77d6f91b34b037ae84ce730dc06d3705269b1e08..c73e79844c188f9701be581531ba38587546aa69 100644 (file)
@@ -11,13 +11,15 @@ namespace atom {
 
 class NodeBindings {
  public:
-  NodeBindings();
+  NodeBindings(bool is_browser);
   virtual ~NodeBindings();
 
   // Setup everything including V8, libuv and node.js main script.
   void Initialize();
 
  private:
+  bool is_browser_;
+
   DISALLOW_COPY_AND_ASSIGN(NodeBindings);
 };
 
index 4ca67139123acff24c884377ebfd6f31eb4efa01..6dadfdb1f5fbaf0d7132fa2b4e4ed084bddead8a 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4ca67139123acff24c884377ebfd6f31eb4efa01
+Subproject commit 6dadfdb1f5fbaf0d7132fa2b4e4ed084bddead8a