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

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

Issue 9224002: Make WebUI objects not derive from WebUI. WebUI objects own the controller. This is the ownership... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head to clear linux_chromeos browsertest failures Created 8 years, 11 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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" 24 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
25 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h" 25 #include "chrome/browser/ui/webui/chromeos/login/network_dropdown_handler.h"
26 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" 26 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
27 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 27 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
28 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" 28 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
29 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" 29 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
30 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" 30 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h"
31 #include "chrome/browser/ui/webui/theme_source.h" 31 #include "chrome/browser/ui/webui/theme_source.h"
32 #include "chrome/common/jstemplate_builder.h" 32 #include "chrome/common/jstemplate_builder.h"
33 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
34 #include "content/browser/webui/web_ui.h"
34 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
35 #include "grit/browser_resources.h" 36 #include "grit/browser_resources.h"
36 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
37 38
38 using content::WebContents; 39 using content::WebContents;
39 40
40 namespace { 41 namespace {
41 42
42 // Path for a stripped down login page that does not have OOBE elements. 43 // Path for a stripped down login page that does not have OOBE elements.
43 const char kLoginPath[] = "login"; 44 const char kLoginPath[] = "login";
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 std::string OobeUIHTMLSource::GetDataResource(int resource_id) const { 103 std::string OobeUIHTMLSource::GetDataResource(int resource_id) const {
103 const base::StringPiece html( 104 const base::StringPiece html(
104 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 105 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
105 return jstemplate_builder::GetI18nTemplateHtml(html, 106 return jstemplate_builder::GetI18nTemplateHtml(html,
106 localized_strings_.get()); 107 localized_strings_.get());
107 } 108 }
108 109
109 // OobeUI ---------------------------------------------------------------------- 110 // OobeUI ----------------------------------------------------------------------
110 111
111 OobeUI::OobeUI(WebContents* contents) 112 OobeUI::OobeUI(WebUI* web_ui)
112 : WebUI(contents, this), 113 : WebUIController(web_ui),
113 update_screen_actor_(NULL), 114 update_screen_actor_(NULL),
114 network_screen_actor_(NULL), 115 network_screen_actor_(NULL),
115 eula_screen_actor_(NULL), 116 eula_screen_actor_(NULL),
116 signin_screen_handler_(NULL), 117 signin_screen_handler_(NULL),
117 user_image_screen_actor_(NULL) { 118 user_image_screen_actor_(NULL) {
118 core_handler_ = new CoreOobeHandler(this); 119 core_handler_ = new CoreOobeHandler(this);
119 AddScreenHandler(core_handler_); 120 AddScreenHandler(core_handler_);
120 121
121 AddScreenHandler(new NetworkDropdownHandler); 122 AddScreenHandler(new NetworkDropdownHandler);
122 123
(...skipping 20 matching lines...) Expand all
143 new UserImageScreenHandler(); 144 new UserImageScreenHandler();
144 user_image_screen_actor_ = user_image_screen_handler; 145 user_image_screen_actor_ = user_image_screen_handler;
145 AddScreenHandler(user_image_screen_handler); 146 AddScreenHandler(user_image_screen_handler);
146 147
147 signin_screen_handler_ = new SigninScreenHandler; 148 signin_screen_handler_ = new SigninScreenHandler;
148 AddScreenHandler(signin_screen_handler_); 149 AddScreenHandler(signin_screen_handler_);
149 150
150 DictionaryValue* localized_strings = new DictionaryValue(); 151 DictionaryValue* localized_strings = new DictionaryValue();
151 GetLocalizedStrings(localized_strings); 152 GetLocalizedStrings(localized_strings);
152 153
153 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 154 Profile* profile = Profile::FromBrowserContext(
155 web_ui->web_contents()->GetBrowserContext());
154 // Set up the chrome://theme/ source, for Chrome logo. 156 // Set up the chrome://theme/ source, for Chrome logo.
155 ThemeSource* theme = new ThemeSource(profile); 157 ThemeSource* theme = new ThemeSource(profile);
156 profile->GetChromeURLDataManager()->AddDataSource(theme); 158 profile->GetChromeURLDataManager()->AddDataSource(theme);
157 159
158 // Set up the chrome://terms/ data source, for EULA content. 160 // Set up the chrome://terms/ data source, for EULA content.
159 AboutUIHTMLSource* about_source = 161 AboutUIHTMLSource* about_source =
160 new AboutUIHTMLSource(chrome::kChromeUITermsHost, profile); 162 new AboutUIHTMLSource(chrome::kChromeUITermsHost, profile);
161 profile->GetChromeURLDataManager()->AddDataSource(about_source); 163 profile->GetChromeURLDataManager()->AddDataSource(about_source);
162 164
163 // Set up the chrome://oobe/ source. 165 // Set up the chrome://oobe/ source.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 207
206 ViewScreenDelegate* OobeUI::GetHTMLPageScreenActor() { 208 ViewScreenDelegate* OobeUI::GetHTMLPageScreenActor() {
207 // WebUI implementation of the LoginDisplayHost opens HTML page directly, 209 // WebUI implementation of the LoginDisplayHost opens HTML page directly,
208 // without opening OOBE page. 210 // without opening OOBE page.
209 NOTREACHED(); 211 NOTREACHED();
210 return NULL; 212 return NULL;
211 } 213 }
212 214
213 void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) { 215 void OobeUI::GetLocalizedStrings(base::DictionaryValue* localized_strings) {
214 // Note, handlers_[0] is a GenericHandler used by the WebUI. 216 // Note, handlers_[0] is a GenericHandler used by the WebUI.
215 for (size_t i = 1; i < handlers_.size(); ++i) { 217 for (size_t i = 0; i < handlers_.size(); ++i)
216 static_cast<BaseScreenHandler*>(handlers_[i])-> 218 handlers_[i]->GetLocalizedStrings(localized_strings);
217 GetLocalizedStrings(localized_strings);
218 }
219 ChromeURLDataManager::DataSource::SetFontAndTextDirection(localized_strings); 219 ChromeURLDataManager::DataSource::SetFontAndTextDirection(localized_strings);
220 } 220 }
221 221
222 void OobeUI::AddScreenHandler(BaseScreenHandler* handler) { 222 void OobeUI::AddScreenHandler(BaseScreenHandler* handler) {
223 AddMessageHandler(handler); 223 web_ui()->AddMessageHandler(handler);
224 handlers_.push_back(handler);
224 } 225 }
225 226
226 void OobeUI::InitializeHandlers() { 227 void OobeUI::InitializeHandlers() {
227 // Note, handlers_[0] is a GenericHandler used by the WebUI. 228 for (size_t i = 0; i < handlers_.size(); ++i)
228 for (size_t i = 1; i < handlers_.size(); ++i) { 229 handlers_[i]->InitializeBase();
229 static_cast<BaseScreenHandler*>(handlers_[i])->InitializeBase();
230 }
231 } 230 }
232 231
233 void OobeUI::ShowOobeUI(bool show) { 232 void OobeUI::ShowOobeUI(bool show) {
234 core_handler_->ShowOobeUI(show); 233 core_handler_->ShowOobeUI(show);
235 } 234 }
236 235
237 void OobeUI::ShowSigninScreen(SigninScreenHandlerDelegate* delegate) { 236 void OobeUI::ShowSigninScreen(SigninScreenHandlerDelegate* delegate) {
238 signin_screen_handler_->SetDelegate(delegate); 237 signin_screen_handler_->SetDelegate(delegate);
239 signin_screen_handler_->Show(core_handler_->show_oobe_ui()); 238 signin_screen_handler_->Show(core_handler_->show_oobe_ui());
240 } 239 }
241 240
242 void OobeUI::ResetSigninScreenHandlerDelegate() { 241 void OobeUI::ResetSigninScreenHandlerDelegate() {
243 signin_screen_handler_->SetDelegate(NULL); 242 signin_screen_handler_->SetDelegate(NULL);
244 } 243 }
245 244
246 void OobeUI::OnLoginPromptVisible() { 245 void OobeUI::OnLoginPromptVisible() {
247 user_image_screen_actor_->CheckCameraPresence(); 246 user_image_screen_actor_->CheckCameraPresence();
248 } 247 }
249 248
250 } // namespace chromeos 249 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698