OLD | NEW |
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/enterprise_enrollment_screen.
h" | 5 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.
h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chromeos/cros/cros_library.h" | 12 #include "chrome/browser/chromeos/cros/cros_library.h" |
13 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 13 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 14 #include "chrome/browser/chromeos/login/authenticator.h" |
14 #include "chrome/browser/chromeos/login/screen_observer.h" | 15 #include "chrome/browser/chromeos/login/screen_observer.h" |
15 #include "chrome/browser/policy/auto_enrollment_client.h" | 16 #include "chrome/browser/policy/auto_enrollment_client.h" |
16 #include "chrome/browser/policy/browser_policy_connector.h" | 17 #include "chrome/browser/policy/browser_policy_connector.h" |
17 #include "chrome/browser/policy/cloud_policy_data_store.h" | 18 #include "chrome/browser/policy/cloud_policy_data_store.h" |
18 #include "chrome/browser/policy/enterprise_metrics.h" | 19 #include "chrome/browser/policy/enterprise_metrics.h" |
19 | 20 |
20 namespace chromeos { | 21 namespace chromeos { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
(...skipping 21 matching lines...) Expand all Loading... |
45 !cryptohome->TpmIsOwned()) { | 46 !cryptohome->TpmIsOwned()) { |
46 cryptohome->TpmCanAttemptOwnership(); | 47 cryptohome->TpmCanAttemptOwnership(); |
47 } | 48 } |
48 } | 49 } |
49 | 50 |
50 EnterpriseEnrollmentScreen::~EnterpriseEnrollmentScreen() {} | 51 EnterpriseEnrollmentScreen::~EnterpriseEnrollmentScreen() {} |
51 | 52 |
52 void EnterpriseEnrollmentScreen::SetParameters(bool is_auto_enrollment, | 53 void EnterpriseEnrollmentScreen::SetParameters(bool is_auto_enrollment, |
53 const std::string& user) { | 54 const std::string& user) { |
54 is_auto_enrollment_ = is_auto_enrollment; | 55 is_auto_enrollment_ = is_auto_enrollment; |
55 user_ = user; | 56 user_ = user.empty() ? user : Authenticator::Canonicalize(user); |
56 } | 57 } |
57 | 58 |
58 void EnterpriseEnrollmentScreen::PrepareToShow() { | 59 void EnterpriseEnrollmentScreen::PrepareToShow() { |
59 actor_->PrepareToShow(); | 60 actor_->PrepareToShow(); |
60 } | 61 } |
61 | 62 |
62 void EnterpriseEnrollmentScreen::Show() { | 63 void EnterpriseEnrollmentScreen::Show() { |
63 is_showing_ = true; | 64 is_showing_ = true; |
64 actor_->Show(); | 65 actor_->Show(); |
65 } | 66 } |
66 | 67 |
67 void EnterpriseEnrollmentScreen::Hide() { | 68 void EnterpriseEnrollmentScreen::Hide() { |
68 is_showing_ = false; | 69 is_showing_ = false; |
69 actor_->Hide(); | 70 actor_->Hide(); |
70 } | 71 } |
71 | 72 |
72 void EnterpriseEnrollmentScreen::OnOAuthTokenAvailable( | 73 void EnterpriseEnrollmentScreen::OnOAuthTokenAvailable( |
73 const std::string& user, | 74 const std::string& user, |
74 const std::string& token) { | 75 const std::string& token) { |
75 user_ = user; | 76 user_ = Authenticator::Canonicalize(user); |
76 RegisterForDevicePolicy(token); | 77 RegisterForDevicePolicy(token); |
77 } | 78 } |
78 | 79 |
79 void EnterpriseEnrollmentScreen::OnConfirmationClosed(bool go_back_to_signin) { | 80 void EnterpriseEnrollmentScreen::OnConfirmationClosed(bool go_back_to_signin) { |
80 get_screen_observer()->OnExit(go_back_to_signin ? | 81 get_screen_observer()->OnExit(go_back_to_signin ? |
81 ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED : | 82 ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED : |
82 ScreenObserver::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); | 83 ScreenObserver::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); |
83 } | 84 } |
84 | 85 |
85 bool EnterpriseEnrollmentScreen::IsAutoEnrollment(std::string* user) { | 86 bool EnterpriseEnrollmentScreen::IsAutoEnrollment(std::string* user) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // and notify us of progress through CloudPolicySubsystem::Observer. | 215 // and notify us of progress through CloudPolicySubsystem::Observer. |
215 connector->RegisterForDevicePolicy(user_, token, is_auto_enrollment_); | 216 connector->RegisterForDevicePolicy(user_, token, is_auto_enrollment_); |
216 return; | 217 return; |
217 } | 218 } |
218 NOTREACHED(); | 219 NOTREACHED(); |
219 if (is_showing_) | 220 if (is_showing_) |
220 actor_->ShowFatalEnrollmentError(); | 221 actor_->ShowFatalEnrollmentError(); |
221 } | 222 } |
222 | 223 |
223 } // namespace chromeos | 224 } // namespace chromeos |
OLD | NEW |