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 for (const auto& mapping: GetPolymerResourcesMap()) |
| 83 source->AddResourcePath(mapping.first, mapping.second); |
| 84 } |
| 85 |
79 // Creates a WebUIDataSource for chrome://oobe | 86 // Creates a WebUIDataSource for chrome://oobe |
80 content::WebUIDataSource* CreateOobeUIDataSource( | 87 content::WebUIDataSource* CreateOobeUIDataSource( |
81 const base::DictionaryValue& localized_strings, | 88 const base::DictionaryValue& localized_strings, |
82 const std::string& display_type) { | 89 const std::string& display_type) { |
83 content::WebUIDataSource* source = | 90 content::WebUIDataSource* source = |
84 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); | 91 content::WebUIDataSource::Create(chrome::kChromeUIOobeHost); |
85 source->AddLocalizedStrings(localized_strings); | 92 source->AddLocalizedStrings(localized_strings); |
86 source->SetJsonPath(kStringsJSPath); | 93 source->SetJsonPath(kStringsJSPath); |
87 | 94 |
88 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { | 95 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { |
(...skipping 12 matching lines...) Expand all Loading... |
101 source->OverrideContentSecurityPolicyFrameSrc( | 108 source->OverrideContentSecurityPolicyFrameSrc( |
102 base::StringPrintf( | 109 base::StringPrintf( |
103 "frame-src chrome://terms/ %s/;", | 110 "frame-src chrome://terms/ %s/;", |
104 extensions::kGaiaAuthExtensionOrigin)); | 111 extensions::kGaiaAuthExtensionOrigin)); |
105 | 112 |
106 // Serve deferred resources. | 113 // Serve deferred resources. |
107 source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML); | 114 source->AddResourcePath(kEnrollmentHTMLPath, IDR_OOBE_ENROLLMENT_HTML); |
108 source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS); | 115 source->AddResourcePath(kEnrollmentCSSPath, IDR_OOBE_ENROLLMENT_CSS); |
109 source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS); | 116 source->AddResourcePath(kEnrollmentJSPath, IDR_OOBE_ENROLLMENT_JS); |
110 | 117 |
| 118 if (display_type == OobeUI::kOobeDisplay) { |
| 119 AddPolymerResourcesPaths(source); |
| 120 source->AddResourcePath("Roboto-Thin.ttf", IDR_FONT_ROBOTO_THIN); |
| 121 source->AddResourcePath("Roboto-Light.ttf", IDR_FONT_ROBOTO_LIGHT); |
| 122 source->AddResourcePath("Roboto-Bold.ttf", IDR_FONT_ROBOTO_BOLD); |
| 123 } |
| 124 |
111 return source; | 125 return source; |
112 } | 126 } |
113 | 127 |
114 std::string GetDisplayType(const GURL& url) { | 128 std::string GetDisplayType(const GURL& url) { |
115 std::string path = url.path().size() ? url.path().substr(1) : ""; | 129 std::string path = url.path().size() ? url.path().substr(1) : ""; |
116 if (std::find(kKnownDisplayTypes, | 130 if (std::find(kKnownDisplayTypes, |
117 kKnownDisplayTypes + arraysize(kKnownDisplayTypes), | 131 kKnownDisplayTypes + arraysize(kKnownDisplayTypes), |
118 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) { | 132 path) == kKnownDisplayTypes + arraysize(kKnownDisplayTypes)) { |
119 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default."; | 133 LOG(ERROR) << "Unknown display type '" << path << "'. Setting default."; |
120 return OobeUI::kLoginDisplay; | 134 return OobeUI::kLoginDisplay; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 DCHECK(screen_ids_.count(screen)) | 555 DCHECK(screen_ids_.count(screen)) |
542 << "Screen should be registered in InitializeScreenMaps()"; | 556 << "Screen should be registered in InitializeScreenMaps()"; |
543 Screen new_screen = screen_ids_[screen]; | 557 Screen new_screen = screen_ids_[screen]; |
544 FOR_EACH_OBSERVER(Observer, | 558 FOR_EACH_OBSERVER(Observer, |
545 observer_list_, | 559 observer_list_, |
546 OnCurrentScreenChanged(current_screen_, new_screen)); | 560 OnCurrentScreenChanged(current_screen_, new_screen)); |
547 current_screen_ = new_screen; | 561 current_screen_ = new_screen; |
548 } | 562 } |
549 | 563 |
550 } // namespace chromeos | 564 } // namespace chromeos |
OLD | NEW |