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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Persist the given refresh token on the device. Overwrites any previous | 50 // Persist the given refresh token on the device. Overwrites any previous |
51 // value. Should only be called during initial device setup. Signals | 51 // value. Should only be called during initial device setup. Signals |
52 // completion via the given callback, passing true if the operation succeeded. | 52 // completion via the given callback, passing true if the operation succeeded. |
53 void SetAndSaveRefreshToken(const std::string& refresh_token, | 53 void SetAndSaveRefreshToken(const std::string& refresh_token, |
54 const StatusCallback& callback); | 54 const StatusCallback& callback); |
55 | 55 |
56 static void RegisterPrefs(PrefRegistrySimple* registry); | 56 static void RegisterPrefs(PrefRegistrySimple* registry); |
57 | 57 |
58 // Implementation of OAuth2TokenService. | 58 // Implementation of OAuth2TokenService. |
59 virtual bool RefreshTokenIsAvailable(const std::string& account_id) | 59 virtual bool RefreshTokenIsAvailable(const std::string& account_id) |
60 const OVERRIDE; | 60 const override; |
61 | 61 |
62 // Pull the robot account ID from device policy. | 62 // Pull the robot account ID from device policy. |
63 virtual std::string GetRobotAccountId() const; | 63 virtual std::string GetRobotAccountId() const; |
64 | 64 |
65 // gaia::GaiaOAuthClient::Delegate implementation. | 65 // gaia::GaiaOAuthClient::Delegate implementation. |
66 virtual void OnRefreshTokenResponse(const std::string& access_token, | 66 virtual void OnRefreshTokenResponse(const std::string& access_token, |
67 int expires_in_seconds) OVERRIDE; | 67 int expires_in_seconds) override; |
68 virtual void OnGetTokenInfoResponse( | 68 virtual void OnGetTokenInfoResponse( |
69 scoped_ptr<base::DictionaryValue> token_info) OVERRIDE; | 69 scoped_ptr<base::DictionaryValue> token_info) override; |
70 virtual void OnOAuthError() OVERRIDE; | 70 virtual void OnOAuthError() override; |
71 virtual void OnNetworkError(int response_code) OVERRIDE; | 71 virtual void OnNetworkError(int response_code) override; |
72 | 72 |
73 protected: | 73 protected: |
74 // Implementation of OAuth2TokenService. | 74 // Implementation of OAuth2TokenService. |
75 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 75 virtual net::URLRequestContextGetter* GetRequestContext() override; |
76 virtual void FetchOAuth2Token(RequestImpl* request, | 76 virtual void FetchOAuth2Token(RequestImpl* request, |
77 const std::string& account_id, | 77 const std::string& account_id, |
78 net::URLRequestContextGetter* getter, | 78 net::URLRequestContextGetter* getter, |
79 const std::string& client_id, | 79 const std::string& client_id, |
80 const std::string& client_secret, | 80 const std::string& client_secret, |
81 const ScopeSet& scopes) OVERRIDE; | 81 const ScopeSet& scopes) override; |
82 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( | 82 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
83 const std::string& account_id, | 83 const std::string& account_id, |
84 net::URLRequestContextGetter* getter, | 84 net::URLRequestContextGetter* getter, |
85 OAuth2AccessTokenConsumer* consumer) OVERRIDE; | 85 OAuth2AccessTokenConsumer* consumer) override; |
86 | 86 |
87 private: | 87 private: |
88 struct PendingRequest; | 88 struct PendingRequest; |
89 friend class DeviceOAuth2TokenServiceFactory; | 89 friend class DeviceOAuth2TokenServiceFactory; |
90 friend class DeviceOAuth2TokenServiceTest; | 90 friend class DeviceOAuth2TokenServiceTest; |
91 | 91 |
92 // Describes the operational state of this object. | 92 // Describes the operational state of this object. |
93 enum State { | 93 enum State { |
94 // Pending system salt / refresh token load. | 94 // Pending system salt / refresh token load. |
95 STATE_LOADING, | 95 STATE_LOADING, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; | 163 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; |
164 | 164 |
165 base::WeakPtrFactory<DeviceOAuth2TokenService> weak_ptr_factory_; | 165 base::WeakPtrFactory<DeviceOAuth2TokenService> weak_ptr_factory_; |
166 | 166 |
167 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); | 167 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); |
168 }; | 168 }; |
169 | 169 |
170 } // namespace chromeos | 170 } // namespace chromeos |
171 | 171 |
172 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ | 172 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |
OLD | NEW |