Chromium Code Reviews| Index: chrome/browser/chromeos/settings/device_oauth2_token_service.h |
| diff --git a/chrome/browser/chromeos/settings/device_oauth2_token_service.h b/chrome/browser/chromeos/settings/device_oauth2_token_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0cdce65b01dc6cb959424eb05e4403fc65303dbd |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/settings/device_oauth2_token_service.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |
| +#define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/browser/signin/oauth2_token_service.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +class GoogleServiceAuthError; |
| +class PrefRegistrySimple; |
| +class PrefService; |
| +class Profile; |
|
brettw
2013/03/28 20:18:32
Your CL description and this code references Profi
|
| + |
| +namespace chromeos { |
| + |
| +// DeviceOAuth2TokenService retrieves OAuth2 access tokens for a given |
| +// set of scopes using the device-level OAuth2 any-api refresh token |
| +// obtained during enterprise device enrollment. The instance for the |
| +// current browser is available from |
| +// g_browser_process->device_oauth2_token_service(). |
| +// |
| +// See |OAuth2TokenService| for usage details. |
| +// |
| +// Note that requests must be made from the UI thread. |
| +class DeviceOAuth2TokenService : public OAuth2TokenService { |
| + public: |
| + // Do not call the constructor, instead use the instance from |
| + // g_browser_process->device_oauth2_token_service(). |
| + explicit DeviceOAuth2TokenService(net::URLRequestContextGetter* getter, |
| + PrefService* local_state); |
| + virtual ~DeviceOAuth2TokenService(); |
| + |
| + // Persist the given refresh token on the device. Overwrites any previous |
| + // value. Should only be called during initial device setup. |
| + void SetAndSaveRefreshToken(const std::string& refresh_token); |
| + |
| + static void RegisterPrefs(PrefRegistrySimple* registry); |
| + |
| + protected: |
| + virtual std::string GetRefreshToken() OVERRIDE; |
| + |
| + private: |
| + PrefService* local_state_; |
| + DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ |