Store api_key_ on TokenLoadingJob
This commit is contained in:
parent
fa2aaa48b1
commit
ea1927f428
2 changed files with 6 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "atom/browser/atom_access_token_store.h"
|
#include "atom/browser/atom_access_token_store.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "atom/browser/atom_browser_context.h"
|
#include "atom/browser/atom_browser_context.h"
|
||||||
|
@ -43,10 +44,13 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||||
auto browser_context = AtomBrowserContext::From("", false);
|
auto browser_context = AtomBrowserContext::From("", false);
|
||||||
request_context_getter_ = browser_context->GetRequestContext();
|
request_context_getter_ = browser_context->GetRequestContext();
|
||||||
|
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||||
|
if (!env->GetVar("GOOGLE_API_KEY", &api_key_))
|
||||||
|
api_key_ = GOOGLEAPIS_API_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RespondOnOriginatingThread() {
|
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
|
// Somehow base::string16 is causing compilation errors when used in a pair
|
||||||
// of std::map on Linux, this can work around it.
|
// of std::map on Linux, this can work around it.
|
||||||
content::AccessTokenStore::AccessTokenMap access_token_map;
|
content::AccessTokenStore::AccessTokenMap access_token_map;
|
||||||
|
@ -59,15 +63,13 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||||
|
|
||||||
content::AccessTokenStore::LoadAccessTokensCallback callback_;
|
content::AccessTokenStore::LoadAccessTokensCallback callback_;
|
||||||
net::URLRequestContextGetter* request_context_getter_;
|
net::URLRequestContextGetter* request_context_getter_;
|
||||||
|
std::string api_key_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AtomAccessTokenStore::AtomAccessTokenStore() {
|
AtomAccessTokenStore::AtomAccessTokenStore() {
|
||||||
content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
||||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
|
||||||
if (!env->GetVar("GOOGLE_API_KEY", &api_key_))
|
|
||||||
api_key_ = GOOGLEAPIS_API_KEY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomAccessTokenStore::~AtomAccessTokenStore() {
|
AtomAccessTokenStore::~AtomAccessTokenStore() {
|
||||||
|
|
|
@ -21,7 +21,6 @@ class AtomAccessTokenStore : public content::AccessTokenStore {
|
||||||
const base::string16& access_token) override;
|
const base::string16& access_token) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string api_key_;
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomAccessTokenStore);
|
DISALLOW_COPY_AND_ASSIGN(AtomAccessTokenStore);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue