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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 AddCallback("toggleResetScreen", &CoreOobeHandler::HandleToggleResetScreen); | 158 AddCallback("toggleResetScreen", &CoreOobeHandler::HandleToggleResetScreen); |
159 AddCallback("toggleEnableDebuggingScreen", | 159 AddCallback("toggleEnableDebuggingScreen", |
160 &CoreOobeHandler::HandleEnableDebuggingScreen); | 160 &CoreOobeHandler::HandleEnableDebuggingScreen); |
161 AddCallback("headerBarVisible", | 161 AddCallback("headerBarVisible", |
162 &CoreOobeHandler::HandleHeaderBarVisible); | 162 &CoreOobeHandler::HandleHeaderBarVisible); |
163 AddCallback("raiseTabKeyEvent", &CoreOobeHandler::HandleRaiseTabKeyEvent); | 163 AddCallback("raiseTabKeyEvent", &CoreOobeHandler::HandleRaiseTabKeyEvent); |
164 AddCallback("setOobeBootstrappingSlave", | 164 AddCallback("setOobeBootstrappingSlave", |
165 &CoreOobeHandler::HandleSetOobeBootstrappingSlave); | 165 &CoreOobeHandler::HandleSetOobeBootstrappingSlave); |
166 } | 166 } |
167 | 167 |
168 template <typename... Args> | |
169 void CoreOobeHandler::ExecuteDeferredJSCall(const std::string& function_name, | |
170 std::unique_ptr<Args>... args) { | |
171 CallJS(function_name, *args...); | |
172 } | |
173 | |
174 template <typename... Args> | |
175 void CoreOobeHandler::CallJSOrDefer(const std::string& function_name, | |
176 const Args&... args) { | |
177 if (is_initialized_) { | |
178 CallJS(function_name, args...); | |
179 } else { | |
180 // Note that std::conditional is used here in order to obtain a sequence of | |
181 // base::Value types with the length equal to sizeof...(Args); the C++ | |
182 // template parameter pack expansion rules require that the name of the | |
183 // parameter pack appears in the pattern, even though the elements of the | |
184 // Args pack are not actually in this code. | |
185 deferred_js_calls_.push_back(base::Bind( | |
186 &CoreOobeHandler::ExecuteDeferredJSCall< | |
187 typename std::conditional<true, base::Value, Args>::type...>, | |
188 base::Unretained(this), function_name, | |
189 base::Passed(::login::MakeValue(args).CreateDeepCopy())...)); | |
190 } | |
191 } | |
192 | |
193 void CoreOobeHandler::ExecuteDeferredJSCalls() { | |
194 for (const auto& deferred_js_call : deferred_js_calls_) | |
195 deferred_js_call.Run(); | |
196 deferred_js_calls_.clear(); | |
197 } | |
198 | |
199 void CoreOobeHandler::ShowSignInError( | 168 void CoreOobeHandler::ShowSignInError( |
200 int login_attempts, | 169 int login_attempts, |
201 const std::string& error_text, | 170 const std::string& error_text, |
202 const std::string& help_link_text, | 171 const std::string& help_link_text, |
203 HelpAppLauncher::HelpTopic help_topic_id) { | 172 HelpAppLauncher::HelpTopic help_topic_id) { |
204 LOG(ERROR) << "CoreOobeHandler::ShowSignInError: error_text=" << error_text; | 173 LOG(ERROR) << "CoreOobeHandler::ShowSignInError: error_text=" << error_text; |
205 CallJSOrDefer("showSignInError", login_attempts, error_text, | 174 oobe_ui_->CallJSOrDefer("showSignInError", this, login_attempts, error_text, |
206 help_link_text, static_cast<int>(help_topic_id)); | 175 help_link_text, static_cast<int>(help_topic_id)); |
207 } | 176 } |
208 | 177 |
209 void CoreOobeHandler::ShowTpmError() { | 178 void CoreOobeHandler::ShowTpmError() { |
210 CallJSOrDefer("showTpmError"); | 179 oobe_ui_->CallJSOrDefer("showTpmError", this); |
211 } | 180 } |
212 | 181 |
213 void CoreOobeHandler::ShowDeviceResetScreen() { | 182 void CoreOobeHandler::ShowDeviceResetScreen() { |
214 policy::BrowserPolicyConnectorChromeOS* connector = | 183 policy::BrowserPolicyConnectorChromeOS* connector = |
215 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 184 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
216 if (!connector->IsEnterpriseManaged()) { | 185 if (!connector->IsEnterpriseManaged()) { |
217 // Don't recreate WizardController if it already exists. | 186 // Don't recreate WizardController if it already exists. |
218 WizardController* wizard_controller = | 187 WizardController* wizard_controller = |
219 WizardController::default_controller(); | 188 WizardController::default_controller(); |
220 if (wizard_controller && !wizard_controller->login_screen_started()) { | 189 if (wizard_controller && !wizard_controller->login_screen_started()) { |
(...skipping 11 matching lines...) Expand all Loading... |
232 WizardController* wizard_controller = | 201 WizardController* wizard_controller = |
233 WizardController::default_controller(); | 202 WizardController::default_controller(); |
234 if (wizard_controller && !wizard_controller->login_screen_started()) { | 203 if (wizard_controller && !wizard_controller->login_screen_started()) { |
235 wizard_controller->AdvanceToScreen( | 204 wizard_controller->AdvanceToScreen( |
236 OobeScreen::SCREEN_OOBE_ENABLE_DEBUGGING); | 205 OobeScreen::SCREEN_OOBE_ENABLE_DEBUGGING); |
237 } | 206 } |
238 } | 207 } |
239 | 208 |
240 void CoreOobeHandler::ShowActiveDirectoryPasswordChangeScreen( | 209 void CoreOobeHandler::ShowActiveDirectoryPasswordChangeScreen( |
241 const std::string& username) { | 210 const std::string& username) { |
242 CallJSOrDefer("showActiveDirectoryPasswordChangeScreen", username); | 211 oobe_ui_->CallJSOrDefer("showActiveDirectoryPasswordChangeScreen", this, |
| 212 username); |
243 } | 213 } |
244 | 214 |
245 void CoreOobeHandler::ShowSignInUI(const std::string& email) { | 215 void CoreOobeHandler::ShowSignInUI(const std::string& email) { |
246 CallJSOrDefer("showSigninUI", email); | 216 oobe_ui_->CallJSOrDefer("showSigninUI", this, email); |
247 } | 217 } |
248 | 218 |
249 void CoreOobeHandler::ResetSignInUI(bool force_online) { | 219 void CoreOobeHandler::ResetSignInUI(bool force_online) { |
250 CallJSOrDefer("resetSigninUI", force_online); | 220 oobe_ui_->CallJSOrDefer("resetSigninUI", this, force_online); |
251 } | 221 } |
252 | 222 |
253 void CoreOobeHandler::ClearUserPodPassword() { | 223 void CoreOobeHandler::ClearUserPodPassword() { |
254 CallJSOrDefer("clearUserPodPassword"); | 224 oobe_ui_->CallJSOrDefer("clearUserPodPassword", this); |
255 } | 225 } |
256 | 226 |
257 void CoreOobeHandler::RefocusCurrentPod() { | 227 void CoreOobeHandler::RefocusCurrentPod() { |
258 CallJSOrDefer("refocusCurrentPod"); | 228 oobe_ui_->CallJSOrDefer("refocusCurrentPod", this); |
259 } | 229 } |
260 | 230 |
261 void CoreOobeHandler::ShowPasswordChangedScreen(bool show_password_error, | 231 void CoreOobeHandler::ShowPasswordChangedScreen(bool show_password_error, |
262 const std::string& email) { | 232 const std::string& email) { |
263 CallJSOrDefer("showPasswordChangedScreen", show_password_error, email); | 233 oobe_ui_->CallJSOrDefer("showPasswordChangedScreen", this, |
| 234 show_password_error, email); |
264 } | 235 } |
265 | 236 |
266 void CoreOobeHandler::SetUsageStats(bool checked) { | 237 void CoreOobeHandler::SetUsageStats(bool checked) { |
267 CallJSOrDefer("setUsageStats", checked); | 238 oobe_ui_->CallJSOrDefer("setUsageStats", this, checked); |
268 } | 239 } |
269 | 240 |
270 void CoreOobeHandler::SetOemEulaUrl(const std::string& oem_eula_url) { | 241 void CoreOobeHandler::SetOemEulaUrl(const std::string& oem_eula_url) { |
271 CallJSOrDefer("setOemEulaUrl", oem_eula_url); | 242 oobe_ui_->CallJSOrDefer("setOemEulaUrl", this, oem_eula_url); |
272 } | 243 } |
273 | 244 |
274 void CoreOobeHandler::SetTpmPassword(const std::string& tpm_password) { | 245 void CoreOobeHandler::SetTpmPassword(const std::string& tpm_password) { |
275 CallJSOrDefer("setTpmPassword", tpm_password); | 246 oobe_ui_->CallJSOrDefer("setTpmPassword", this, tpm_password); |
276 } | 247 } |
277 | 248 |
278 void CoreOobeHandler::ClearErrors() { | 249 void CoreOobeHandler::ClearErrors() { |
279 CallJSOrDefer("clearErrors"); | 250 oobe_ui_->CallJSOrDefer("clearErrors", this); |
280 } | 251 } |
281 | 252 |
282 void CoreOobeHandler::ReloadContent(const base::DictionaryValue& dictionary) { | 253 void CoreOobeHandler::ReloadContent(const base::DictionaryValue& dictionary) { |
283 CallJSOrDefer("reloadContent", dictionary); | 254 oobe_ui_->CallJSOrDefer("reloadContent", this, dictionary); |
284 } | 255 } |
285 | 256 |
286 void CoreOobeHandler::ShowControlBar(bool show) { | 257 void CoreOobeHandler::ShowControlBar(bool show) { |
287 CallJSOrDefer("showControlBar", show); | 258 oobe_ui_->CallJSOrDefer("showControlBar", this, show); |
288 } | 259 } |
289 | 260 |
290 void CoreOobeHandler::ShowPinKeyboard(bool show) { | 261 void CoreOobeHandler::ShowPinKeyboard(bool show) { |
291 CallJSOrDefer("showPinKeyboard", show); | 262 oobe_ui_->CallJSOrDefer("showPinKeyboard", this, show); |
292 } | 263 } |
293 | 264 |
294 void CoreOobeHandler::SetClientAreaSize(int width, int height) { | 265 void CoreOobeHandler::SetClientAreaSize(int width, int height) { |
295 CallJSOrDefer("setClientAreaSize", width, height); | 266 oobe_ui_->CallJSOrDefer("setClientAreaSize", this, width, height); |
296 } | 267 } |
297 | 268 |
298 void CoreOobeHandler::HandleInitialized() { | 269 void CoreOobeHandler::HandleInitialized() { |
299 DCHECK(!is_initialized_); | 270 oobe_ui_->ExecuteDeferredJSCalls(); |
300 is_initialized_ = true; | |
301 ExecuteDeferredJSCalls(); | |
302 oobe_ui_->InitializeHandlers(); | 271 oobe_ui_->InitializeHandlers(); |
303 } | 272 } |
304 | 273 |
305 void CoreOobeHandler::HandleSkipUpdateEnrollAfterEula() { | 274 void CoreOobeHandler::HandleSkipUpdateEnrollAfterEula() { |
306 WizardController* controller = WizardController::default_controller(); | 275 WizardController* controller = WizardController::default_controller(); |
307 DCHECK(controller); | 276 DCHECK(controller); |
308 if (controller) | 277 if (controller) |
309 controller->SkipUpdateEnrollAfterEula(); | 278 controller->SkipUpdateEnrollAfterEula(); |
310 } | 279 } |
311 | 280 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 return; | 358 return; |
390 | 359 |
391 show_oobe_ui_ = show; | 360 show_oobe_ui_ = show; |
392 | 361 |
393 if (page_is_ready()) | 362 if (page_is_ready()) |
394 UpdateOobeUIVisibility(); | 363 UpdateOobeUIVisibility(); |
395 } | 364 } |
396 | 365 |
397 void CoreOobeHandler::UpdateShutdownAndRebootVisibility( | 366 void CoreOobeHandler::UpdateShutdownAndRebootVisibility( |
398 bool reboot_on_shutdown) { | 367 bool reboot_on_shutdown) { |
399 CallJSOrDefer("showShutdown", !reboot_on_shutdown); | 368 oobe_ui_->CallJSOrDefer("showShutdown", this, !reboot_on_shutdown); |
400 } | 369 } |
401 | 370 |
402 void CoreOobeHandler::UpdateA11yState() { | 371 void CoreOobeHandler::UpdateA11yState() { |
403 if (chrome::IsRunningInMash()) { | 372 if (chrome::IsRunningInMash()) { |
404 NOTIMPLEMENTED(); | 373 NOTIMPLEMENTED(); |
405 return; | 374 return; |
406 } | 375 } |
407 // TODO(dpolukhin): crbug.com/412891 | 376 // TODO(dpolukhin): crbug.com/412891 |
408 DCHECK(MagnificationManager::Get()); | 377 DCHECK(MagnificationManager::Get()); |
409 base::DictionaryValue a11y_info; | 378 base::DictionaryValue a11y_info; |
410 a11y_info.SetBoolean("highContrastEnabled", | 379 a11y_info.SetBoolean("highContrastEnabled", |
411 AccessibilityManager::Get()->IsHighContrastEnabled()); | 380 AccessibilityManager::Get()->IsHighContrastEnabled()); |
412 a11y_info.SetBoolean("largeCursorEnabled", | 381 a11y_info.SetBoolean("largeCursorEnabled", |
413 AccessibilityManager::Get()->IsLargeCursorEnabled()); | 382 AccessibilityManager::Get()->IsLargeCursorEnabled()); |
414 a11y_info.SetBoolean("spokenFeedbackEnabled", | 383 a11y_info.SetBoolean("spokenFeedbackEnabled", |
415 AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 384 AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
416 a11y_info.SetBoolean("screenMagnifierEnabled", | 385 a11y_info.SetBoolean("screenMagnifierEnabled", |
417 MagnificationManager::Get()->IsMagnifierEnabled()); | 386 MagnificationManager::Get()->IsMagnifierEnabled()); |
418 a11y_info.SetBoolean("virtualKeyboardEnabled", | 387 a11y_info.SetBoolean("virtualKeyboardEnabled", |
419 AccessibilityManager::Get()->IsVirtualKeyboardEnabled()); | 388 AccessibilityManager::Get()->IsVirtualKeyboardEnabled()); |
420 CallJSOrDefer("refreshA11yInfo", a11y_info); | 389 oobe_ui_->CallJSOrDefer("refreshA11yInfo", this, a11y_info); |
421 } | 390 } |
422 | 391 |
423 void CoreOobeHandler::UpdateOobeUIVisibility() { | 392 void CoreOobeHandler::UpdateOobeUIVisibility() { |
424 const std::string& display = oobe_ui_->display_type(); | 393 const std::string& display = oobe_ui_->display_type(); |
425 CallJSOrDefer("showAPIKeysNotice", !google_apis::HasKeysConfigured() && | 394 oobe_ui_->CallJSOrDefer( |
426 (display == OobeUI::kOobeDisplay || | 395 "showAPIKeysNotice", this, |
427 display == OobeUI::kLoginDisplay)); | 396 !google_apis::HasKeysConfigured() && (display == OobeUI::kOobeDisplay || |
| 397 display == OobeUI::kLoginDisplay)); |
428 | 398 |
429 // Don't show version label on the stable channel by default. | 399 // Don't show version label on the stable channel by default. |
430 bool should_show_version = true; | 400 bool should_show_version = true; |
431 version_info::Channel channel = chrome::GetChannel(); | 401 version_info::Channel channel = chrome::GetChannel(); |
432 if (channel == version_info::Channel::STABLE || | 402 if (channel == version_info::Channel::STABLE || |
433 channel == version_info::Channel::BETA) { | 403 channel == version_info::Channel::BETA) { |
434 should_show_version = false; | 404 should_show_version = false; |
435 } | 405 } |
436 CallJSOrDefer("showVersion", should_show_version); | 406 oobe_ui_->CallJSOrDefer("showVersion", this, should_show_version); |
437 CallJSOrDefer("showOobeUI", show_oobe_ui_); | 407 oobe_ui_->CallJSOrDefer("showOobeUI", this, show_oobe_ui_); |
438 if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation()) | 408 if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation()) |
439 CallJSOrDefer("enableKeyboardFlow", true); | 409 oobe_ui_->CallJSOrDefer("enableKeyboardFlow", this, true); |
440 } | 410 } |
441 | 411 |
442 void CoreOobeHandler::OnOSVersionLabelTextUpdated( | 412 void CoreOobeHandler::OnOSVersionLabelTextUpdated( |
443 const std::string& os_version_label_text) { | 413 const std::string& os_version_label_text) { |
444 UpdateLabel("version", os_version_label_text); | 414 UpdateLabel("version", os_version_label_text); |
445 } | 415 } |
446 | 416 |
447 void CoreOobeHandler::OnEnterpriseInfoUpdated( | 417 void CoreOobeHandler::OnEnterpriseInfoUpdated( |
448 const std::string& message_text, const std::string& asset_id) { | 418 const std::string& message_text, const std::string& asset_id) { |
449 CallJSOrDefer("setEnterpriseInfo", message_text, asset_id); | 419 oobe_ui_->CallJSOrDefer("setEnterpriseInfo", this, message_text, asset_id); |
450 } | 420 } |
451 | 421 |
452 ui::EventProcessor* CoreOobeHandler::GetEventProcessor() { | 422 ui::EventProcessor* CoreOobeHandler::GetEventProcessor() { |
453 return ash::Shell::GetPrimaryRootWindow()->GetHost()->event_processor(); | 423 return ash::Shell::GetPrimaryRootWindow()->GetHost()->event_processor(); |
454 } | 424 } |
455 | 425 |
456 void CoreOobeHandler::UpdateLabel(const std::string& id, | 426 void CoreOobeHandler::UpdateLabel(const std::string& id, |
457 const std::string& text) { | 427 const std::string& text) { |
458 CallJSOrDefer("setLabelText", id, text); | 428 oobe_ui_->CallJSOrDefer("setLabelText", this, id, text); |
459 } | 429 } |
460 | 430 |
461 void CoreOobeHandler::UpdateDeviceRequisition() { | 431 void CoreOobeHandler::UpdateDeviceRequisition() { |
462 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 432 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
463 g_browser_process->platform_part() | 433 g_browser_process->platform_part() |
464 ->browser_policy_connector_chromeos() | 434 ->browser_policy_connector_chromeos() |
465 ->GetDeviceCloudPolicyManager(); | 435 ->GetDeviceCloudPolicyManager(); |
466 if (policy_manager) { | 436 if (policy_manager) { |
467 CallJSOrDefer("updateDeviceRequisition", | 437 oobe_ui_->CallJSOrDefer("updateDeviceRequisition", this, |
468 policy_manager->GetDeviceRequisition()); | 438 policy_manager->GetDeviceRequisition()); |
469 } | 439 } |
470 } | 440 } |
471 | 441 |
472 void CoreOobeHandler::UpdateKeyboardState() { | 442 void CoreOobeHandler::UpdateKeyboardState() { |
473 keyboard::KeyboardController* keyboard_controller = | 443 keyboard::KeyboardController* keyboard_controller = |
474 keyboard::KeyboardController::GetInstance(); | 444 keyboard::KeyboardController::GetInstance(); |
475 if (keyboard_controller) { | 445 if (keyboard_controller) { |
476 gfx::Rect bounds = keyboard_controller->current_keyboard_bounds(); | 446 gfx::Rect bounds = keyboard_controller->current_keyboard_bounds(); |
477 ShowControlBar(bounds.IsEmpty()); | 447 ShowControlBar(bounds.IsEmpty()); |
478 ShowPinKeyboard(bounds.IsEmpty()); | 448 ShowPinKeyboard(bounds.IsEmpty()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 497 |
528 void CoreOobeHandler::InitDemoModeDetection() { | 498 void CoreOobeHandler::InitDemoModeDetection() { |
529 demo_mode_detector_.InitDetection(); | 499 demo_mode_detector_.InitDetection(); |
530 } | 500 } |
531 | 501 |
532 void CoreOobeHandler::StopDemoModeDetection() { | 502 void CoreOobeHandler::StopDemoModeDetection() { |
533 demo_mode_detector_.StopDetection(); | 503 demo_mode_detector_.StopDetection(); |
534 } | 504 } |
535 | 505 |
536 } // namespace chromeos | 506 } // namespace chromeos |
OLD | NEW |