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/ui/webui/chromeos/login/core_oobe_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h" |
6 | 6 |
7 #include <type_traits> | 7 #include <type_traits> |
8 | 8 |
9 #include "ash/common/accessibility_types.h" | 9 #include "ash/common/accessibility_types.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 namespace { | 48 namespace { |
49 | 49 |
50 const char kJsScreenPath[] = "cr.ui.Oobe"; | 50 const char kJsScreenPath[] = "cr.ui.Oobe"; |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 namespace chromeos { | 54 namespace chromeos { |
55 | 55 |
56 // Note that show_oobe_ui_ defaults to false because WizardController assumes | 56 // Note that show_oobe_ui_ defaults to false because WizardController assumes |
57 // OOBE UI is not visible by default. | 57 // OOBE UI is not visible by default. |
58 CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui) | 58 CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui, |
59 : oobe_ui_(oobe_ui), version_info_updater_(this) { | 59 JSCallsContainer* js_calls_container) |
| 60 : BaseScreenHandler(js_calls_container), |
| 61 oobe_ui_(oobe_ui), |
| 62 version_info_updater_(this) { |
| 63 DCHECK(js_calls_container); |
60 set_call_js_prefix(kJsScreenPath); | 64 set_call_js_prefix(kJsScreenPath); |
61 if (!ash_util::IsRunningInMash()) { | 65 if (!ash_util::IsRunningInMash()) { |
62 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 66 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
63 CHECK(accessibility_manager); | 67 CHECK(accessibility_manager); |
64 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 68 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
65 base::Bind(&CoreOobeHandler::OnAccessibilityStatusChanged, | 69 base::Bind(&CoreOobeHandler::OnAccessibilityStatusChanged, |
66 base::Unretained(this))); | 70 base::Unretained(this))); |
67 } else { | 71 } else { |
68 NOTIMPLEMENTED(); | 72 NOTIMPLEMENTED(); |
69 } | 73 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 AddCallback("toggleResetScreen", &CoreOobeHandler::HandleToggleResetScreen); | 161 AddCallback("toggleResetScreen", &CoreOobeHandler::HandleToggleResetScreen); |
158 AddCallback("toggleEnableDebuggingScreen", | 162 AddCallback("toggleEnableDebuggingScreen", |
159 &CoreOobeHandler::HandleEnableDebuggingScreen); | 163 &CoreOobeHandler::HandleEnableDebuggingScreen); |
160 AddCallback("headerBarVisible", | 164 AddCallback("headerBarVisible", |
161 &CoreOobeHandler::HandleHeaderBarVisible); | 165 &CoreOobeHandler::HandleHeaderBarVisible); |
162 AddCallback("raiseTabKeyEvent", &CoreOobeHandler::HandleRaiseTabKeyEvent); | 166 AddCallback("raiseTabKeyEvent", &CoreOobeHandler::HandleRaiseTabKeyEvent); |
163 AddCallback("setOobeBootstrappingSlave", | 167 AddCallback("setOobeBootstrappingSlave", |
164 &CoreOobeHandler::HandleSetOobeBootstrappingSlave); | 168 &CoreOobeHandler::HandleSetOobeBootstrappingSlave); |
165 } | 169 } |
166 | 170 |
167 template <typename... Args> | |
168 void CoreOobeHandler::ExecuteDeferredJSCall(const std::string& function_name, | |
169 std::unique_ptr<Args>... args) { | |
170 CallJS(function_name, *args...); | |
171 } | |
172 | |
173 template <typename... Args> | |
174 void CoreOobeHandler::CallJSOrDefer(const std::string& function_name, | |
175 const Args&... args) { | |
176 if (is_initialized_) { | |
177 CallJS(function_name, args...); | |
178 } else { | |
179 // Note that std::conditional is used here in order to obtain a sequence of | |
180 // base::Value types with the length equal to sizeof...(Args); the C++ | |
181 // template parameter pack expansion rules require that the name of the | |
182 // parameter pack appears in the pattern, even though the elements of the | |
183 // Args pack are not actually in this code. | |
184 deferred_js_calls_.push_back(base::Bind( | |
185 &CoreOobeHandler::ExecuteDeferredJSCall< | |
186 typename std::conditional<true, base::Value, Args>::type...>, | |
187 base::Unretained(this), function_name, | |
188 base::Passed(::login::MakeValue(args).CreateDeepCopy())...)); | |
189 } | |
190 } | |
191 | |
192 void CoreOobeHandler::ExecuteDeferredJSCalls() { | |
193 for (const auto& deferred_js_call : deferred_js_calls_) | |
194 deferred_js_call.Run(); | |
195 deferred_js_calls_.clear(); | |
196 } | |
197 | |
198 void CoreOobeHandler::ShowSignInError( | 171 void CoreOobeHandler::ShowSignInError( |
199 int login_attempts, | 172 int login_attempts, |
200 const std::string& error_text, | 173 const std::string& error_text, |
201 const std::string& help_link_text, | 174 const std::string& help_link_text, |
202 HelpAppLauncher::HelpTopic help_topic_id) { | 175 HelpAppLauncher::HelpTopic help_topic_id) { |
203 LOG(ERROR) << "CoreOobeHandler::ShowSignInError: error_text=" << error_text; | 176 LOG(ERROR) << "CoreOobeHandler::ShowSignInError: error_text=" << error_text; |
204 CallJSOrDefer("showSignInError", login_attempts, error_text, | 177 CallJSOrDefer("showSignInError", login_attempts, error_text, |
205 help_link_text, static_cast<int>(help_topic_id)); | 178 help_link_text, static_cast<int>(help_topic_id)); |
206 } | 179 } |
207 | 180 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 261 |
289 void CoreOobeHandler::ShowPinKeyboard(bool show) { | 262 void CoreOobeHandler::ShowPinKeyboard(bool show) { |
290 CallJSOrDefer("showPinKeyboard", show); | 263 CallJSOrDefer("showPinKeyboard", show); |
291 } | 264 } |
292 | 265 |
293 void CoreOobeHandler::SetClientAreaSize(int width, int height) { | 266 void CoreOobeHandler::SetClientAreaSize(int width, int height) { |
294 CallJSOrDefer("setClientAreaSize", width, height); | 267 CallJSOrDefer("setClientAreaSize", width, height); |
295 } | 268 } |
296 | 269 |
297 void CoreOobeHandler::HandleInitialized() { | 270 void CoreOobeHandler::HandleInitialized() { |
298 DCHECK(!is_initialized_); | |
299 is_initialized_ = true; | |
300 ExecuteDeferredJSCalls(); | 271 ExecuteDeferredJSCalls(); |
301 oobe_ui_->InitializeHandlers(); | 272 oobe_ui_->InitializeHandlers(); |
302 } | 273 } |
303 | 274 |
304 void CoreOobeHandler::HandleSkipUpdateEnrollAfterEula() { | 275 void CoreOobeHandler::HandleSkipUpdateEnrollAfterEula() { |
305 WizardController* controller = WizardController::default_controller(); | 276 WizardController* controller = WizardController::default_controller(); |
306 DCHECK(controller); | 277 DCHECK(controller); |
307 if (controller) | 278 if (controller) |
308 controller->SkipUpdateEnrollAfterEula(); | 279 controller->SkipUpdateEnrollAfterEula(); |
309 } | 280 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 | 497 |
527 void CoreOobeHandler::InitDemoModeDetection() { | 498 void CoreOobeHandler::InitDemoModeDetection() { |
528 demo_mode_detector_.InitDetection(); | 499 demo_mode_detector_.InitDetection(); |
529 } | 500 } |
530 | 501 |
531 void CoreOobeHandler::StopDemoModeDetection() { | 502 void CoreOobeHandler::StopDemoModeDetection() { |
532 demo_mode_detector_.StopDetection(); | 503 demo_mode_detector_.StopDetection(); |
533 } | 504 } |
534 | 505 |
535 } // namespace chromeos | 506 } // namespace chromeos |
OLD | NEW |