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

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

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to include the update to ProfileSyncService: r224220 Created 7 years, 3 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_POLICY_CLOUD_CLOUD_POLICY_CLIENT_REGISTRATION_HELPER_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_REGISTRATION_HELPER_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_REGISTRATION_HELPER_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_REGISTRATION_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/policy/cloud/cloud_policy_client.h" 14 #include "chrome/browser/policy/cloud/cloud_policy_client.h"
15 #include "chrome/browser/policy/cloud/user_info_fetcher.h" 15 #include "chrome/browser/policy/cloud/user_info_fetcher.h"
16 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" 16 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
17 17
18 class AndroidProfileOAuth2TokenService;
19 class OAuth2TokenService; 18 class OAuth2TokenService;
20 19
21 namespace net { 20 namespace net {
22 class URLRequestContextGetter; 21 class URLRequestContextGetter;
23 } 22 }
24 23
25 namespace policy { 24 namespace policy {
26 25
27 // Helper class that registers a CloudPolicyClient. It fetches an OAuth2 token 26 // Helper class that registers a CloudPolicyClient. It fetches an OAuth2 token
28 // for the DM service if needed, and checks with Gaia if the account has policy 27 // for the DM service if needed, and checks with Gaia if the account has policy
29 // management enabled. 28 // management enabled.
30 class CloudPolicyClientRegistrationHelper : public UserInfoFetcher::Delegate, 29 class CloudPolicyClientRegistrationHelper : public UserInfoFetcher::Delegate,
31 public CloudPolicyClient::Observer { 30 public CloudPolicyClient::Observer {
32 public: 31 public:
33 // |context| and |client| are not owned and must outlive this object. 32 // |context| and |client| are not owned and must outlive this object.
34 // If |should_force_load_policy| then the cloud policy registration is 33 // If |should_force_load_policy| then the cloud policy registration is
35 // performed even if Gaia indicates that this account doesn't have management 34 // performed even if Gaia indicates that this account doesn't have management
36 // enabled. 35 // enabled.
37 CloudPolicyClientRegistrationHelper( 36 CloudPolicyClientRegistrationHelper(
38 net::URLRequestContextGetter* context, 37 net::URLRequestContextGetter* context,
39 CloudPolicyClient* client, 38 CloudPolicyClient* client,
40 bool should_force_load_policy, 39 bool should_force_load_policy,
41 enterprise_management::DeviceRegisterRequest::Type registration_type); 40 enterprise_management::DeviceRegisterRequest::Type registration_type);
42 virtual ~CloudPolicyClientRegistrationHelper(); 41 virtual ~CloudPolicyClientRegistrationHelper();
43 42
44 // Starts the client registration process. This version uses the 43 // Starts the client registration process. This version uses the
45 // supplied OAuth2TokenService to mint the new token for the userinfo 44 // supplied OAuth2TokenService to mint the new token for the userinfo
46 // and DM services, using the |username| account. 45 // and DM services, using the |account_id|.
47 // |callback| is invoked when the registration is complete. 46 // |callback| is invoked when the registration is complete.
48 void StartRegistration( 47 void StartRegistration(
49 #if defined(OS_ANDROID)
50 // TODO(atwilson): Remove this when the Android StartRequestForUsername()
51 // API is folded into the base OAuth2TokenService class (when that class
52 // is made multi-account aware).
53 AndroidProfileOAuth2TokenService* token_service,
54 #else
55 OAuth2TokenService* token_service, 48 OAuth2TokenService* token_service,
56 #endif 49 const std::string& account_id,
57 const std::string& username,
58 const base::Closure& callback); 50 const base::Closure& callback);
59 51
60 #if !defined(OS_ANDROID) 52 #if !defined(OS_ANDROID)
61 // Starts the client registration process. The |login_refresh_token| is used 53 // Starts the client registration process. The |login_refresh_token| is used
62 // to mint a new token for the userinfo and DM services. 54 // to mint a new token for the userinfo and DM services.
63 // |callback| is invoked when the registration is complete. 55 // |callback| is invoked when the registration is complete.
64 void StartRegistrationWithLoginToken(const std::string& login_refresh_token, 56 void StartRegistrationWithLoginToken(const std::string& login_refresh_token,
65 const base::Closure& callback); 57 const base::Closure& callback);
66 #endif 58 #endif
67 59
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 bool should_force_load_policy_; 105 bool should_force_load_policy_;
114 enterprise_management::DeviceRegisterRequest::Type registration_type_; 106 enterprise_management::DeviceRegisterRequest::Type registration_type_;
115 base::Closure callback_; 107 base::Closure callback_;
116 108
117 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClientRegistrationHelper); 109 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClientRegistrationHelper);
118 }; 110 };
119 111
120 } // namespace policy 112 } // namespace policy
121 113
122 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_REGISTRATION_HELPER_H _ 114 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_REGISTRATION_HELPER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698