refactor: remove hardcoded google api key (#15478)

* refactor: remove hardcoded Google API key

* address changes from review
This commit is contained in:
Shelley Vohr 2018-10-31 07:49:44 -07:00 коммит произвёл GitHub
Родитель 86064a7bd8
Коммит b2e1a93177
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 5 добавлений и 29 удалений

Просмотреть файл

@ -11,7 +11,6 @@
#include "atom/app/atom_content_client.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/relauncher.h"
#include "atom/common/google_api_key.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/atom_renderer_client.h"
#include "atom/renderer/atom_sandboxed_renderer_client.h"

Просмотреть файл

@ -31,7 +31,6 @@
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/window_list.h"
#include "atom/common/google_api_key.h"
#include "atom/common/options_switches.h"
#include "atom/common/platform_util.h"
#include "base/command_line.h"
@ -428,11 +427,11 @@ void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
#endif
}
// attempt to get api key from env
std::string AtomBrowserClient::GetGeolocationApiKey() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
std::string api_key;
if (!env->GetVar("GOOGLE_API_KEY", &api_key))
api_key = GOOGLEAPIS_API_KEY;
env->GetVar("GOOGLE_API_KEY", &api_key);
return api_key;
}

Просмотреть файл

@ -1,17 +0,0 @@
// Copyright (c) 2014 GitHub, Inc.
// 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_ENDPOINT
#define GOOGLEAPIS_ENDPOINT \
"https://www.googleapis.com/geolocation/v1/geolocate?key="
#endif
#ifndef GOOGLEAPIS_API_KEY
#define GOOGLEAPIS_API_KEY "AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q"
#endif
#endif // ATOM_COMMON_GOOGLE_API_KEY_H_

Просмотреть файл

@ -48,20 +48,16 @@ Unsupported options are:
### `GOOGLE_API_KEY`
Electron includes a hardcoded API key for making requests to Google's geocoding
webservice. Because this API key is included in every version of Electron, it
often exceeds its usage quota. To work around this, you can supply your own
Google API key in the environment. Place the following code in your main process
You can provide an API key for making requests to Google's geocoding webservice. To do this, place the following code in your main process
file, before opening any browser windows that will make geocoding requests:
```javascript
process.env.GOOGLE_API_KEY = 'YOUR_KEY_HERE'
```
For instructions on how to acquire a Google API key, visit [this page](https://www.chromium.org/developers/how-tos/api-keys).
For instructions on how to acquire a Google API key, visit [this page](https://developers.google.com/maps/documentation/javascript/get-api-key).
By default, a newly generated Google API key may not be allowed to make
geocoding requests. To enable geocoding requests, visit [this page](https://console.developers.google.com/apis/api/geolocation/overview).
geocoding requests. To enable geocoding requests, visit [this page](https://developers.google.com/maps/documentation/geocoding/get-api-key).
### `ELECTRON_NO_ASAR`

Просмотреть файл

@ -576,7 +576,6 @@ filenames = {
"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/heap_snapshot.cc",
"atom/common/heap_snapshot.h",
"atom/common/key_weak_map.h",