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 16 matching lines...) Expand all Loading... |
27 class Profile; | 27 class Profile; |
28 | 28 |
29 namespace chromeos { | 29 namespace chromeos { |
30 | 30 |
31 // DeviceOAuth2TokenService retrieves OAuth2 access tokens for a given | 31 // DeviceOAuth2TokenService retrieves OAuth2 access tokens for a given |
32 // set of scopes using the device-level OAuth2 any-api refresh token | 32 // set of scopes using the device-level OAuth2 any-api refresh token |
33 // obtained during enterprise device enrollment. | 33 // obtained during enterprise device enrollment. |
34 // | 34 // |
35 // See |OAuth2TokenService| for usage details. | 35 // See |OAuth2TokenService| for usage details. |
36 // | 36 // |
| 37 // When using DeviceOAuth2TokenSerivce, a value of |GetRobotAccountId| should |
| 38 // be used in places where API expects |account_id|. |
| 39 // |
37 // Note that requests must be made from the UI thread. | 40 // Note that requests must be made from the UI thread. |
38 class DeviceOAuth2TokenService : public OAuth2TokenService { | 41 class DeviceOAuth2TokenService : public OAuth2TokenService { |
39 public: | 42 public: |
40 // Specialization of StartRequest that in parallel validates that the refresh | 43 // Specialization of StartRequest that in parallel validates that the refresh |
41 // token stored on the device is owned by the device service account. | 44 // token stored on the device is owned by the device service account. |
42 virtual scoped_ptr<Request> StartRequest(const ScopeSet& scopes, | 45 // TODO(fgorski): Remove override of StartRequest to make the method |
| 46 // non-virtual. See crbug.com/282454 for details. |
| 47 virtual scoped_ptr<Request> StartRequest(const std::string& account_id, |
| 48 const ScopeSet& scopes, |
43 Consumer* consumer) OVERRIDE; | 49 Consumer* consumer) OVERRIDE; |
44 | 50 |
45 // Persist the given refresh token on the device. Overwrites any previous | 51 // Persist the given refresh token on the device. Overwrites any previous |
46 // value. Should only be called during initial device setup. | 52 // value. Should only be called during initial device setup. |
47 void SetAndSaveRefreshToken(const std::string& refresh_token); | 53 void SetAndSaveRefreshToken(const std::string& refresh_token); |
48 | 54 |
49 static void RegisterPrefs(PrefRegistrySimple* registry); | 55 static void RegisterPrefs(PrefRegistrySimple* registry); |
50 | 56 |
51 virtual std::string GetRefreshToken() OVERRIDE; | 57 // Gets the refresh token used by the service. |account_id| is expected to be |
| 58 // a value of |GetRobotAccountId|. |
| 59 virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE; |
52 | 60 |
53 protected: | |
54 // Pull the robot account ID from device policy. | 61 // Pull the robot account ID from device policy. |
55 virtual std::string GetRobotAccountId(); | 62 virtual std::string GetRobotAccountId(); |
56 | 63 |
| 64 protected: |
57 // Implementation of OAuth2TokenService. | 65 // Implementation of OAuth2TokenService. |
58 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 66 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
59 | 67 |
60 private: | 68 private: |
61 class ValidatingConsumer; | 69 class ValidatingConsumer; |
62 friend class ValidatingConsumer; | 70 friend class ValidatingConsumer; |
63 friend class DeviceOAuth2TokenServiceFactory; | 71 friend class DeviceOAuth2TokenServiceFactory; |
64 friend class DeviceOAuth2TokenServiceTest; | 72 friend class DeviceOAuth2TokenServiceTest; |
65 friend class TestDeviceOAuth2TokenService; | 73 friend class TestDeviceOAuth2TokenService; |
66 | 74 |
(...skipping 11 matching lines...) Expand all Loading... |
78 | 86 |
79 // Cache the decrypted refresh token, so we only decrypt once. | 87 // Cache the decrypted refresh token, so we only decrypt once. |
80 std::string refresh_token_; | 88 std::string refresh_token_; |
81 PrefService* local_state_; | 89 PrefService* local_state_; |
82 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); | 90 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); |
83 }; | 91 }; |
84 | 92 |
85 } // namespace chromeos | 93 } // namespace chromeos |
86 | 94 |
87 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ | 95 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |