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

Side by Side Diff: chrome/browser/chromeos/login/enterprise_enrollment_screen.cc

Issue 7562008: Add new version of enrollment screen supporting OAuth. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix nit. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" 5 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
11 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 11 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
12 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h" 12 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h"
13 #include "chrome/browser/chromeos/login/screen_observer.h" 13 #include "chrome/browser/chromeos/login/screen_observer.h"
14 #include "chrome/browser/policy/browser_policy_connector.h"
15 #include "chrome/browser/policy/enterprise_metrics.h" 14 #include "chrome/browser/policy/enterprise_metrics.h"
16 #include "chrome/common/net/gaia/gaia_constants.h" 15 #include "chrome/common/net/gaia/gaia_constants.h"
17 #include "chrome/common/net/gaia/google_service_auth_error.h" 16 #include "chrome/common/net/gaia/google_service_auth_error.h"
18 17
19 namespace chromeos { 18 namespace chromeos {
20 19
21 // Retry for InstallAttrs initialization every 500ms. 20 // Retry for InstallAttrs initialization every 500ms.
22 const int kLockRetryIntervalMs = 500; 21 const int kLockRetryIntervalMs = 500;
23 22
24 EnterpriseEnrollmentScreen::EnterpriseEnrollmentScreen( 23 EnterpriseEnrollmentScreen::EnterpriseEnrollmentScreen(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 captcha_token_, captcha, 77 captcha_token_, captcha,
79 GaiaAuthFetcher::HostedAccountsAllowed); 78 GaiaAuthFetcher::HostedAccountsAllowed);
80 } else { 79 } else {
81 auth_fetcher_->StartClientLogin(user, access_code, 80 auth_fetcher_->StartClientLogin(user, access_code,
82 GaiaConstants::kDeviceManagementService, 81 GaiaConstants::kDeviceManagementService,
83 std::string(), std::string(), 82 std::string(), std::string(),
84 GaiaAuthFetcher::HostedAccountsAllowed); 83 GaiaAuthFetcher::HostedAccountsAllowed);
85 } 84 }
86 } 85 }
87 86
87 void EnterpriseEnrollmentScreen::OnOAuthTokenAvailable(
88 const std::string& user,
89 const std::string& token) {
90 user_ = user;
91 RegisterForDevicePolicy(token,
92 policy::BrowserPolicyConnector::TOKEN_TYPE_OAUTH);
93 }
94
88 void EnterpriseEnrollmentScreen::OnAuthCancelled() { 95 void EnterpriseEnrollmentScreen::OnAuthCancelled() {
89 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, 96 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
90 policy::kMetricEnrollmentCancelled, 97 policy::kMetricEnrollmentCancelled,
91 policy::kMetricEnrollmentSize); 98 policy::kMetricEnrollmentSize);
92 auth_fetcher_.reset(); 99 auth_fetcher_.reset();
93 registrar_.reset(); 100 registrar_.reset();
94 g_browser_process->browser_policy_connector()->DeviceStopAutoRetry(); 101 g_browser_process->browser_policy_connector()->DeviceStopAutoRetry();
95 get_screen_observer()->OnExit( 102 get_screen_observer()->OnExit(
96 ScreenObserver::ENTERPRISE_ENROLLMENT_CANCELLED); 103 ScreenObserver::ENTERPRISE_ENROLLMENT_CANCELLED);
97 } 104 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (service != GaiaConstants::kDeviceManagementService) { 150 if (service != GaiaConstants::kDeviceManagementService) {
144 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, 151 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
145 policy::kMetricEnrollmentOtherFailed, 152 policy::kMetricEnrollmentOtherFailed,
146 policy::kMetricEnrollmentSize); 153 policy::kMetricEnrollmentSize);
147 NOTREACHED() << service; 154 NOTREACHED() << service;
148 return; 155 return;
149 } 156 }
150 157
151 scoped_ptr<GaiaAuthFetcher> auth_fetcher(auth_fetcher_.release()); 158 scoped_ptr<GaiaAuthFetcher> auth_fetcher(auth_fetcher_.release());
152 159
153 policy::BrowserPolicyConnector* connector = 160 RegisterForDevicePolicy(auth_token,
154 g_browser_process->browser_policy_connector(); 161 policy::BrowserPolicyConnector::TOKEN_TYPE_GAIA);
155 if (!connector->device_cloud_policy_subsystem()) {
156 NOTREACHED() << "Cloud policy subsystem not initialized.";
157 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
158 policy::kMetricEnrollmentOtherFailed,
159 policy::kMetricEnrollmentSize);
160 if (is_showing_)
161 actor_->ShowFatalEnrollmentError();
162 return;
163 }
164
165 connector->ScheduleServiceInitialization(0);
166 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar(
167 connector->device_cloud_policy_subsystem(), this));
168
169 // Push the credentials to the policy infrastructure. It'll start enrollment
170 // and notify us of progress through CloudPolicySubsystem::Observer.
171 connector->SetDeviceCredentials(user_, auth_token);
172 } 162 }
173 163
174 void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure( 164 void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure(
175 const std::string& service, 165 const std::string& service,
176 const GoogleServiceAuthError& error) { 166 const GoogleServiceAuthError& error) {
177 if (service != GaiaConstants::kDeviceManagementService) { 167 if (service != GaiaConstants::kDeviceManagementService) {
178 NOTREACHED() << service; 168 NOTREACHED() << service;
179 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, 169 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
180 policy::kMetricEnrollmentOtherFailed, 170 policy::kMetricEnrollmentOtherFailed,
181 policy::kMetricEnrollmentSize); 171 policy::kMetricEnrollmentSize);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs " 306 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs "
317 << "has been locked already!"; 307 << "has been locked already!";
318 actor_->ShowFatalEnrollmentError(); 308 actor_->ShowFatalEnrollmentError();
319 return; 309 return;
320 } 310 }
321 } 311 }
322 312
323 NOTREACHED(); 313 NOTREACHED();
324 } 314 }
325 315
316 void EnterpriseEnrollmentScreen::RegisterForDevicePolicy(
317 const std::string& token,
318 policy::BrowserPolicyConnector::TokenType token_type) {
319 policy::BrowserPolicyConnector* connector =
320 g_browser_process->browser_policy_connector();
321 if (!connector->device_cloud_policy_subsystem()) {
322 NOTREACHED() << "Cloud policy subsystem not initialized.";
323 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
324 policy::kMetricEnrollmentOtherFailed,
325 policy::kMetricEnrollmentSize);
326 if (is_showing_)
327 actor_->ShowFatalEnrollmentError();
328 return;
329 }
330
331 connector->ScheduleServiceInitialization(0);
332 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar(
333 connector->device_cloud_policy_subsystem(), this));
334
335 // Push the credentials to the policy infrastructure. It'll start enrollment
336 // and notify us of progress through CloudPolicySubsystem::Observer.
337 connector->SetDeviceCredentials(user_, token, token_type);
338 }
339
326 } // namespace chromeos 340 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698