From ea1927f428dafb951e18f9c71454a3ea3274c63a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 20 Sep 2016 13:24:45 -0700 Subject: [PATCH] Store api_key_ on TokenLoadingJob --- atom/browser/atom_access_token_store.cc | 10 ++++++---- atom/browser/atom_access_token_store.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/atom/browser/atom_access_token_store.cc b/atom/browser/atom_access_token_store.cc index 0ad637d7afa3..b4e19086d4c2 100644 --- a/atom/browser/atom_access_token_store.cc +++ b/atom/browser/atom_access_token_store.cc @@ -4,6 +4,7 @@ #include "atom/browser/atom_access_token_store.h" +#include #include #include "atom/browser/atom_browser_context.h" @@ -43,10 +44,13 @@ class TokenLoadingJob : public base::RefCountedThreadSafe { DCHECK_CURRENTLY_ON(BrowserThread::UI); auto browser_context = AtomBrowserContext::From("", false); request_context_getter_ = browser_context->GetRequestContext(); + std::unique_ptr env(base::Environment::Create()); + if (!env->GetVar("GOOGLE_API_KEY", &api_key_)) + api_key_ = GOOGLEAPIS_API_KEY; } void RespondOnOriginatingThread() { - // Equivelent to access_token_map[kGeolocationProviderURL]. + // Equivalent to access_token_map[kGeolocationProviderURL]. // Somehow base::string16 is causing compilation errors when used in a pair // of std::map on Linux, this can work around it. content::AccessTokenStore::AccessTokenMap access_token_map; @@ -59,15 +63,13 @@ class TokenLoadingJob : public base::RefCountedThreadSafe { content::AccessTokenStore::LoadAccessTokensCallback callback_; net::URLRequestContextGetter* request_context_getter_; + std::string api_key_; }; } // namespace AtomAccessTokenStore::AtomAccessTokenStore() { content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices(); - std::unique_ptr env(base::Environment::Create()); - if (!env->GetVar("GOOGLE_API_KEY", &api_key_)) - api_key_ = GOOGLEAPIS_API_KEY; } AtomAccessTokenStore::~AtomAccessTokenStore() { diff --git a/atom/browser/atom_access_token_store.h b/atom/browser/atom_access_token_store.h index dccbe3f5c4d0..d70d44a0cd3e 100644 --- a/atom/browser/atom_access_token_store.h +++ b/atom/browser/atom_access_token_store.h @@ -21,7 +21,6 @@ class AtomAccessTokenStore : public content::AccessTokenStore { const base::string16& access_token) override; private: - std::string api_key_; DISALLOW_COPY_AND_ASSIGN(AtomAccessTokenStore); };