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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h" | 17 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_view.h" |
18 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper.
h" | 18 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper.
h" |
19 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 19 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
20 #include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" | 20 #include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" |
21 #include "chrome/browser/chromeos/policy/enrollment_config.h" | 21 #include "chrome/browser/chromeos/policy/enrollment_config.h" |
22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
23 #include "components/policy/core/common/cloud/enterprise_metrics.h" | 23 #include "components/policy/core/common/cloud/enterprise_metrics.h" |
24 #include "net/base/backoff_entry.h" | 24 #include "net/base/backoff_entry.h" |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 class ElapsedTimer; | 27 class ElapsedTimer; |
28 } | 28 } |
29 | 29 |
30 namespace pairing_chromeos { | 30 namespace pairing_chromeos { |
31 class ControllerPairingController; | 31 class ControllerPairingController; |
32 } | 32 } |
33 | 33 |
34 namespace chromeos { | 34 namespace chromeos { |
35 | 35 |
36 class BaseScreenDelegate; | 36 class BaseScreenDelegate; |
37 class ScreenManager; | 37 class ScreenManager; |
38 | 38 |
39 // The screen implementation that links the enterprise enrollment UI into the | 39 // The screen implementation that links the enterprise enrollment UI into the |
40 // OOBE wizard. | 40 // OOBE wizard. |
41 class EnrollmentScreen | 41 class EnrollmentScreen |
42 : public BaseScreen, | 42 : public BaseScreen, |
43 public EnterpriseEnrollmentHelper::EnrollmentStatusConsumer, | 43 public EnterpriseEnrollmentHelper::EnrollmentStatusConsumer, |
44 public EnrollmentScreenActor::Controller, | 44 public EnrollmentScreenView::Controller, |
45 public ActiveDirectoryJoinDelegate { | 45 public ActiveDirectoryJoinDelegate { |
46 public: | 46 public: |
47 EnrollmentScreen(BaseScreenDelegate* base_screen_delegate, | 47 EnrollmentScreen(BaseScreenDelegate* base_screen_delegate, |
48 EnrollmentScreenActor* actor); | 48 EnrollmentScreenView* view); |
49 ~EnrollmentScreen() override; | 49 ~EnrollmentScreen() override; |
50 | 50 |
51 static EnrollmentScreen* Get(ScreenManager* manager); | 51 static EnrollmentScreen* Get(ScreenManager* manager); |
52 | 52 |
53 // Setup how this screen will handle enrollment. | 53 // Setup how this screen will handle enrollment. |
54 // |shark_controller| is an interface that is used to communicate with a | 54 // |shark_controller| is an interface that is used to communicate with a |
55 // remora device or a slave device for remote enrollment. | 55 // remora device or a slave device for remote enrollment. |
56 void SetParameters( | 56 void SetParameters( |
57 const policy::EnrollmentConfig& enrollment_config, | 57 const policy::EnrollmentConfig& enrollment_config, |
58 pairing_chromeos::ControllerPairingController* shark_controller); | 58 pairing_chromeos::ControllerPairingController* shark_controller); |
59 | 59 |
60 // BaseScreen implementation: | 60 // BaseScreen implementation: |
61 void Show() override; | 61 void Show() override; |
62 void Hide() override; | 62 void Hide() override; |
63 | 63 |
64 // EnrollmentScreenActor::Controller implementation: | 64 // EnrollmentScreenView::Controller implementation: |
65 void OnLoginDone(const std::string& user, | 65 void OnLoginDone(const std::string& user, |
66 const std::string& auth_code) override; | 66 const std::string& auth_code) override; |
67 void OnRetry() override; | 67 void OnRetry() override; |
68 void OnCancel() override; | 68 void OnCancel() override; |
69 void OnConfirmationClosed() override; | 69 void OnConfirmationClosed() override; |
70 void OnAdJoined(const std::string& realm) override; | 70 void OnAdJoined(const std::string& realm) override; |
71 void OnDeviceAttributeProvided(const std::string& asset_id, | 71 void OnDeviceAttributeProvided(const std::string& asset_id, |
72 const std::string& location) override; | 72 const std::string& location) override; |
73 | 73 |
74 // EnterpriseEnrollmentHelper::EnrollmentStatusConsumer implementation: | 74 // EnterpriseEnrollmentHelper::EnrollmentStatusConsumer implementation: |
75 void OnAuthError(const GoogleServiceAuthError& error) override; | 75 void OnAuthError(const GoogleServiceAuthError& error) override; |
76 void OnEnrollmentError(policy::EnrollmentStatus status) override; | 76 void OnEnrollmentError(policy::EnrollmentStatus status) override; |
77 void OnOtherError(EnterpriseEnrollmentHelper::OtherError error) override; | 77 void OnOtherError(EnterpriseEnrollmentHelper::OtherError error) override; |
78 void OnDeviceEnrolled(const std::string& additional_token) override; | 78 void OnDeviceEnrolled(const std::string& additional_token) override; |
79 void OnDeviceAttributeUploadCompleted(bool success) override; | 79 void OnDeviceAttributeUploadCompleted(bool success) override; |
80 void OnDeviceAttributeUpdatePermission(bool granted) override; | 80 void OnDeviceAttributeUpdatePermission(bool granted) override; |
81 | 81 |
82 // ActiveDirectoryJoinDelegate implementation: | 82 // ActiveDirectoryJoinDelegate implementation: |
83 void JoinDomain(OnDomainJoinedCallback on_joined_callback) override; | 83 void JoinDomain(OnDomainJoinedCallback on_joined_callback) override; |
84 | 84 |
85 // Used for testing. | 85 // Used for testing. |
86 EnrollmentScreenActor* GetActor() { | 86 EnrollmentScreenView* GetView() { return view_; } |
87 return actor_; | |
88 } | |
89 | 87 |
90 private: | 88 private: |
91 friend class EnrollmentScreenUnitTest; | 89 friend class EnrollmentScreenUnitTest; |
92 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestSuccess); | 90 FRIEND_TEST_ALL_PREFIXES(EnrollmentScreenTest, TestSuccess); |
93 FRIEND_TEST_ALL_PREFIXES(AttestationAuthEnrollmentScreenTest, TestCancel); | 91 FRIEND_TEST_ALL_PREFIXES(AttestationAuthEnrollmentScreenTest, TestCancel); |
94 FRIEND_TEST_ALL_PREFIXES(ForcedAttestationAuthEnrollmentScreenTest, | 92 FRIEND_TEST_ALL_PREFIXES(ForcedAttestationAuthEnrollmentScreenTest, |
95 TestCancel); | 93 TestCancel); |
96 FRIEND_TEST_ALL_PREFIXES(MultiAuthEnrollmentScreenTest, TestCancel); | 94 FRIEND_TEST_ALL_PREFIXES(MultiAuthEnrollmentScreenTest, TestCancel); |
97 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, | 95 FRIEND_TEST_ALL_PREFIXES(EnterpriseEnrollmentTest, |
98 TestProperPageGetsLoadedOnEnrollmentSuccess); | 96 TestProperPageGetsLoadedOnEnrollmentSuccess); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Similar to OnRetry(), but responds to a timer instead of the user | 157 // Similar to OnRetry(), but responds to a timer instead of the user |
160 // pressing the Retry button. | 158 // pressing the Retry button. |
161 void AutomaticRetry(); | 159 void AutomaticRetry(); |
162 | 160 |
163 // Processes a request to retry enrollment. | 161 // Processes a request to retry enrollment. |
164 // Called by OnRetry() and AutomaticRetry(). | 162 // Called by OnRetry() and AutomaticRetry(). |
165 void ProcessRetry(); | 163 void ProcessRetry(); |
166 | 164 |
167 pairing_chromeos::ControllerPairingController* shark_controller_ = nullptr; | 165 pairing_chromeos::ControllerPairingController* shark_controller_ = nullptr; |
168 | 166 |
169 EnrollmentScreenActor* actor_; | 167 EnrollmentScreenView* view_; |
170 policy::EnrollmentConfig config_; | 168 policy::EnrollmentConfig config_; |
171 policy::EnrollmentConfig enrollment_config_; | 169 policy::EnrollmentConfig enrollment_config_; |
172 Auth current_auth_ = AUTH_OAUTH; | 170 Auth current_auth_ = AUTH_OAUTH; |
173 Auth last_auth_ = AUTH_OAUTH; | 171 Auth last_auth_ = AUTH_OAUTH; |
174 bool enrollment_failed_once_ = false; | 172 bool enrollment_failed_once_ = false; |
175 std::string enrolling_user_domain_; | 173 std::string enrolling_user_domain_; |
176 std::unique_ptr<base::ElapsedTimer> elapsed_timer_; | 174 std::unique_ptr<base::ElapsedTimer> elapsed_timer_; |
177 net::BackoffEntry::Policy retry_policy_; | 175 net::BackoffEntry::Policy retry_policy_; |
178 std::unique_ptr<net::BackoffEntry> retry_backoff_; | 176 std::unique_ptr<net::BackoffEntry> retry_backoff_; |
179 base::CancelableClosure retry_task_; | 177 base::CancelableClosure retry_task_; |
180 int num_retries_ = 0; | 178 int num_retries_ = 0; |
181 std::unique_ptr<EnterpriseEnrollmentHelper> enrollment_helper_; | 179 std::unique_ptr<EnterpriseEnrollmentHelper> enrollment_helper_; |
182 OnDomainJoinedCallback on_joined_callback_; | 180 OnDomainJoinedCallback on_joined_callback_; |
183 base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_; | 181 base::WeakPtrFactory<EnrollmentScreen> weak_ptr_factory_; |
184 | 182 |
185 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen); | 183 DISALLOW_COPY_AND_ASSIGN(EnrollmentScreen); |
186 }; | 184 }; |
187 | 185 |
188 } // namespace chromeos | 186 } // namespace chromeos |
189 | 187 |
190 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ | 188 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_ENROLLMENT_SCREEN_H_ |
OLD | NEW |