OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_ |
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_ | 6 #define EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 class ShellOAuth2TokenService : public OAuth2TokenService { | 23 class ShellOAuth2TokenService : public OAuth2TokenService { |
24 public: | 24 public: |
25 ShellOAuth2TokenService(content::BrowserContext* browser_context, | 25 ShellOAuth2TokenService(content::BrowserContext* browser_context, |
26 std::string account_id, | 26 std::string account_id, |
27 std::string refresh_token); | 27 std::string refresh_token); |
28 ~ShellOAuth2TokenService() override; | 28 ~ShellOAuth2TokenService() override; |
29 | 29 |
30 // Returns the single instance for app_shell. | 30 // Returns the single instance for app_shell. |
31 static ShellOAuth2TokenService* GetInstance(); | 31 static ShellOAuth2TokenService* GetInstance(); |
32 | 32 |
33 std::string account_id() const { return account_id_; } | |
34 | |
35 // Sets the current user account and refresh token. | |
36 void SetRefreshToken(const std::string& account_id, | 33 void SetRefreshToken(const std::string& account_id, |
37 const std::string& refresh_token); | 34 const std::string& refresh_token); |
38 | 35 |
39 // OAuth2TokenService: | 36 std::string AccountId() const; |
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; | |
46 | |
47 private: | |
48 // Not owned. | |
49 content::BrowserContext* browser_context_; | |
50 | |
51 // User account id, such as "foo@gmail.com". | |
52 std::string account_id_; | |
53 | |
54 // Cached copy of an OAuth2 refresh token. Not stored on disk. | |
55 std::string refresh_token_; | |
56 | 37 |
57 DISALLOW_COPY_AND_ASSIGN(ShellOAuth2TokenService); | 38 DISALLOW_COPY_AND_ASSIGN(ShellOAuth2TokenService); |
58 }; | 39 }; |
59 | 40 |
60 } // namespace extensions | 41 } // namespace extensions |
61 | 42 |
62 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_ | 43 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |