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

Side by Side Diff: chrome/browser/policy/cloud/user_policy_signin_service_mobile.h

Issue 2953253002: [DICE] Enable sync for an account that is already present in the token service. (Closed)
Patch Set: Address code review Created 3 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_MOBILE_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_MOBILE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_MOBILE_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_MOBILE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h" 17 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h"
18 18
19 class ProfileOAuth2TokenService; 19 class ProfileOAuth2TokenService;
20 class Profile; 20 class Profile;
21 21
22 namespace net { 22 namespace net {
23 class URLRequestContextGetter; 23 class URLRequestContextGetter;
24 } 24 }
25 25
26 namespace policy { 26 namespace policy {
27 27
28 class CloudPolicyClientRegistrationHelper; 28 class CloudPolicyClientRegistrationHelper;
29 29
30 // A specialization of the UserPolicySigninServiceBase for the mobile platforms 30 // A specialization of UserPolicySigninServiceBase for the Android.
31 // (currently Android and iOS).
32 class UserPolicySigninService : public UserPolicySigninServiceBase { 31 class UserPolicySigninService : public UserPolicySigninServiceBase {
33 public: 32 public:
34 // Creates a UserPolicySigninService associated with the passed |profile|. 33 // Creates a UserPolicySigninService associated with the passed |profile|.
35 UserPolicySigninService( 34 UserPolicySigninService(
36 Profile* profile, 35 Profile* profile,
37 PrefService* local_state, 36 PrefService* local_state,
38 DeviceManagementService* device_management_service, 37 DeviceManagementService* device_management_service,
39 UserCloudPolicyManager* policy_manager, 38 UserCloudPolicyManager* policy_manager,
40 SigninManager* signin_manager, 39 SigninManager* signin_manager,
41 scoped_refptr<net::URLRequestContextGetter> system_request_context, 40 scoped_refptr<net::URLRequestContextGetter> system_request_context,
42 ProfileOAuth2TokenService* token_service); 41 ProfileOAuth2TokenService* token_service);
43 ~UserPolicySigninService() override; 42 ~UserPolicySigninService() override;
44 43
45 // Registers a CloudPolicyClient for fetching policy for |username|. 44 // Registers a CloudPolicyClient for fetching policy for |username|.
46 // This requests an OAuth2 token for the services involved, and contacts 45 // This requests an OAuth2 token for the services involved, and contacts
47 // the policy service if the account has management enabled. 46 // the policy service if the account has management enabled.
48 // |account_id| is the obfuscated identitifcation of |username| to get OAuth2 47 // |account_id| is the obfuscated identitifcation of |username| to get OAuth2
49 // token services. 48 // token services.
50 // |callback| is invoked once we have registered this device to fetch policy, 49 // |callback| is invoked once we have registered this device to fetch policy,
51 // or once it is determined that |username| is not a managed account. 50 // or once it is determined that |username| is not a managed account.
52 void RegisterForPolicy(const std::string& username, 51 void RegisterForPolicyWithAccountId(
53 const std::string& account_id,
54 const PolicyRegistrationCallback& callback);
55
56 #if !defined(OS_ANDROID)
57 // Registers a CloudPolicyClient for fetching policy for |username|.
58 // This requires a valid OAuth access token for the scopes returned by the
59 // |GetScopes| static function. |callback| is invoked once we have
60 // registered this device to fetch policy, or once it is determined that
61 // |username| is not a managed account.
62 void RegisterForPolicyWithAccessToken(
63 const std::string& username, 52 const std::string& username,
64 const std::string& access_token, 53 const std::string& account_id,
65 const PolicyRegistrationCallback& callback); 54 const PolicyRegistrationCallback& callback);
66 55
67 // Returns the list of OAuth access scopes required for policy fetching.
68 static std::vector<std::string> GetScopes();
69 #endif
70
71 // Overridden from UserPolicySigninServiceBase to cancel the pending delayed 56 // Overridden from UserPolicySigninServiceBase to cancel the pending delayed
72 // registration. 57 // registration.
73 void ShutdownUserCloudPolicyManager() override; 58 void ShutdownUserCloudPolicyManager() override;
74 59
75 private: 60 private:
76 void RegisterForPolicyInternal(const std::string& username, 61 void RegisterForPolicyInternal(const std::string& username,
77 const std::string& account_id, 62 const std::string& account_id,
78 const std::string& access_token, 63 const std::string& access_token,
79 const PolicyRegistrationCallback& callback); 64 const PolicyRegistrationCallback& callback);
80 65
(...skipping 24 matching lines...) Expand all
105 PrefService* profile_prefs_; 90 PrefService* profile_prefs_;
106 91
107 base::WeakPtrFactory<UserPolicySigninService> weak_factory_; 92 base::WeakPtrFactory<UserPolicySigninService> weak_factory_;
108 93
109 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); 94 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService);
110 }; 95 };
111 96
112 } // namespace policy 97 } // namespace policy
113 98
114 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_MOBILE_H_ 99 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_MOBILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698