Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/browser/chromeos/settings/device_oauth2_token_service.h

Issue 12538009: Public Sessions: fetch device robot api token during enterprise enrollment. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: updated tests Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/signin/oauth2_token_service.h" 13 #include "chrome/browser/signin/oauth2_token_service.h"
14 #include "net/url_request/url_request_context_getter.h" 14 #include "net/url_request/url_request_context_getter.h"
15 15
16 namespace net { 16 namespace net {
17 class URLRequestContextGetter; 17 class URLRequestContextGetter;
18 } 18 }
19 19
20 namespace policy {
21 namespace test {
22 class DeviceCloudPolicyManagerChromeOSEnrollmentTest;
23 }
24 }
25
20 class GoogleServiceAuthError; 26 class GoogleServiceAuthError;
21 class PrefRegistrySimple; 27 class PrefRegistrySimple;
22 class PrefService; 28 class PrefService;
23 class Profile; 29 class Profile;
24 30
25 namespace chromeos { 31 namespace chromeos {
26 32
27 // DeviceOAuth2TokenService retrieves OAuth2 access tokens for a given 33 // DeviceOAuth2TokenService retrieves OAuth2 access tokens for a given
28 // set of scopes using the device-level OAuth2 any-api refresh token 34 // set of scopes using the device-level OAuth2 any-api refresh token
29 // obtained during enterprise device enrollment. 35 // obtained during enterprise device enrollment.
30 // 36 //
31 // See |OAuth2TokenService| for usage details. 37 // See |OAuth2TokenService| for usage details.
32 // 38 //
33 // Note that requests must be made from the UI thread. 39 // Note that requests must be made from the UI thread.
34 class DeviceOAuth2TokenService : public OAuth2TokenService { 40 class DeviceOAuth2TokenService : public OAuth2TokenService {
35 public: 41 public:
36 // Persist the given refresh token on the device. Overwrites any previous 42 // Persist the given refresh token on the device. Overwrites any previous
37 // value. Should only be called during initial device setup. 43 // value. Should only be called during initial device setup.
38 void SetAndSaveRefreshToken(const std::string& refresh_token); 44 void SetAndSaveRefreshToken(const std::string& refresh_token);
39 45
40 static void RegisterPrefs(PrefRegistrySimple* registry); 46 static void RegisterPrefs(PrefRegistrySimple* registry);
41 47
42 protected: 48 protected:
43 virtual std::string GetRefreshToken() OVERRIDE; 49 virtual std::string GetRefreshToken() OVERRIDE;
44 50
45 private: 51 private:
46 friend class DeviceOAuth2TokenServiceFactory; 52 friend class DeviceOAuth2TokenServiceFactory;
53 friend class policy::test::DeviceCloudPolicyManagerChromeOSEnrollmentTest;
Mattias Nissler (ping if slow) 2013/04/22 10:59:00 Is there anything wrong with making GetRefreshToke
David Roche 2013/04/23 01:36:08 I guess not. It seemed like clients of these clas
47 FRIEND_TEST_ALL_PREFIXES(DeviceOAuth2TokenServiceTest, SaveEncryptedToken); 54 FRIEND_TEST_ALL_PREFIXES(DeviceOAuth2TokenServiceTest, SaveEncryptedToken);
48 55
49 // Use DeviceOAuth2TokenServiceFactory to get an instance of this class. 56 // Use DeviceOAuth2TokenServiceFactory to get an instance of this class.
50 explicit DeviceOAuth2TokenService(net::URLRequestContextGetter* getter, 57 explicit DeviceOAuth2TokenService(net::URLRequestContextGetter* getter,
51 PrefService* local_state); 58 PrefService* local_state);
52 virtual ~DeviceOAuth2TokenService(); 59 virtual ~DeviceOAuth2TokenService();
53 60
54 // Cache the decrypted refresh token, so we only decrypt once. 61 // Cache the decrypted refresh token, so we only decrypt once.
55 std::string refresh_token_; 62 std::string refresh_token_;
56 PrefService* local_state_; 63 PrefService* local_state_;
57 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService); 64 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenService);
58 }; 65 };
59 66
60 } // namespace chromeos 67 } // namespace chromeos
61 68
62 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_ 69 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698