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

Side by Side Diff: chrome/browser/chromeos/login/enrollment/enrollment_screen.cc

Issue 390443006: Support for remote enrollment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/enrollment/enrollment_screen.h" 5 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/login/login_utils.h" 13 #include "chrome/browser/chromeos/login/login_utils.h"
14 #include "chrome/browser/chromeos/login/screens/screen_observer.h" 14 #include "chrome/browser/chromeos/login/screens/screen_observer.h"
15 #include "chrome/browser/chromeos/login/startup_utils.h" 15 #include "chrome/browser/chromeos/login/startup_utils.h"
16 #include "chrome/browser/chromeos/login/wizard_controller.h" 16 #include "chrome/browser/chromeos/login/wizard_controller.h"
17 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h" 17 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
19 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
20 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
20 #include "chromeos/dbus/cryptohome_client.h" 21 #include "chromeos/dbus/cryptohome_client.h"
21 #include "chromeos/dbus/dbus_method_call_status.h" 22 #include "chromeos/dbus/dbus_method_call_status.h"
22 #include "chromeos/dbus/dbus_thread_manager.h" 23 #include "chromeos/dbus/dbus_thread_manager.h"
23 #include "chromeos/dbus/session_manager_client.h" 24 #include "chromeos/dbus/session_manager_client.h"
24 #include "components/policy/core/common/cloud/enterprise_metrics.h" 25 #include "components/policy/core/common/cloud/enterprise_metrics.h"
25 #include "google_apis/gaia/gaia_auth_util.h" 26 #include "google_apis/gaia/gaia_auth_util.h"
26 #include "google_apis/gaia/google_service_auth_error.h" 27 #include "google_apis/gaia/google_service_auth_error.h"
27 28
28 namespace chromeos { 29 namespace chromeos {
29 30
(...skipping 20 matching lines...) Expand all
50 // have not done that yet). 51 // have not done that yet).
51 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership( 52 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership(
52 EmptyVoidDBusMethodCallback()); 53 EmptyVoidDBusMethodCallback());
53 } 54 }
54 55
55 EnrollmentScreen::~EnrollmentScreen() {} 56 EnrollmentScreen::~EnrollmentScreen() {}
56 57
57 void EnrollmentScreen::SetParameters( 58 void EnrollmentScreen::SetParameters(
58 EnrollmentScreenActor::EnrollmentMode enrollment_mode, 59 EnrollmentScreenActor::EnrollmentMode enrollment_mode,
59 const std::string& management_domain, 60 const std::string& management_domain,
60 const std::string& user) { 61 const std::string& user,
62 const std::string& auth_token) {
61 enrollment_mode_ = enrollment_mode; 63 enrollment_mode_ = enrollment_mode;
62 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user); 64 user_ = user.empty() ? user : gaia::CanonicalizeEmail(user);
65 auth_token_ = auth_token;
63 actor_->SetParameters(this, enrollment_mode_, management_domain); 66 actor_->SetParameters(this, enrollment_mode_, management_domain);
64 } 67 }
65 68
66 void EnrollmentScreen::PrepareToShow() { 69 void EnrollmentScreen::PrepareToShow() {
67 actor_->PrepareToShow(); 70 actor_->PrepareToShow();
68 } 71 }
69 72
70 void EnrollmentScreen::Show() { 73 void EnrollmentScreen::Show() {
71 if (is_auto_enrollment() && !enrollment_failed_once_) { 74 if (is_auto_enrollment() && !enrollment_failed_once_) {
72 actor_->Show(); 75 actor_->Show();
73 UMA(policy::kMetricEnrollmentAutoStarted); 76 UMA(policy::kMetricEnrollmentAutoStarted);
74 actor_->ShowEnrollmentSpinnerScreen(); 77 actor_->ShowEnrollmentSpinnerScreen();
75 actor_->FetchOAuthToken(); 78 actor_->FetchOAuthToken();
76 } else { 79 } else if (auth_token_.empty()) {
77 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, 80 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen,
78 weak_ptr_factory_.GetWeakPtr())); 81 weak_ptr_factory_.GetWeakPtr()));
82 } else {
83 actor_->Show();
84 actor_->ShowEnrollmentSpinnerScreen();
85 OnOAuthTokenAvailable(auth_token_);
79 } 86 }
80 } 87 }
81 88
82 void EnrollmentScreen::Hide() { 89 void EnrollmentScreen::Hide() {
83 actor_->Hide(); 90 actor_->Hide();
84 weak_ptr_factory_.InvalidateWeakPtrs(); 91 weak_ptr_factory_.InvalidateWeakPtrs();
85 } 92 }
86 93
87 std::string EnrollmentScreen::GetName() const { 94 std::string EnrollmentScreen::GetName() const {
88 return WizardController::kEnrollmentScreenName; 95 return WizardController::kEnrollmentScreenName;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 case GoogleServiceAuthError::NUM_STATES: 136 case GoogleServiceAuthError::NUM_STATES:
130 break; 137 break;
131 } 138 }
132 139
133 NOTREACHED(); 140 NOTREACHED();
134 UMAFailure(policy::kMetricEnrollmentOtherFailed); 141 UMAFailure(policy::kMetricEnrollmentOtherFailed);
135 } 142 }
136 143
137 void EnrollmentScreen::OnOAuthTokenAvailable( 144 void EnrollmentScreen::OnOAuthTokenAvailable(
138 const std::string& token) { 145 const std::string& token) {
139 RegisterForDevicePolicy(token); 146 VLOG(1) << "OnOAuthTokenAvailable " << token;
147 const bool is_shark =
148 g_browser_process->platform_part()->browser_policy_connector_chromeos()->
149 GetDeviceCloudPolicyManager()->IsSharkRequisition();
bartfab (slow) 2014/07/16 10:09:15 Nit: IsSharkRequisition() should not be a part of
achuithb 2014/08/13 01:57:42 I tried doing this here: https://codereview.chromi
bartfab (slow) 2014/08/13 14:20:14 Yes, we can discuss this further in crbug.com/3836
achuithb 2014/08/13 23:48:39 Acknowledged.
150
151 if (is_shark && auth_token_.empty()) {
152 // Fetch a second token for shark devices.
153 auth_token_ = token;
bartfab (slow) 2014/07/16 10:09:15 |auth_token_| plays a dual role that makes it diff
achuithb 2014/08/13 01:57:42 What you say is true. However, in the current impl
bartfab (slow) 2014/08/13 14:20:14 Just make a wrapper around base::WriteFile that ta
achuithb 2014/08/13 23:48:39 Done.
154 actor_->FetchOAuthToken();
155 SendEnrollmentAuthToken(token);
156 } else {
157 RegisterForDevicePolicy(token);
158 }
140 } 159 }
141 160
142 void EnrollmentScreen::OnRetry() { 161 void EnrollmentScreen::OnRetry() {
143 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, 162 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen,
144 weak_ptr_factory_.GetWeakPtr())); 163 weak_ptr_factory_.GetWeakPtr()));
145 } 164 }
146 165
147 void EnrollmentScreen::OnCancel() { 166 void EnrollmentScreen::OnCancel() {
148 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_FORCED) { 167 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_FORCED) {
149 actor_->ResetAuth( 168 actor_->ResetAuth(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 policy::DeviceCloudPolicyInitializer* dcp_initializer = 230 policy::DeviceCloudPolicyInitializer* dcp_initializer =
212 connector->GetDeviceCloudPolicyInitializer(); 231 connector->GetDeviceCloudPolicyInitializer();
213 CHECK(dcp_initializer); 232 CHECK(dcp_initializer);
214 dcp_initializer->StartEnrollment( 233 dcp_initializer->StartEnrollment(
215 connector->device_management_service(), 234 connector->device_management_service(),
216 token, is_auto_enrollment(), device_modes, 235 token, is_auto_enrollment(), device_modes,
217 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus, 236 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus,
218 weak_ptr_factory_.GetWeakPtr())); 237 weak_ptr_factory_.GetWeakPtr()));
219 } 238 }
220 239
240 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) {
241 }
bartfab (slow) 2014/07/16 10:09:15 Nit: Add a TODO that briefly explains what this me
achuithb 2014/08/13 01:57:42 Done. I'd like to keep this brief since this isn't
242
221 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( 243 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess(
222 const policy::EnrollmentStatus& status) { 244 const policy::EnrollmentStatus& status) {
223 actor_->ShowEnrollmentStatus(status); 245 actor_->ShowEnrollmentStatus(status);
224 StartupUtils::MarkOobeCompleted(); 246 StartupUtils::MarkOobeCompleted();
225 } 247 }
226 248
227 void EnrollmentScreen::ReportEnrollmentStatus( 249 void EnrollmentScreen::ReportEnrollmentStatus(
228 policy::EnrollmentStatus status) { 250 policy::EnrollmentStatus status) {
229 bool success = status.status() == policy::EnrollmentStatus::STATUS_SUCCESS; 251 bool success = status.status() == policy::EnrollmentStatus::STATUS_SUCCESS;
230 enrollment_failed_once_ |= !success; 252 enrollment_failed_once_ |= !success;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 sample = policy::kMetricEnrollmentAutoFailed; 335 sample = policy::kMetricEnrollmentAutoFailed;
314 UMA(sample); 336 UMA(sample);
315 } 337 }
316 338
317 void EnrollmentScreen::ShowSigninScreen() { 339 void EnrollmentScreen::ShowSigninScreen() {
318 actor_->Show(); 340 actor_->Show();
319 actor_->ShowSigninScreen(); 341 actor_->ShowSigninScreen();
320 } 342 }
321 343
322 } // namespace chromeos 344 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698