]> khamidou — GitHub mirrors - electron.git/commitdiff
Show chromium's version in user agent, fixes #428.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 25 Jun 2014 01:05:10 +0000 (09:05 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 25 Jun 2014 01:05:10 +0000 (09:05 +0800)
atom/browser/native_window.cc
atom/common/chrome_version.h [new file with mode: 0644]
script/bootstrap.py
script/chrome_version.h.in [new file with mode: 0644]

index fc907af67a82f550212015d77c66d2f2820a0f67..6b1ccd6ce95459607a31bf1de90aa2cfdc4a8a79 100644 (file)
@@ -16,6 +16,7 @@
 #include "atom/browser/window_list.h"
 #include "atom/common/api/api_messages.h"
 #include "atom/common/atom_version.h"
+#include "atom/common/chrome_version.h"
 #include "atom/common/native_mate_converters/image_converter.h"
 #include "atom/common/native_mate_converters/file_path_converter.h"
 #include "atom/common/options_switches.h"
@@ -99,9 +100,10 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
   // Override the user agent to contain application and atom-shell's version.
   Browser* browser = Browser::Get();
   std::string product_name = base::StringPrintf(
-      "%s/%s Atom-Shell/" ATOM_VERSION_STRING,
+      "%s/%s Chrome/%s Atom-Shell/" ATOM_VERSION_STRING,
       browser->GetName().c_str(),
-      browser->GetVersion().c_str());
+      browser->GetVersion().c_str(),
+      CHROME_VERSION_STRING);
   web_contents->GetMutableRendererPrefs()->user_agent_override =
       webkit_glue::BuildUserAgentFromProduct(product_name);
 
diff --git a/atom/common/chrome_version.h b/atom/common/chrome_version.h
new file mode 100644 (file)
index 0000000..fcbf468
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+// This file is generated by script/bootstrap.py, you should never modify it
+// by hand.
+
+#ifndef ATOM_COMMON_CHROME_VERSION_H_
+#define ATOM_COMMON_CHROME_VERSION_H_
+
+#define CHROME_VERSION_STRING "31.0.1650.57"
+#define CHROME_VERSION "v" CHROME_VERSION_STRING
+
+#endif  // ATOM_COMMON_CHROME_VERSION_H_
index 87e5b9e046a0834f378bd55caf5c529752b45e55..fb32a9758c4813a02f2a2af37f3a3d70da05f318 100755 (executable)
@@ -28,6 +28,7 @@ def main():
   if sys.platform in ['win32', 'cygwin']:
     install_runas()
 
+  create_chrome_version_h()
   touch_config_gypi()
   update_atom_shell()
 
@@ -81,6 +82,22 @@ def install_runas():
     execute([NPM, 'install', 'runas'])
 
 
+def create_chrome_version_h():
+  version_file = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor',
+                              'libchromiumcontent', 'VERSION')
+  target_file = os.path.join(SOURCE_ROOT, 'atom', 'common', 'chrome_version.h')
+  template_file = os.path.join(SOURCE_ROOT, 'script', 'chrome_version.h.in')
+
+  with open(version_file, 'r') as f:
+    version = f.read()
+  with open(template_file, 'r') as f:
+    template = f.read()
+  with open(target_file, 'w+') as f:
+    content = template.replace('{PLACEHOLDER}', version.strip())
+    if f.read() != content:
+      f.write(content)
+
+
 def touch_config_gypi():
   config_gypi = os.path.join(SOURCE_ROOT, 'vendor', 'node', 'config.gypi')
   with open(config_gypi, 'w+') as f:
diff --git a/script/chrome_version.h.in b/script/chrome_version.h.in
new file mode 100644 (file)
index 0000000..b048874
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright (c) 2014 GitHub, Inc. All rights reserved.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+// This file is generated by script/bootstrap.py, you should never modify it
+// by hand.
+
+#ifndef ATOM_COMMON_CHROME_VERSION_H_
+#define ATOM_COMMON_CHROME_VERSION_H_
+
+#define CHROME_VERSION_STRING "{PLACEHOLDER}"
+#define CHROME_VERSION "v" CHROME_VERSION_STRING
+
+#endif  // ATOM_COMMON_CHROME_VERSION_H_