Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/oobe_ui.cc

Issue 7121013: Initial implementation of network screen WebUI handler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/chromeos/login/wizard_controller.h" 11 #include "chrome/browser/chromeos/login/wizard_controller.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
14 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" 14 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
15 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
15 #include "chrome/common/jstemplate_builder.h" 16 #include "chrome/common/jstemplate_builder.h"
16 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
17 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
18 #include "grit/browser_resources.h" 19 #include "grit/browser_resources.h"
19 #include "grit/chromium_strings.h" 20 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
23 24
24 namespace { 25 namespace {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 110
110 CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui) 111 CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui)
111 : oobe_ui_(oobe_ui) { 112 : oobe_ui_(oobe_ui) {
112 } 113 }
113 114
114 CoreOobeHandler::~CoreOobeHandler() { 115 CoreOobeHandler::~CoreOobeHandler() {
115 } 116 }
116 117
117 void CoreOobeHandler::GetLocalizedSettings(DictionaryValue* localized_strings) { 118 void CoreOobeHandler::GetLocalizedSettings(DictionaryValue* localized_strings) {
118 // OOBE title is not actually seen in UI, use title of the welcome screen. 119 // 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", 120 localized_strings->SetString("welcomeScreenTitle",
Nikita (slow) 2011/06/08 08:21:23 Move this string to network screen handler.
whywhat 2011/06/08 08:29:57 Done.
124 l10n_util::GetStringFUTF16(IDS_WELCOME_SCREEN_TITLE, 121 l10n_util::GetStringFUTF16(IDS_WELCOME_SCREEN_TITLE,
125 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 122 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 } 123 }
135 124
136 void CoreOobeHandler::Initialize() { 125 void CoreOobeHandler::Initialize() {
137 } 126 }
138 127
139 void CoreOobeHandler::RegisterMessages() { 128 void CoreOobeHandler::RegisterMessages() {
140 web_ui_->RegisterMessageCallback(kJsApiScreenStateInitialize, 129 web_ui_->RegisterMessageCallback(kJsApiScreenStateInitialize,
141 NewCallback(this, &CoreOobeHandler::OnInitialized)); 130 NewCallback(this, &CoreOobeHandler::OnInitialized));
142 } 131 }
143 132
144 void CoreOobeHandler::OnInitialized(const ListValue* args) { 133 void CoreOobeHandler::OnInitialized(const ListValue* args) {
145 oobe_ui_->InitializeHandlers(); 134 oobe_ui_->InitializeHandlers();
146 } 135 }
147 136
148 // OobeUI ---------------------------------------------------------------------- 137 // OobeUI ----------------------------------------------------------------------
149 138
150 OobeUI::OobeUI(TabContents* contents) 139 OobeUI::OobeUI(TabContents* contents)
151 : ChromeWebUI(contents), 140 : ChromeWebUI(contents),
152 update_screen_actor_(NULL), 141 update_screen_actor_(NULL),
153 network_screen_actor_(NULL), 142 network_screen_actor_(NULL),
154 eula_screen_actor_(NULL) { 143 eula_screen_actor_(NULL) {
155 scoped_ptr<DictionaryValue> localized_strings(new DictionaryValue); 144 scoped_ptr<DictionaryValue> localized_strings(new DictionaryValue);
156 145
157 AddOobeMessageHandler(new CoreOobeHandler(this), localized_strings.get()); 146 AddOobeMessageHandler(new CoreOobeHandler(this), localized_strings.get());
158 147
148 NetworkScreenHandler* network_screen_handler = new NetworkScreenHandler;
149 network_screen_actor_ = network_screen_handler;
150 AddOobeMessageHandler(network_screen_handler, localized_strings.get());
151
159 EulaScreenHandler* eula_screen_handler = new EulaScreenHandler; 152 EulaScreenHandler* eula_screen_handler = new EulaScreenHandler;
160 eula_screen_actor_ = eula_screen_handler; 153 eula_screen_actor_ = eula_screen_handler;
161 AddOobeMessageHandler(eula_screen_handler, localized_strings.get()); 154 AddOobeMessageHandler(eula_screen_handler, localized_strings.get());
162 155
163 OobeUIHTMLSource* html_source = 156 OobeUIHTMLSource* html_source =
164 new OobeUIHTMLSource(localized_strings.release()); 157 new OobeUIHTMLSource(localized_strings.release());
165 // Set up the chrome://oobe/ source. 158 // Set up the chrome://oobe/ source.
166 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); 159 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
167 } 160 }
168 161
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return NULL; 199 return NULL;
207 } 200 }
208 201
209 void OobeUI::AddOobeMessageHandler(OobeMessageHandler* handler, 202 void OobeUI::AddOobeMessageHandler(OobeMessageHandler* handler,
210 DictionaryValue* localized_strings) { 203 DictionaryValue* localized_strings) {
211 AddMessageHandler(handler->Attach(this)); 204 AddMessageHandler(handler->Attach(this));
212 handler->GetLocalizedSettings(localized_strings); 205 handler->GetLocalizedSettings(localized_strings);
213 } 206 }
214 207
215 void OobeUI::InitializeHandlers() { 208 void OobeUI::InitializeHandlers() {
216 std::vector<WebUIMessageHandler*>::iterator iter;
217 // Note, handlers_[0] is a GenericHandler used by the WebUI. 209 // Note, handlers_[0] is a GenericHandler used by the WebUI.
218 for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) { 210 for (size_t i = 1; i < handlers_.size(); ++i) {
219 (static_cast<OobeMessageHandler*>(*iter))->Initialize(); 211 static_cast<OobeMessageHandler*>(handlers_[i])->Initialize();
220 } 212 }
221 } 213 }
222 214
223 } // namespace chromeos 215 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698