Chromium Code Reviews| 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" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" | 28 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" |
| 29 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" | 29 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
| 30 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h" | 30 #include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h" |
| 31 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h" | 31 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h" |
| 32 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" | 32 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" |
| 33 #include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler .h" | 33 #include "chrome/browser/ui/webui/chromeos/login/kiosk_autolaunch_screen_handler .h" |
| 34 #include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h" | 34 #include "chrome/browser/ui/webui/chromeos/login/kiosk_enable_screen_handler.h" |
| 35 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h" | 35 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h" |
| 36 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" | 36 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" |
| 37 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 37 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
| 38 #include "chrome/browser/ui/webui/chromeos/login/polymer_resources_map.h" | |
| 38 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h" | 39 #include "chrome/browser/ui/webui/chromeos/login/reset_screen_handler.h" |
| 39 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 40 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 40 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen _handler.h" | 41 #include "chrome/browser/ui/webui/chromeos/login/supervised_user_creation_screen _handler.h" |
| 41 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler .h" | 42 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler .h" |
| 42 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" | 43 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" |
| 43 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" | 44 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" |
| 44 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h" | 45 #include "chrome/browser/ui/webui/chromeos/login/wrong_hwid_screen_handler.h" |
| 45 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" | 46 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" |
| 46 #include "chrome/browser/ui/webui/theme_source.h" | 47 #include "chrome/browser/ui/webui/theme_source.h" |
| 47 #include "chrome/common/chrome_constants.h" | 48 #include "chrome/common/chrome_constants.h" |
| 48 #include "chrome/common/url_constants.h" | 49 #include "chrome/common/url_constants.h" |
| 49 #include "chromeos/chromeos_switches.h" | 50 #include "chromeos/chromeos_switches.h" |
| 50 #include "content/public/browser/web_ui.h" | 51 #include "content/public/browser/web_ui.h" |
| 51 #include "content/public/browser/web_ui_data_source.h" | 52 #include "content/public/browser/web_ui_data_source.h" |
| 52 #include "grit/browser_resources.h" | 53 #include "grit/browser_resources.h" |
| 54 #include "grit/chrome_unscaled_resources.h" | |
| 53 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
| 54 #include "ui/base/webui/web_ui_util.h" | 56 #include "ui/base/webui/web_ui_util.h" |
| 55 | 57 |
| 56 namespace chromeos { | 58 namespace chromeos { |
| 57 | 59 |
| 58 namespace { | 60 namespace { |
| 59 | 61 |
| 60 const char* kKnownDisplayTypes[] = { | 62 const char* kKnownDisplayTypes[] = { |
| 61 OobeUI::kOobeDisplay, | 63 OobeUI::kOobeDisplay, |
| 62 OobeUI::kLoginDisplay, | 64 OobeUI::kLoginDisplay, |
| 63 OobeUI::kLockDisplay, | 65 OobeUI::kLockDisplay, |
| 64 OobeUI::kUserAddingDisplay, | 66 OobeUI::kUserAddingDisplay, |
| 65 OobeUI::kAppLaunchSplashDisplay | 67 OobeUI::kAppLaunchSplashDisplay |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 const char kStringsJSPath[] = "strings.js"; | 70 const char kStringsJSPath[] = "strings.js"; |
| 69 const char kLoginJSPath[] = "login.js"; | 71 const char kLoginJSPath[] = "login.js"; |
| 70 const char kOobeJSPath[] = "oobe.js"; | 72 const char kOobeJSPath[] = "oobe.js"; |
| 71 const char kKeyboardUtilsJSPath[] = "keyboard_utils.js"; | 73 const char kKeyboardUtilsJSPath[] = "keyboard_utils.js"; |
| 72 const char kDemoUserLoginJSPath[] = "demo_user_login.js"; | 74 const char kDemoUserLoginJSPath[] = "demo_user_login.js"; |
| 73 | 75 |
| 74 // Paths for deferred resource loading. | 76 // Paths for deferred resource loading. |
| 75 const char kEnrollmentHTMLPath[] = "enrollment.html"; | 77 const char kEnrollmentHTMLPath[] = "enrollment.html"; |
| 76 const char kEnrollmentCSSPath[] = "enrollment.css"; | 78 const char kEnrollmentCSSPath[] = "enrollment.css"; |
| 77 const char kEnrollmentJSPath[] = "enrollment.js"; | 79 const char kEnrollmentJSPath[] = "enrollment.js"; |
| 78 | 80 |
| 81 void AddPolymerResourcesPaths(content::WebUIDataSource* source) { | |
| 82 const std::vector<std::pair<std::string, int>>& resources = | |
| 83 GetPolymerResourcesMap(); | |
| 84 for (size_t i = 0; i < resources.size(); ++i) { | |
| 85 source->AddResourcePath(resources[i].first, resources[i].second); | |
| 86 } | |
|
Nikita (slow)
2014/09/25 20:20:00
nit: drop {}
dzhioev (left Google)
2014/09/26 22:56:11
Done.
| |
| 87 } | |
| 88 | |
| 79 // Creates a WebUIDataSource for chrome://oobe | 89 // Creates a WebUIDataSource for chrome://oobe |
| 80 content::WebUIDataSource* CreateOobeUIDataSource( | 90 content::WebUIDataSource* CreateOobeUIDataSource( |
| 81 const base::DictionaryValue& localized_strings, | 91 const base::DictionaryValue& localized_strings, |
| 82 const std::string& display_type) { | 92 const std::string& display_type) { |
| 83 content::WebUIDataSource* source = | 93 content::WebUIDataSource* source = |
| 84 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); | 94 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); |
| 85 source->SetUseJsonJSFormatV2(); | 95 source->SetUseJsonJSFormatV2(); |
| 86 source->AddLocalizedStrings(localized_strings); | 96 source->AddLocalizedStrings(localized_strings); |
| 87 source->SetJsonPath(kStringsJSPath); | 97 source->SetJsonPath(kStringsJSPath); |
| 88 | 98 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 102 source->OverrideContentSecurityPolicyFrameSrc( | 112 source->OverrideContentSecurityPolicyFrameSrc( |
| 103 base::StringPrintf( | 113 base::StringPrintf( |
| 104 "frame-src chrome://terms/ %s/;", | 114 "frame-src chrome://terms/ %s/;", |
| 105 extensions::kGaiaAuthExtensionOrigin)); | 115 extensions::kGaiaAuthExtensionOrigin)); |
| 106 | 116 |
| 107 // Serve deferred resources. | 117 // Serve deferred resources. |
| 108 source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML); | 118 source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML); |
| 109 source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS); | 119 source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS); |
| 110 source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS); | 120 source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS); |
| 111 | 121 |
| 122 if (display_type == OobeUI::kOobeDisplay) { | |
| 123 AddPolymerResourcesPaths(source); | |
| 124 source->AddResourcePath("Roboto-Thin.ttf", IDR_FONT_ROBOTO_THIN); | |
|
Nikita (slow)
2014/09/25 20:20:00
nit: I think it makes sense to file a tracking bug
dzhioev (left Google)
2014/09/26 22:56:11
Agree, will file on Monday.
| |
| 125 source->AddResourcePath("Roboto-Light.ttf", IDR_FONT_ROBOTO_LIGHT); | |
| 126 source->AddResourcePath("Roboto-Bold.ttf", IDR_FONT_ROBOTO_BOLD); | |
| 127 } | |
| 128 | |
| 112 return source; | 129 return source; |
| 113 } | 130 } |
| 114 | 131 |
| 115 std::string GetDisplayType(const GURL& url) { | 132 std::string GetDisplayType(const GURL& url) { |
| 116 std::string path = url.path().size() ? url.path().substr(1) : ""; | 133 std::string path = url.path().size() ? url.path().substr(1) : ""; |
| 117 if (std::find(kKnownDisplayTypes, | 134 if (std::find(kKnownDisplayTypes, |
| 118 kKnownDisplayTypes + arraysize(kKnownDisplayTypes), | 135 kKnownDisplayTypes + arraysize(kKnownDisplayTypes), |
| 119 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) { | 136 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) { |
| 120 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default."; | 137 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default."; |
| 121 return OobeUI::kLoginDisplay; | 138 return OobeUI::kLoginDisplay; |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 DCHECK(screen_ids_.count(screen)) | 559 DCHECK(screen_ids_.count(screen)) |
| 543 << "Screen should be registered in InitializeScreenMaps()"; | 560 << "Screen should be registered in InitializeScreenMaps()"; |
| 544 Screen new_screen = screen_ids_[screen]; | 561 Screen new_screen = screen_ids_[screen]; |
| 545 FOR_EACH_OBSERVER(Observer, | 562 FOR_EACH_OBSERVER(Observer, |
| 546 observer_list_, | 563 observer_list_, |
| 547 OnCurrentScreenChanged(current_screen_, new_screen)); | 564 OnCurrentScreenChanged(current_screen_, new_screen)); |
| 548 current_screen_ = new_screen; | 565 current_screen_ = new_screen; |
| 549 } | 566 } |
| 550 | 567 |
| 551 } // namespace chromeos | 568 } // namespace chromeos |
| OLD | NEW |