Remove unused parameter.
[chromium-blink-merge.git] / extensions / shell / browser / shell_oauth2_token_service.cc
blob53ed2fe425d41a3486cbf175da4aac04233f963f
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/shell/browser/shell_oauth2_token_service.h"
7 #include "base/logging.h"
8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
12 namespace extensions {
13 namespace {
15 ShellOAuth2TokenService* g_instance = nullptr;
17 } // namespace
19 ShellOAuth2TokenService::ShellOAuth2TokenService(
20 content::BrowserContext* browser_context,
21 std::string account_id,
22 std::string refresh_token)
23 : browser_context_(browser_context),
24 account_id_(account_id),
25 refresh_token_(refresh_token) {
26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
27 DCHECK(!g_instance);
28 g_instance = this;
31 ShellOAuth2TokenService::~ShellOAuth2TokenService() {
32 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
33 DCHECK(g_instance);
34 g_instance = nullptr;
37 // static
38 ShellOAuth2TokenService* ShellOAuth2TokenService::GetInstance() {
39 DCHECK(g_instance);
40 return g_instance;
43 void ShellOAuth2TokenService::SetRefreshToken(
44 const std::string& account_id,
45 const std::string& refresh_token) {
46 account_id_ = account_id;
47 refresh_token_ = refresh_token;
50 bool ShellOAuth2TokenService::RefreshTokenIsAvailable(
51 const std::string& account_id) const {
52 if (account_id != account_id_)
53 return false;
55 return !refresh_token_.empty();
58 OAuth2AccessTokenFetcher* ShellOAuth2TokenService::CreateAccessTokenFetcher(
59 const std::string& account_id,
60 net::URLRequestContextGetter* getter,
61 OAuth2AccessTokenConsumer* consumer) {
62 DCHECK(!refresh_token_.empty());
63 return new OAuth2AccessTokenFetcherImpl(consumer, getter, refresh_token_);
66 net::URLRequestContextGetter* ShellOAuth2TokenService::GetRequestContext() {
67 return browser_context_->GetRequestContext();
70 } // namespace extensions