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

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

Issue 7382001: [ChromeOS] WebUI OOBE/Login refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync and address comments in set #1 Created 9 years, 5 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/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_about_handler.h" 12 #include "chrome/browser/browser_about_handler.h"
13 #include "chrome/browser/chromeos/login/wizard_controller.h" 13 #include "chrome/browser/chromeos/login/wizard_controller.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
16 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
16 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" 17 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
17 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" 18 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
18 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 19 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
19 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" 20 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
20 #include "chrome/browser/ui/webui/theme_source.h" 21 #include "chrome/browser/ui/webui/theme_source.h"
21 #include "chrome/common/jstemplate_builder.h" 22 #include "chrome/common/jstemplate_builder.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "content/browser/tab_contents/tab_contents.h" 24 #include "content/browser/tab_contents/tab_contents.h"
24 #include "grit/browser_resources.h" 25 #include "grit/browser_resources.h"
25 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
(...skipping 23 matching lines...) Expand all
49 return "text/html"; 50 return "text/html";
50 } 51 }
51 52
52 private: 53 private:
53 virtual ~OobeUIHTMLSource() {} 54 virtual ~OobeUIHTMLSource() {}
54 55
55 scoped_ptr<DictionaryValue> localized_strings_; 56 scoped_ptr<DictionaryValue> localized_strings_;
56 DISALLOW_COPY_AND_ASSIGN(OobeUIHTMLSource); 57 DISALLOW_COPY_AND_ASSIGN(OobeUIHTMLSource);
57 }; 58 };
58 59
59 // OobeMessageHandler ----------------------------------------------------------
60 OobeMessageHandler::OobeMessageHandler() : page_is_ready_(false) {
61 }
62
63 OobeMessageHandler::~OobeMessageHandler() {
64 }
65
66 void OobeMessageHandler::InitializeBase() {
67 page_is_ready_ = true;
68 Initialize();
69 }
70
71 // CoreOobeHandler ------------------------------------------------------------- 60 // CoreOobeHandler -------------------------------------------------------------
72 61
73 // The core handler for Javascript messages related to the "oobe" view. 62 // The core handler for Javascript messages related to the "oobe" view.
74 class CoreOobeHandler : public OobeMessageHandler { 63 class CoreOobeHandler : public BaseScreenHandler {
75 public: 64 public:
76 explicit CoreOobeHandler(OobeUI* oobe_ui); 65 explicit CoreOobeHandler(OobeUI* oobe_ui);
77 virtual ~CoreOobeHandler(); 66 virtual ~CoreOobeHandler();
78 67
79 // OobeMessageHandler implementation: 68 // BaseScreenHandler implementation:
80 virtual void GetLocalizedStrings(DictionaryValue* localized_strings); 69 virtual void GetLocalizedStrings(DictionaryValue* localized_strings);
81 virtual void Initialize(); 70 virtual void Initialize();
82 71
83 // WebUIMessageHandler implementation. 72 // WebUIMessageHandler implementation.
84 virtual void RegisterMessages(); 73 virtual void RegisterMessages();
85 74
86 private: 75 private:
87 // Handlers for JS WebUI messages. 76 // Handlers for JS WebUI messages.
88 void OnInitialized(const ListValue* args); 77 void OnInitialized(const ListValue* args);
89 78
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 131 }
143 132
144 // OobeUI ---------------------------------------------------------------------- 133 // OobeUI ----------------------------------------------------------------------
145 134
146 OobeUI::OobeUI(TabContents* contents) 135 OobeUI::OobeUI(TabContents* contents)
147 : ChromeWebUI(contents), 136 : ChromeWebUI(contents),
148 update_screen_actor_(NULL), 137 update_screen_actor_(NULL),
149 network_screen_actor_(NULL), 138 network_screen_actor_(NULL),
150 eula_screen_actor_(NULL), 139 eula_screen_actor_(NULL),
151 signin_screen_handler_(NULL) { 140 signin_screen_handler_(NULL) {
152 AddOobeMessageHandler(new CoreOobeHandler(this)); 141 AddScreenHandler(new CoreOobeHandler(this));
153 142
154 NetworkScreenHandler* network_screen_handler = new NetworkScreenHandler; 143 NetworkScreenHandler* network_screen_handler = new NetworkScreenHandler;
155 network_screen_actor_ = network_screen_handler; 144 network_screen_actor_ = network_screen_handler;
156 AddOobeMessageHandler(network_screen_handler); 145 AddScreenHandler(network_screen_handler);
157 146
158 EulaScreenHandler* eula_screen_handler = new EulaScreenHandler; 147 EulaScreenHandler* eula_screen_handler = new EulaScreenHandler;
159 eula_screen_actor_ = eula_screen_handler; 148 eula_screen_actor_ = eula_screen_handler;
160 AddOobeMessageHandler(eula_screen_handler); 149 AddScreenHandler(eula_screen_handler);
161 150
162 UpdateScreenHandler* update_screen_handler = new UpdateScreenHandler; 151 UpdateScreenHandler* update_screen_handler = new UpdateScreenHandler;
163 update_screen_actor_ = update_screen_handler; 152 update_screen_actor_ = update_screen_handler;
164 AddOobeMessageHandler(update_screen_handler); 153 AddScreenHandler(update_screen_handler);
165 154
166 signin_screen_handler_ = new SigninScreenHandler; 155 signin_screen_handler_ = new SigninScreenHandler;
167 AddOobeMessageHandler(signin_screen_handler_); 156 AddScreenHandler(signin_screen_handler_);
168 157
169 DictionaryValue* localized_strings = new DictionaryValue; 158 DictionaryValue* localized_strings = new DictionaryValue;
170 GetLocalizedStrings(localized_strings); 159 GetLocalizedStrings(localized_strings);
171 OobeUIHTMLSource* html_source = 160 OobeUIHTMLSource* html_source =
172 new OobeUIHTMLSource(localized_strings); 161 new OobeUIHTMLSource(localized_strings);
173 162
174 // Set up the chrome://theme/ source, for Chrome logo. 163 // Set up the chrome://theme/ source, for Chrome logo.
175 ThemeSource* theme = new ThemeSource(contents->profile()); 164 ThemeSource* theme = new ThemeSource(contents->profile());
176 contents->profile()->GetChromeURLDataManager()->AddDataSource(theme); 165 contents->profile()->GetChromeURLDataManager()->AddDataSource(theme);
177 166
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 207 }
219 208
220 ViewScreenDelegate* OobeUI::GetHTMLPageScreenActor() { 209 ViewScreenDelegate* OobeUI::GetHTMLPageScreenActor() {
221 NOTIMPLEMENTED(); 210 NOTIMPLEMENTED();
222 return NULL; 211 return NULL;
223 } 212 }
224 213
225 void OobeUI::GetLocalizedStrings(DictionaryValue* localized_strings) { 214 void OobeUI::GetLocalizedStrings(DictionaryValue* localized_strings) {
226 // Note, handlers_[0] is a GenericHandler used by the WebUI. 215 // Note, handlers_[0] is a GenericHandler used by the WebUI.
227 for (size_t i = 1; i < handlers_.size(); ++i) { 216 for (size_t i = 1; i < handlers_.size(); ++i) {
228 static_cast<OobeMessageHandler*>(handlers_[i])-> 217 static_cast<BaseScreenHandler*>(handlers_[i])->
229 GetLocalizedStrings(localized_strings); 218 GetLocalizedStrings(localized_strings);
230 } 219 }
231 ChromeURLDataManager::DataSource::SetFontAndTextDirection(localized_strings); 220 ChromeURLDataManager::DataSource::SetFontAndTextDirection(localized_strings);
232 } 221 }
233 222
234 void OobeUI::AddOobeMessageHandler(OobeMessageHandler* handler) { 223 void OobeUI::AddScreenHandler(BaseScreenHandler* handler) {
235 AddMessageHandler(handler->Attach(this)); 224 AddMessageHandler(handler->Attach(this));
236 } 225 }
237 226
238 void OobeUI::InitializeHandlers() { 227 void OobeUI::InitializeHandlers() {
239 // Note, handlers_[0] is a GenericHandler used by the WebUI. 228 // Note, handlers_[0] is a GenericHandler used by the WebUI.
240 for (size_t i = 1; i < handlers_.size(); ++i) { 229 for (size_t i = 1; i < handlers_.size(); ++i) {
241 static_cast<OobeMessageHandler*>(handlers_[i])->InitializeBase(); 230 static_cast<BaseScreenHandler*>(handlers_[i])->InitializeBase();
242 } 231 }
243 } 232 }
244 233
245 void OobeUI::ShowSigninScreen() { 234 void OobeUI::ShowSigninScreen() {
246 signin_screen_handler_->Show(); 235 signin_screen_handler_->Show();
247 } 236 }
248 237
249 } // namespace chromeos 238 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698