Remove ExtensionPrefs::SetDidExtensionEscalatePermissions.
[chromium-blink-merge.git] / extensions / shell / browser / shell_oauth2_token_service.h
blob208c349571e888718b8ca9b572168c7e752873ee
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 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "google_apis/gaia/oauth2_token_service.h"
13 namespace content {
14 class BrowserContext;
17 namespace extensions {
19 // Requests OAuth2 access tokens for app_shell. Requires the OAuth2 refresh
20 // token to be set explicitly. Only stores a single refresh token for a single
21 // user account. Created and accessed on the UI thread. Only one instance is
22 // allowed.
23 class ShellOAuth2TokenService : public OAuth2TokenService {
24 public:
25 ShellOAuth2TokenService(content::BrowserContext* browser_context,
26 std::string account_id,
27 std::string refresh_token);
28 ~ShellOAuth2TokenService() override;
30 // Returns the single instance for app_shell.
31 static ShellOAuth2TokenService* GetInstance();
33 std::string account_id() const { return account_id_; }
35 // Sets the current user account and refresh token.
36 void SetRefreshToken(const std::string& account_id,
37 const std::string& refresh_token);
39 // OAuth2TokenService:
40 bool RefreshTokenIsAvailable(const std::string& account_id) const override;
41 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher(
42 const std::string& account_id,
43 net::URLRequestContextGetter* getter,
44 OAuth2AccessTokenConsumer* consumer) override;
45 net::URLRequestContextGetter* GetRequestContext() override;
47 private:
48 // Not owned.
49 content::BrowserContext* browser_context_;
51 // User account id, such as "foo@gmail.com".
52 std::string account_id_;
54 // Cached copy of an OAuth2 refresh token. Not stored on disk.
55 std::string refresh_token_;
57 DISALLOW_COPY_AND_ASSIGN(ShellOAuth2TokenService);
60 } // namespace extensions
62 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_