]> khamidou — GitHub mirrors - electron.git/commitdiff
Set google API key
authorCheng Zhao <zcbenz@gmail.com>
Wed, 8 Oct 2014 10:27:39 +0000 (18:27 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 8 Oct 2014 10:27:39 +0000 (18:27 +0800)
atom.gyp
atom/app/atom_main_delegate.cc
atom/browser/atom_access_token_store.cc
atom/common/google_api_key.h [new file with mode: 0644]

index 8cc769bf44ab69b8b21192acc00260d3af0165a2..b2856bb852dca411f0d1da2496e452d4accdd89b 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
       'atom/common/crash_reporter/win/crash_service_main.h',
       'atom/common/draggable_region.cc',
       'atom/common/draggable_region.h',
+      'atom/common/google_api_key.h',
       'atom/common/linux/application_info.cc',
       'atom/common/native_mate_converters/accelerator_converter.cc',
       'atom/common/native_mate_converters/accelerator_converter.h',
index 34d434fc77e4f601c4f6a6ffa4646f9c4e94e2ff..c3d537250c2a92e6288ffed76bc7721b2c2d2290 100644 (file)
@@ -8,9 +8,11 @@
 
 #include "atom/app/atom_content_client.h"
 #include "atom/browser/atom_browser_client.h"
+#include "atom/common/google_api_key.h"
 #include "atom/renderer/atom_renderer_client.h"
 #include "base/command_line.h"
 #include "base/debug/stack_trace.h"
+#include "base/environment.h"
 #include "base/logging.h"
 #include "content/public/common/content_switches.h"
 #include "ui/base/resource/resource_bundle.h"
@@ -52,6 +54,11 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
 void AtomMainDelegate::PreSandboxStartup() {
   brightray::MainDelegate::PreSandboxStartup();
 
+  // Set google API key.
+  scoped_ptr<base::Environment> env(base::Environment::Create());
+  if (!env->HasVar("GOOGLE_API_KEY"))
+    env->SetVar("GOOGLE_API_KEY", GOOGLEAPIS_API_KEY);
+
   CommandLine* command_line = CommandLine::ForCurrentProcess();
   std::string process_type = command_line->GetSwitchValueASCII(
       switches::kProcessType);
index 653c37a0019136baf8beec9027d6d46d284fbbab..40dc9184f55d5cbf40e1ddc54c575dcf75915293 100644 (file)
@@ -7,10 +7,7 @@
 #include <utility>
 
 #include "atom/browser/atom_browser_context.h"
-
-#ifndef GOOGLEAPIS_API_KEY
-#define GOOGLEAPIS_API_KEY "AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q"
-#endif
+#include "atom/common/google_api_key.h"
 
 namespace atom {
 
diff --git a/atom/common/google_api_key.h b/atom/common/google_api_key.h
new file mode 100644 (file)
index 0000000..c332654
--- /dev/null
@@ -0,0 +1,12 @@
+// 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.
+
+#ifndef ATOM_COMMON_GOOGLE_API_KEY_H_
+#define ATOM_COMMON_GOOGLE_API_KEY_H_
+
+#ifndef GOOGLEAPIS_API_KEY
+#define GOOGLEAPIS_API_KEY "AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q"
+#endif
+
+#endif  // ATOM_COMMON_GOOGLE_API_KEY_H_