OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/auto_enrollment_check_screen.
h" | 5 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 // static | 40 // static |
41 AutoEnrollmentCheckScreen* AutoEnrollmentCheckScreen::Get( | 41 AutoEnrollmentCheckScreen* AutoEnrollmentCheckScreen::Get( |
42 ScreenManager* manager) { | 42 ScreenManager* manager) { |
43 return static_cast<AutoEnrollmentCheckScreen*>( | 43 return static_cast<AutoEnrollmentCheckScreen*>( |
44 manager->GetScreen(OobeScreen::SCREEN_AUTO_ENROLLMENT_CHECK)); | 44 manager->GetScreen(OobeScreen::SCREEN_AUTO_ENROLLMENT_CHECK)); |
45 } | 45 } |
46 | 46 |
47 AutoEnrollmentCheckScreen::AutoEnrollmentCheckScreen( | 47 AutoEnrollmentCheckScreen::AutoEnrollmentCheckScreen( |
48 BaseScreenDelegate* base_screen_delegate, | 48 BaseScreenDelegate* base_screen_delegate, |
49 AutoEnrollmentCheckScreenActor* actor) | 49 AutoEnrollmentCheckScreenView* view) |
50 : BaseScreen(base_screen_delegate, | 50 : BaseScreen(base_screen_delegate, |
51 OobeScreen::SCREEN_AUTO_ENROLLMENT_CHECK), | 51 OobeScreen::SCREEN_AUTO_ENROLLMENT_CHECK), |
52 actor_(actor), | 52 view_(view), |
53 auto_enrollment_controller_(nullptr), | 53 auto_enrollment_controller_(nullptr), |
54 captive_portal_status_( | 54 captive_portal_status_( |
55 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN), | 55 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN), |
56 auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE), | 56 auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE), |
57 histogram_helper_(new ErrorScreensHistogramHelper("Enrollment")), | 57 histogram_helper_(new ErrorScreensHistogramHelper("Enrollment")), |
58 weak_ptr_factory_(this) { | 58 weak_ptr_factory_(this) { |
59 if (actor_) | 59 if (view_) |
60 actor_->SetDelegate(this); | 60 view_->SetDelegate(this); |
61 } | 61 } |
62 | 62 |
63 AutoEnrollmentCheckScreen::~AutoEnrollmentCheckScreen() { | 63 AutoEnrollmentCheckScreen::~AutoEnrollmentCheckScreen() { |
64 network_portal_detector::GetInstance()->RemoveObserver(this); | 64 network_portal_detector::GetInstance()->RemoveObserver(this); |
65 if (actor_) | 65 if (view_) |
66 actor_->SetDelegate(NULL); | 66 view_->SetDelegate(NULL); |
67 } | 67 } |
68 | 68 |
69 void AutoEnrollmentCheckScreen::ClearState() { | 69 void AutoEnrollmentCheckScreen::ClearState() { |
70 auto_enrollment_progress_subscription_.reset(); | 70 auto_enrollment_progress_subscription_.reset(); |
71 connect_request_subscription_.reset(); | 71 connect_request_subscription_.reset(); |
72 network_portal_detector::GetInstance()->RemoveObserver(this); | 72 network_portal_detector::GetInstance()->RemoveObserver(this); |
73 | 73 |
74 auto_enrollment_state_ = policy::AUTO_ENROLLMENT_STATE_IDLE; | 74 auto_enrollment_state_ = policy::AUTO_ENROLLMENT_STATE_IDLE; |
75 captive_portal_status_ = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN; | 75 captive_portal_status_ = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN; |
76 } | 76 } |
77 | 77 |
78 void AutoEnrollmentCheckScreen::Show() { | 78 void AutoEnrollmentCheckScreen::Show() { |
79 // If the decision got made already, don't show the screen at all. | 79 // If the decision got made already, don't show the screen at all. |
80 if (AutoEnrollmentController::GetMode() != | 80 if (AutoEnrollmentController::GetMode() != |
81 AutoEnrollmentController::MODE_FORCED_RE_ENROLLMENT || | 81 AutoEnrollmentController::MODE_FORCED_RE_ENROLLMENT || |
82 IsCompleted()) { | 82 IsCompleted()) { |
83 SignalCompletion(); | 83 SignalCompletion(); |
84 return; | 84 return; |
85 } | 85 } |
86 | 86 |
87 // Start from a clean slate. | 87 // Start from a clean slate. |
88 ClearState(); | 88 ClearState(); |
89 | 89 |
90 // Bring up the screen. It's important to do this before updating the UI, | 90 // Bring up the screen. It's important to do this before updating the UI, |
91 // because the latter may switch to the error screen, which needs to stay on | 91 // because the latter may switch to the error screen, which needs to stay on |
92 // top. | 92 // top. |
93 actor_->Show(); | 93 view_->Show(); |
94 histogram_helper_->OnScreenShow(); | 94 histogram_helper_->OnScreenShow(); |
95 | 95 |
96 // Set up state change observers. | 96 // Set up state change observers. |
97 auto_enrollment_progress_subscription_ = | 97 auto_enrollment_progress_subscription_ = |
98 auto_enrollment_controller_->RegisterProgressCallback( | 98 auto_enrollment_controller_->RegisterProgressCallback( |
99 base::Bind( | 99 base::Bind( |
100 &AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed, | 100 &AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed, |
101 base::Unretained(this))); | 101 base::Unretained(this))); |
102 network_portal_detector::GetInstance()->AddObserver(this); | 102 network_portal_detector::GetInstance()->AddObserver(this); |
103 | 103 |
(...skipping 10 matching lines...) Expand all Loading... |
114 auto_enrollment_state_ = new_auto_enrollment_state; | 114 auto_enrollment_state_ = new_auto_enrollment_state; |
115 | 115 |
116 // Make sure gears are in motion in the background. | 116 // Make sure gears are in motion in the background. |
117 auto_enrollment_controller_->Start(); | 117 auto_enrollment_controller_->Start(); |
118 network_portal_detector::GetInstance()->StartDetectionIfIdle(); | 118 network_portal_detector::GetInstance()->StartDetectionIfIdle(); |
119 } | 119 } |
120 | 120 |
121 void AutoEnrollmentCheckScreen::Hide() { | 121 void AutoEnrollmentCheckScreen::Hide() { |
122 } | 122 } |
123 | 123 |
124 void AutoEnrollmentCheckScreen::OnActorDestroyed( | 124 void AutoEnrollmentCheckScreen::OnViewDestroyed( |
125 AutoEnrollmentCheckScreenActor* actor) { | 125 AutoEnrollmentCheckScreenView* view) { |
126 if (actor_ == actor) | 126 if (view_ == view) |
127 actor_ = NULL; | 127 view_ = nullptr; |
128 } | 128 } |
129 | 129 |
130 void AutoEnrollmentCheckScreen::OnPortalDetectionCompleted( | 130 void AutoEnrollmentCheckScreen::OnPortalDetectionCompleted( |
131 const NetworkState* /* network */, | 131 const NetworkState* /* network */, |
132 const NetworkPortalDetector::CaptivePortalState& /* state */) { | 132 const NetworkPortalDetector::CaptivePortalState& /* state */) { |
133 UpdateState(); | 133 UpdateState(); |
134 } | 134 } |
135 | 135 |
136 void AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed( | 136 void AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed( |
137 policy::AutoEnrollmentState state) { | 137 policy::AutoEnrollmentState state) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 NOTREACHED(); | 269 NOTREACHED(); |
270 return false; | 270 return false; |
271 } | 271 } |
272 | 272 |
273 void AutoEnrollmentCheckScreen::OnConnectRequested() { | 273 void AutoEnrollmentCheckScreen::OnConnectRequested() { |
274 auto_enrollment_controller_->Retry(); | 274 auto_enrollment_controller_->Retry(); |
275 } | 275 } |
276 | 276 |
277 } // namespace chromeos | 277 } // namespace chromeos |
OLD | NEW |