| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "chrome/browser/chromeos/login/wizard_controller.h" | 12 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 14 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" | 15 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" |
| 16 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" |
| 15 #include "chrome/common/jstemplate_builder.h" | 17 #include "chrome/common/jstemplate_builder.h" |
| 16 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 17 #include "content/browser/tab_contents/tab_contents.h" | 19 #include "content/browser/tab_contents/tab_contents.h" |
| 18 #include "grit/browser_resources.h" | 20 #include "grit/browser_resources.h" |
| 19 #include "grit/chromium_strings.h" | |
| 20 #include "grit/generated_resources.h" | |
| 21 #include "ui/base/l10n/l10n_util.h" | |
| 22 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 // JS API callbacks names. | 25 // JS API callbacks names. |
| 27 const char kJsApiScreenStateInitialize[] = "screenStateInitialize"; | 26 const char kJsApiScreenStateInitialize[] = "screenStateInitialize"; |
| 28 | 27 |
| 29 } // namespace | 28 } // namespace |
| 30 | 29 |
| 31 namespace chromeos { | 30 namespace chromeos { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // CoreOobeHandler ------------------------------------------------------------ | 107 // CoreOobeHandler ------------------------------------------------------------ |
| 109 | 108 |
| 110 CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui) | 109 CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui) |
| 111 : oobe_ui_(oobe_ui) { | 110 : oobe_ui_(oobe_ui) { |
| 112 } | 111 } |
| 113 | 112 |
| 114 CoreOobeHandler::~CoreOobeHandler() { | 113 CoreOobeHandler::~CoreOobeHandler() { |
| 115 } | 114 } |
| 116 | 115 |
| 117 void CoreOobeHandler::GetLocalizedSettings(DictionaryValue* localized_strings) { | 116 void CoreOobeHandler::GetLocalizedSettings(DictionaryValue* localized_strings) { |
| 118 // OOBE title is not actually seen in UI, use title of the welcome screen. | |
| 119 // TODO(altimofeev): move the strings to the corresponding handlers, when | |
| 120 // they will be ready. | |
| 121 localized_strings->SetString("title", | |
| 122 l10n_util::GetStringUTF16(IDS_NETWORK_SELECTION_TITLE)); | |
| 123 localized_strings->SetString("welcomeScreenTitle", | |
| 124 l10n_util::GetStringFUTF16(IDS_WELCOME_SCREEN_TITLE, | |
| 125 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
| 126 localized_strings->SetString("languageSelect", | |
| 127 l10n_util::GetStringUTF16(IDS_LANGUAGE_SELECTION_SELECT)); | |
| 128 localized_strings->SetString("keyboardSelect", | |
| 129 l10n_util::GetStringUTF16(IDS_KEYBOARD_SELECTION_SELECT)); | |
| 130 localized_strings->SetString("networkSelect", | |
| 131 l10n_util::GetStringUTF16(IDS_NETWORK_SELECTION_SELECT)); | |
| 132 localized_strings->SetString("continue", | |
| 133 l10n_util::GetStringUTF16(IDS_NETWORK_SELECTION_CONTINUE_BUTTON)); | |
| 134 } | 117 } |
| 135 | 118 |
| 136 void CoreOobeHandler::Initialize() { | 119 void CoreOobeHandler::Initialize() { |
| 137 } | 120 } |
| 138 | 121 |
| 139 void CoreOobeHandler::RegisterMessages() { | 122 void CoreOobeHandler::RegisterMessages() { |
| 140 web_ui_->RegisterMessageCallback(kJsApiScreenStateInitialize, | 123 web_ui_->RegisterMessageCallback(kJsApiScreenStateInitialize, |
| 141 NewCallback(this, &CoreOobeHandler::OnInitialized)); | 124 NewCallback(this, &CoreOobeHandler::OnInitialized)); |
| 142 } | 125 } |
| 143 | 126 |
| 144 void CoreOobeHandler::OnInitialized(const ListValue* args) { | 127 void CoreOobeHandler::OnInitialized(const ListValue* args) { |
| 145 oobe_ui_->InitializeHandlers(); | 128 oobe_ui_->InitializeHandlers(); |
| 146 } | 129 } |
| 147 | 130 |
| 148 // OobeUI ---------------------------------------------------------------------- | 131 // OobeUI ---------------------------------------------------------------------- |
| 149 | 132 |
| 150 OobeUI::OobeUI(TabContents* contents) | 133 OobeUI::OobeUI(TabContents* contents) |
| 151 : ChromeWebUI(contents), | 134 : ChromeWebUI(contents), |
| 152 update_screen_actor_(NULL), | 135 update_screen_actor_(NULL), |
| 153 network_screen_actor_(NULL), | 136 network_screen_actor_(NULL), |
| 154 eula_screen_actor_(NULL) { | 137 eula_screen_actor_(NULL) { |
| 155 scoped_ptr<DictionaryValue> localized_strings(new DictionaryValue); | 138 scoped_ptr<DictionaryValue> localized_strings(new DictionaryValue); |
| 156 | 139 |
| 157 AddOobeMessageHandler(new CoreOobeHandler(this), localized_strings.get()); | 140 AddOobeMessageHandler(new CoreOobeHandler(this), localized_strings.get()); |
| 158 | 141 |
| 142 NetworkScreenHandler* network_screen_handler = new NetworkScreenHandler; |
| 143 network_screen_actor_ = network_screen_handler; |
| 144 AddOobeMessageHandler(network_screen_handler, localized_strings.get()); |
| 145 |
| 159 EulaScreenHandler* eula_screen_handler = new EulaScreenHandler; | 146 EulaScreenHandler* eula_screen_handler = new EulaScreenHandler; |
| 160 eula_screen_actor_ = eula_screen_handler; | 147 eula_screen_actor_ = eula_screen_handler; |
| 161 AddOobeMessageHandler(eula_screen_handler, localized_strings.get()); | 148 AddOobeMessageHandler(eula_screen_handler, localized_strings.get()); |
| 162 | 149 |
| 163 OobeUIHTMLSource* html_source = | 150 OobeUIHTMLSource* html_source = |
| 164 new OobeUIHTMLSource(localized_strings.release()); | 151 new OobeUIHTMLSource(localized_strings.release()); |
| 165 // Set up the chrome://oobe/ source. | 152 // Set up the chrome://oobe/ source. |
| 166 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 153 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
| 167 } | 154 } |
| 168 | 155 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return NULL; | 193 return NULL; |
| 207 } | 194 } |
| 208 | 195 |
| 209 void OobeUI::AddOobeMessageHandler(OobeMessageHandler* handler, | 196 void OobeUI::AddOobeMessageHandler(OobeMessageHandler* handler, |
| 210 DictionaryValue* localized_strings) { | 197 DictionaryValue* localized_strings) { |
| 211 AddMessageHandler(handler->Attach(this)); | 198 AddMessageHandler(handler->Attach(this)); |
| 212 handler->GetLocalizedSettings(localized_strings); | 199 handler->GetLocalizedSettings(localized_strings); |
| 213 } | 200 } |
| 214 | 201 |
| 215 void OobeUI::InitializeHandlers() { | 202 void OobeUI::InitializeHandlers() { |
| 216 std::vector<WebUIMessageHandler*>::iterator iter; | |
| 217 // Note, handlers_[0] is a GenericHandler used by the WebUI. | 203 // Note, handlers_[0] is a GenericHandler used by the WebUI. |
| 218 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { | 204 for (size_t i = 1; i < handlers_.size(); ++i) { |
| 219 (static_cast<OobeMessageHandler*>(*iter))->Initialize(); | 205 static_cast<OobeMessageHandler*>(handlers_[i])->Initialize(); |
| 220 } | 206 } |
| 221 } | 207 } |
| 222 | 208 |
| 223 } // namespace chromeos | 209 } // namespace chromeos |
| OLD | NEW |