OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void SetAndSaveRefreshToken(const std::string& refresh_token); | 47 void SetAndSaveRefreshToken(const std::string& refresh_token); |
48 | 48 |
49 static void RegisterPrefs(PrefRegistrySimple* registry); | 49 static void RegisterPrefs(PrefRegistrySimple* registry); |
50 | 50 |
51 virtual std::string GetRefreshToken() OVERRIDE; | 51 virtual std::string GetRefreshToken() OVERRIDE; |
52 | 52 |
53 protected: | 53 protected: |
54 // Pull the robot account ID from device policy. | 54 // Pull the robot account ID from device policy. |
55 virtual std::string GetRobotAccountId(); | 55 virtual std::string GetRobotAccountId(); |
56 | 56 |
| 57 // Implementation of OAuth2TokenService. |
| 58 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
| 59 |
57 private: | 60 private: |
58 class ValidatingConsumer; | 61 class ValidatingConsumer; |
59 friend class ValidatingConsumer; | 62 friend class ValidatingConsumer; |
60 friend class DeviceOAuth2TokenServiceFactory; | 63 friend class DeviceOAuth2TokenServiceFactory; |
61 friend class DeviceOAuth2TokenServiceTest; | 64 friend class DeviceOAuth2TokenServiceTest; |
62 friend class TestDeviceOAuth2TokenService; | 65 friend class TestDeviceOAuth2TokenService; |
63 | 66 |
64 // Use DeviceOAuth2TokenServiceFactory to get an instance of this class. | 67 // Use DeviceOAuth2TokenServiceFactory to get an instance of this class. |
65 explicit DeviceOAuth2TokenService(net::URLRequestContextGetter* getter, | 68 explicit DeviceOAuth2TokenService(net::URLRequestContextGetter* getter, |
66 PrefService* local_state); | 69 PrefService* local_state); |
67 virtual ~DeviceOAuth2TokenService(); | 70 virtual ~DeviceOAuth2TokenService(); |
68 | 71 |
69 // Implementation of OAuth2TokenService. | |
70 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | |
71 | |
72 void OnValidationComplete(bool token_is_valid); | 72 void OnValidationComplete(bool token_is_valid); |
73 | 73 |
74 bool refresh_token_is_valid_; | 74 bool refresh_token_is_valid_; |
75 int max_refresh_token_validation_retries_; | 75 int max_refresh_token_validation_retries_; |
76 | 76 |
77 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 77 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
78 | 78 |
79 // Cache the decrypted refresh token, so we only decrypt once. | 79 // Cache the decrypted refresh token, so we only decrypt once. |
80 std::string refresh_token_; | 80 std::string refresh_token_; |
81 PrefService* local_state_; | 81 PrefService* local_state_; |
82 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); | 82 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); |
83 }; | 83 }; |
84 | 84 |
85 } // namespace chromeos | 85 } // namespace chromeos |
86 | 86 |
87 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ | 87 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |