| 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/oobe_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/browser_process_platform_part.h" | 12 #include "chrome/browser/browser_process_platform_part.h" |
| 13 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | |
| 14 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen_
actor.h" | 13 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen_
actor.h" |
| 15 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h" | 14 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h" |
| 16 #include "chrome/browser/chromeos/login/screens/error_screen.h" | 15 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
| 16 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 17 #include "chrome/browser/chromeos/login/wizard_controller.h" | 18 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 19 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 20 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 20 #include "chrome/browser/chromeos/system/input_device_settings.h" | 21 #include "chrome/browser/chromeos/system/input_device_settings.h" |
| 21 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" | 22 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" |
| 22 #include "chrome/browser/extensions/tab_helper.h" | 23 #include "chrome/browser/extensions/tab_helper.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/ui/webui/about_ui.h" | 25 #include "chrome/browser/ui/webui/about_ui.h" |
| 25 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handle
r.h" | 26 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handle
r.h" |
| 26 #include "chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_ha
ndler.h" | 27 #include "chrome/browser/ui/webui/chromeos/login/auto_enrollment_check_screen_ha
ndler.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 45 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen
_handler.h" | 46 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen
_handler.h" |
| 46 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler
.h" | 47 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler
.h" |
| 47 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" | 48 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" |
| 48 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" | 49 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" |
| 49 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h" | 50 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h" |
| 50 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" | 51 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" |
| 51 #include "chrome/browser/ui/webui/theme_source.h" | 52 #include "chrome/browser/ui/webui/theme_source.h" |
| 52 #include "chrome/common/chrome_constants.h" | 53 #include "chrome/common/chrome_constants.h" |
| 53 #include "chrome/common/url_constants.h" | 54 #include "chrome/common/url_constants.h" |
| 54 #include "chromeos/chromeos_switches.h" | 55 #include "chromeos/chromeos_switches.h" |
| 56 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 55 #include "content/public/browser/web_ui.h" | 57 #include "content/public/browser/web_ui.h" |
| 56 #include "content/public/browser/web_ui_data_source.h" | 58 #include "content/public/browser/web_ui_data_source.h" |
| 57 #include "grit/browser_resources.h" | 59 #include "grit/browser_resources.h" |
| 58 #include "grit/chrome_unscaled_resources.h" | 60 #include "grit/chrome_unscaled_resources.h" |
| 59 #include "ui/base/resource/resource_bundle.h" | 61 #include "ui/base/resource/resource_bundle.h" |
| 60 #include "ui/base/webui/web_ui_util.h" | 62 #include "ui/base/webui/web_ui_util.h" |
| 61 | 63 |
| 62 namespace chromeos { | 64 namespace chromeos { |
| 63 | 65 |
| 64 namespace { | 66 namespace { |
| 65 | 67 |
| 66 const char* kKnownDisplayTypes[] = { | 68 const char* kKnownDisplayTypes[] = { |
| 67 OobeUI::kOobeDisplay, | 69 OobeUI::kOobeDisplay, |
| 68 OobeUI::kLoginDisplay, | 70 OobeUI::kLoginDisplay, |
| 69 OobeUI::kLockDisplay, | 71 OobeUI::kLockDisplay, |
| 70 OobeUI::kUserAddingDisplay, | 72 OobeUI::kUserAddingDisplay, |
| 71 OobeUI::kAppLaunchSplashDisplay, | 73 OobeUI::kAppLaunchSplashDisplay, |
| 72 OobeUI::kNewOobeDisplay | 74 OobeUI::kNewOobeDisplay |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 const char kStringsJSPath[] = "strings.js"; | 77 const char kStringsJSPath[] = "strings.js"; |
| 76 const char kLoginJSPath[] = "login.js"; | 78 const char kLoginJSPath[] = "login.js"; |
| 77 const char kOobeJSPath[] = "oobe.js"; | 79 const char kOobeJSPath[] = "oobe.js"; |
| 78 const char kKeyboardUtilsJSPath[] = "keyboard_utils.js"; | 80 const char kKeyboardUtilsJSPath[] = "keyboard_utils.js"; |
| 79 const char kDemoUserLoginJSPath[] = "demo_user_login.js"; | |
| 80 const char kCustomElementsHTMLPath[] = "custom_elements.html"; | 81 const char kCustomElementsHTMLPath[] = "custom_elements.html"; |
| 81 const char kCustomElementsJSPath[] = "custom_elements.js"; | 82 const char kCustomElementsJSPath[] = "custom_elements.js"; |
| 82 | 83 |
| 83 // Paths for deferred resource loading. | 84 // Paths for deferred resource loading. |
| 84 const char kEnrollmentHTMLPath[] = "enrollment.html"; | 85 const char kEnrollmentHTMLPath[] = "enrollment.html"; |
| 85 const char kEnrollmentCSSPath[] = "enrollment.css"; | 86 const char kEnrollmentCSSPath[] = "enrollment.css"; |
| 86 const char kEnrollmentJSPath[] = "enrollment.js"; | 87 const char kEnrollmentJSPath[] = "enrollment.js"; |
| 87 | 88 |
| 88 content::WebUIDataSource* CreateNewOobeUIDataSource( | 89 content::WebUIDataSource* CreateNewOobeUIDataSource( |
| 89 const base::DictionaryValue& localized_strings) { | 90 const base::DictionaryValue& localized_strings) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 101 const base::DictionaryValue& localized_strings, | 102 const base::DictionaryValue& localized_strings, |
| 102 const std::string& display_type) { | 103 const std::string& display_type) { |
| 103 if (display_type == OobeUI::kNewOobeDisplay) { | 104 if (display_type == OobeUI::kNewOobeDisplay) { |
| 104 return CreateNewOobeUIDataSource(localized_strings); | 105 return CreateNewOobeUIDataSource(localized_strings); |
| 105 } | 106 } |
| 106 content::WebUIDataSource* source = | 107 content::WebUIDataSource* source = |
| 107 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); | 108 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); |
| 108 source->AddLocalizedStrings(localized_strings); | 109 source->AddLocalizedStrings(localized_strings); |
| 109 source->SetJsonPath(kStringsJSPath); | 110 source->SetJsonPath(kStringsJSPath); |
| 110 | 111 |
| 111 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { | |
| 112 source->SetDefaultResource(IDR_DEMO_USER_LOGIN_HTML); | |
| 113 source->AddResourcePath(kDemoUserLoginJSPath, IDR_DEMO_USER_LOGIN_JS); | |
| 114 return source; | |
| 115 } | |
| 116 | |
| 117 if (display_type == OobeUI::kOobeDisplay) { | 112 if (display_type == OobeUI::kOobeDisplay) { |
| 118 source->SetDefaultResource(IDR_OOBE_HTML); | 113 source->SetDefaultResource(IDR_OOBE_HTML); |
| 119 source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS); | 114 source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS); |
| 120 } else { | 115 } else { |
| 121 source->SetDefaultResource(IDR_LOGIN_HTML); | 116 source->SetDefaultResource(IDR_LOGIN_HTML); |
| 122 source->AddResourcePath(kLoginJSPath, IDR_LOGIN_JS); | 117 source->AddResourcePath(kLoginJSPath, IDR_LOGIN_JS); |
| 123 } | 118 } |
| 124 source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS); | 119 source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS); |
| 125 source->OverrideContentSecurityPolicyFrameSrc( | 120 source->OverrideContentSecurityPolicyFrameSrc( |
| 126 base::StringPrintf( | 121 base::StringPrintf( |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) { | 571 bool OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) { |
| 577 if (!ready_) | 572 if (!ready_) |
| 578 ready_callbacks_.push_back(display_is_ready_callback); | 573 ready_callbacks_.push_back(display_is_ready_callback); |
| 579 return ready_; | 574 return ready_; |
| 580 } | 575 } |
| 581 | 576 |
| 582 void OobeUI::ShowOobeUI(bool show) { | 577 void OobeUI::ShowOobeUI(bool show) { |
| 583 core_handler_->ShowOobeUI(show); | 578 core_handler_->ShowOobeUI(show); |
| 584 } | 579 } |
| 585 | 580 |
| 586 void OobeUI::ShowRetailModeLoginSpinner() { | |
| 587 signin_screen_handler_->ShowRetailModeLoginSpinner(); | |
| 588 } | |
| 589 | |
| 590 void OobeUI::ShowSigninScreen(const LoginScreenContext& context, | 581 void OobeUI::ShowSigninScreen(const LoginScreenContext& context, |
| 591 SigninScreenHandlerDelegate* delegate, | 582 SigninScreenHandlerDelegate* delegate, |
| 592 NativeWindowDelegate* native_window_delegate) { | 583 NativeWindowDelegate* native_window_delegate) { |
| 584 // Check our device mode. |
| 585 policy::BrowserPolicyConnectorChromeOS* connector = |
| 586 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 587 if (connector->GetDeviceMode() == policy::DEVICE_MODE_LEGACY_RETAIL_MODE) { |
| 588 // If we're in legacy retail mode, the best thing we can do is launch the |
| 589 // new offline demo mode. |
| 590 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); |
| 591 host->StartDemoAppLaunch(); |
| 592 return; |
| 593 } |
| 594 |
| 593 signin_screen_handler_->SetDelegate(delegate); | 595 signin_screen_handler_->SetDelegate(delegate); |
| 594 signin_screen_handler_->SetNativeWindowDelegate(native_window_delegate); | 596 signin_screen_handler_->SetNativeWindowDelegate(native_window_delegate); |
| 595 | 597 |
| 596 LoginScreenContext actual_context(context); | 598 LoginScreenContext actual_context(context); |
| 597 actual_context.set_oobe_ui(core_handler_->show_oobe_ui()); | 599 actual_context.set_oobe_ui(core_handler_->show_oobe_ui()); |
| 598 signin_screen_handler_->Show(actual_context); | 600 signin_screen_handler_->Show(actual_context); |
| 599 } | 601 } |
| 600 | 602 |
| 601 void OobeUI::ResetSigninScreenHandlerDelegate() { | 603 void OobeUI::ResetSigninScreenHandlerDelegate() { |
| 602 signin_screen_handler_->SetDelegate(NULL); | 604 signin_screen_handler_->SetDelegate(NULL); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 622 DCHECK(screen_ids_.count(screen)) | 624 DCHECK(screen_ids_.count(screen)) |
| 623 << "Screen should be registered in InitializeScreenMaps()"; | 625 << "Screen should be registered in InitializeScreenMaps()"; |
| 624 Screen new_screen = screen_ids_[screen]; | 626 Screen new_screen = screen_ids_[screen]; |
| 625 FOR_EACH_OBSERVER(Observer, | 627 FOR_EACH_OBSERVER(Observer, |
| 626 observer_list_, | 628 observer_list_, |
| 627 OnCurrentScreenChanged(current_screen_, new_screen)); | 629 OnCurrentScreenChanged(current_screen_, new_screen)); |
| 628 current_screen_ = new_screen; | 630 current_screen_ = new_screen; |
| 629 } | 631 } |
| 630 | 632 |
| 631 } // namespace chromeos | 633 } // namespace chromeos |
| OLD | NEW |