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

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: 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"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 captcha_token_, captcha, 78 captcha_token_, captcha,
79 GaiaAuthFetcher::HostedAccountsAllowed); 79 GaiaAuthFetcher::HostedAccountsAllowed);
80 } else { 80 } else {
81 auth_fetcher_->StartClientLogin(user, access_code, 81 auth_fetcher_->StartClientLogin(user, access_code,
82 GaiaConstants::kDeviceManagementService, 82 GaiaConstants::kDeviceManagementService,
83 std::string(), std::string(), 83 std::string(), std::string(),
84 GaiaAuthFetcher::HostedAccountsAllowed); 84 GaiaAuthFetcher::HostedAccountsAllowed);
85 } 85 }
86 } 86 }
87 87
88 void EnterpriseEnrollmentScreen::OnOAuthTokenAvailable(
89 const std::string& user,
90 const std::string& token) {
91 user_ = user;
92 RegisterForDevicePolicy("", token);
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();
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 } 161 }
173 162
174 void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure( 163 void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure(
175 const std::string& service, 164 const std::string& service,
176 const GoogleServiceAuthError& error) { 165 const GoogleServiceAuthError& error) {
177 if (service != GaiaConstants::kDeviceManagementService) { 166 if (service != GaiaConstants::kDeviceManagementService) {
178 NOTREACHED() << service; 167 NOTREACHED() << service;
179 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment, 168 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
180 policy::kMetricEnrollmentOtherFailed, 169 policy::kMetricEnrollmentOtherFailed,
181 policy::kMetricEnrollmentSize); 170 policy::kMetricEnrollmentSize);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs " 305 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs "
317 << "has been locked already!"; 306 << "has been locked already!";
318 actor_->ShowFatalEnrollmentError(); 307 actor_->ShowFatalEnrollmentError();
319 return; 308 return;
320 } 309 }
321 } 310 }
322 311
323 NOTREACHED(); 312 NOTREACHED();
324 } 313 }
325 314
315 void EnterpriseEnrollmentScreen::RegisterForDevicePolicy(
316 const std::string& gaia_auth_token,
317 const std::string& oauth_token) {
318 policy::BrowserPolicyConnector* connector =
319 g_browser_process->browser_policy_connector();
320 if (!connector->device_cloud_policy_subsystem()) {
321 NOTREACHED() << "Cloud policy subsystem not initialized.";
322 UMA_HISTOGRAM_ENUMERATION(policy::kMetricEnrollment,
323 policy::kMetricEnrollmentOtherFailed,
324 policy::kMetricEnrollmentSize);
325 if (is_showing_)
326 actor_->ShowFatalEnrollmentError();
327 return;
328 }
329
330 connector->ScheduleServiceInitialization(0);
331 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar(
332 connector->device_cloud_policy_subsystem(), this));
333
334 // Push the credentials to the policy infrastructure. It'll start enrollment
335 // and notify us of progress through CloudPolicySubsystem::Observer.
336 connector->SetDeviceCredentials(user_, gaia_auth_token, oauth_token);
337 }
338
326 } // namespace chromeos 339 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698