| 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 "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "content/public/browser/web_ui.h" | 49 #include "content/public/browser/web_ui.h" |
| 50 #include "content/public/browser/web_ui_data_source.h" | 50 #include "content/public/browser/web_ui_data_source.h" |
| 51 #include "grit/browser_resources.h" | 51 #include "grit/browser_resources.h" |
| 52 #include "ui/base/resource/resource_bundle.h" | 52 #include "ui/base/resource/resource_bundle.h" |
| 53 #include "ui/base/webui/web_ui_util.h" | 53 #include "ui/base/webui/web_ui_util.h" |
| 54 | 54 |
| 55 namespace chromeos { | 55 namespace chromeos { |
| 56 | 56 |
| 57 namespace { | 57 namespace { |
| 58 | 58 |
| 59 // List of known types of OobeUI. Type added as path in chrome://oobe url, for | |
| 60 // example chrome://oobe/user-adding. | |
| 61 const char kOobeDisplay[] = "oobe"; | |
| 62 const char kLoginDisplay[] = "login"; | |
| 63 const char kLockDisplay[] = "lock"; | |
| 64 const char kUserAddingDisplay[] = "user-adding"; | |
| 65 const char kAppLaunchSplashDisplay[] = "app-launch-splash"; | |
| 66 | |
| 67 const char* kKnownDisplayTypes[] = { | 59 const char* kKnownDisplayTypes[] = { |
| 68 kOobeDisplay, | 60 OobeUI::kOobeDisplay, |
| 69 kLoginDisplay, | 61 OobeUI::kLoginDisplay, |
| 70 kLockDisplay, | 62 OobeUI::kLockDisplay, |
| 71 kUserAddingDisplay, | 63 OobeUI::kUserAddingDisplay, |
| 72 kAppLaunchSplashDisplay | 64 OobeUI::kAppLaunchSplashDisplay |
| 73 }; | 65 }; |
| 74 | 66 |
| 75 const char kStringsJSPath[] = "strings.js"; | 67 const char kStringsJSPath[] = "strings.js"; |
| 76 const char kLoginJSPath[] = "login.js"; | 68 const char kLoginJSPath[] = "login.js"; |
| 77 const char kOobeJSPath[] = "oobe.js"; | 69 const char kOobeJSPath[] = "oobe.js"; |
| 78 const char kKeyboardUtilsJSPath[] = "keyboard_utils.js"; | 70 const char kKeyboardUtilsJSPath[] = "keyboard_utils.js"; |
| 79 const char kDemoUserLoginJSPath[] = "demo_user_login.js"; | 71 const char kDemoUserLoginJSPath[] = "demo_user_login.js"; |
| 80 | 72 |
| 81 // Paths for deferred resource loading. | 73 // Paths for deferred resource loading. |
| 82 const char kEnrollmentHTMLPath[] = "enrollment.html"; | 74 const char kEnrollmentHTMLPath[] = "enrollment.html"; |
| 83 const char kEnrollmentCSSPath[] = "enrollment.css"; | 75 const char kEnrollmentCSSPath[] = "enrollment.css"; |
| 84 const char kEnrollmentJSPath[] = "enrollment.js"; | 76 const char kEnrollmentJSPath[] = "enrollment.js"; |
| 85 | 77 |
| 86 // Creates a WebUIDataSource for chrome://oobe | 78 // Creates a WebUIDataSource for chrome://oobe |
| 87 content::WebUIDataSource* CreateOobeUIDataSource( | 79 content::WebUIDataSource* CreateOobeUIDataSource( |
| 88 const base::DictionaryValue& localized_strings, | 80 const base::DictionaryValue& localized_strings, |
| 89 const std::string& display_type) { | 81 const std::string& display_type) { |
| 90 content::WebUIDataSource* source = | 82 content::WebUIDataSource* source = |
| 91 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); | 83 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); |
| 92 source->SetUseJsonJSFormatV2(); | 84 source->SetUseJsonJSFormatV2(); |
| 93 source->AddLocalizedStrings(localized_strings); | 85 source->AddLocalizedStrings(localized_strings); |
| 94 source->SetJsonPath(kStringsJSPath); | 86 source->SetJsonPath(kStringsJSPath); |
| 95 | 87 |
| 96 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { | 88 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { |
| 97 source->SetDefaultResource(IDR_DEMO_USER_LOGIN_HTML); | 89 source->SetDefaultResource(IDR_DEMO_USER_LOGIN_HTML); |
| 98 source->AddResourcePath(kDemoUserLoginJSPath, IDR_DEMO_USER_LOGIN_JS); | 90 source->AddResourcePath(kDemoUserLoginJSPath, IDR_DEMO_USER_LOGIN_JS); |
| 99 return source; | 91 return source; |
| 100 } | 92 } |
| 101 if (display_type == kOobeDisplay) { | 93 if (display_type == OobeUI::kOobeDisplay) { |
| 102 source->SetDefaultResource(IDR_OOBE_HTML); | 94 source->SetDefaultResource(IDR_OOBE_HTML); |
| 103 source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS); | 95 source->AddResourcePath(kOobeJSPath, IDR_OOBE_JS); |
| 104 } else { | 96 } else { |
| 105 source->SetDefaultResource(IDR_LOGIN_HTML); | 97 source->SetDefaultResource(IDR_LOGIN_HTML); |
| 106 source->AddResourcePath(kLoginJSPath, IDR_LOGIN_JS); | 98 source->AddResourcePath(kLoginJSPath, IDR_LOGIN_JS); |
| 107 } | 99 } |
| 108 source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS); | 100 source->AddResourcePath(kKeyboardUtilsJSPath, IDR_KEYBOARD_UTILS_JS); |
| 109 source->OverrideContentSecurityPolicyFrameSrc( | 101 source->OverrideContentSecurityPolicyFrameSrc( |
| 110 "frame-src chrome://terms/ " | 102 "frame-src chrome://terms/ " |
| 111 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/;"); | 103 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/;"); |
| 112 | 104 |
| 113 // Serve deferred resources. | 105 // Serve deferred resources. |
| 114 source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML); | 106 source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML); |
| 115 source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS); | 107 source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS); |
| 116 source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS); | 108 source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS); |
| 117 | 109 |
| 118 return source; | 110 return source; |
| 119 } | 111 } |
| 120 | 112 |
| 121 std::string GetDisplayType(const GURL& url) { | 113 std::string GetDisplayType(const GURL& url) { |
| 122 std::string path = url.path().size() ? url.path().substr(1) : ""; | 114 std::string path = url.path().size() ? url.path().substr(1) : ""; |
| 123 if (std::find(kKnownDisplayTypes, | 115 if (std::find(kKnownDisplayTypes, |
| 124 kKnownDisplayTypes + arraysize(kKnownDisplayTypes), | 116 kKnownDisplayTypes + arraysize(kKnownDisplayTypes), |
| 125 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) { | 117 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) { |
| 126 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default."; | 118 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default."; |
| 127 return kLoginDisplay; | 119 return OobeUI::kLoginDisplay; |
| 128 } | 120 } |
| 129 return path; | 121 return path; |
| 130 } | 122 } |
| 131 | 123 |
| 132 } // namespace | 124 } // namespace |
| 133 | 125 |
| 134 // static | 126 // static |
| 127 const char OobeUI::kOobeDisplay[] = "oobe"; |
| 128 const char OobeUI::kLoginDisplay[] = "login"; |
| 129 const char OobeUI::kLockDisplay[] = "lock"; |
| 130 const char OobeUI::kUserAddingDisplay[] = "user-adding"; |
| 131 const char OobeUI::kAppLaunchSplashDisplay[] = "app-launch-splash"; |
| 132 |
| 133 // static |
| 135 const char OobeUI::kScreenOobeHIDDetection[] = "hid-detection"; | 134 const char OobeUI::kScreenOobeHIDDetection[] = "hid-detection"; |
| 136 const char OobeUI::kScreenOobeNetwork[] = "connect"; | 135 const char OobeUI::kScreenOobeNetwork[] = "connect"; |
| 137 const char OobeUI::kScreenOobeEula[] = "eula"; | 136 const char OobeUI::kScreenOobeEula[] = "eula"; |
| 138 const char OobeUI::kScreenOobeUpdate[] = "update"; | 137 const char OobeUI::kScreenOobeUpdate[] = "update"; |
| 139 const char OobeUI::kScreenOobeEnrollment[] = "oauth-enrollment"; | 138 const char OobeUI::kScreenOobeEnrollment[] = "oauth-enrollment"; |
| 140 const char OobeUI::kScreenOobeReset[] = "reset"; | 139 const char OobeUI::kScreenOobeReset[] = "reset"; |
| 141 const char OobeUI::kScreenGaiaSignin[] = "gaia-signin"; | 140 const char OobeUI::kScreenGaiaSignin[] = "gaia-signin"; |
| 142 const char OobeUI::kScreenAccountPicker[] = "account-picker"; | 141 const char OobeUI::kScreenAccountPicker[] = "account-picker"; |
| 143 const char OobeUI::kScreenKioskAutolaunch[] = "autolaunch"; | 142 const char OobeUI::kScreenKioskAutolaunch[] = "autolaunch"; |
| 144 const char OobeUI::kScreenKioskEnable[] = "kiosk-enable"; | 143 const char OobeUI::kScreenKioskEnable[] = "kiosk-enable"; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 observer_list_, | 509 observer_list_, |
| 511 OnCurrentScreenChanged(current_screen_, new_screen)); | 510 OnCurrentScreenChanged(current_screen_, new_screen)); |
| 512 current_screen_ = new_screen; | 511 current_screen_ = new_screen; |
| 513 } else { | 512 } else { |
| 514 NOTREACHED() << "Screen should be registered in InitializeScreenMaps()"; | 513 NOTREACHED() << "Screen should be registered in InitializeScreenMaps()"; |
| 515 current_screen_ = SCREEN_UNKNOWN; | 514 current_screen_ = SCREEN_UNKNOWN; |
| 516 } | 515 } |
| 517 } | 516 } |
| 518 | 517 |
| 519 } // namespace chromeos | 518 } // namespace chromeos |
| OLD | NEW |