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

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

Issue 8113025: base::Bind: More converts, mostly in WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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/register_page_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/register_page_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/string_piece.h" 13 #include "base/string_piece.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/cros/cros_library.h" 17 #include "chrome/browser/chromeos/cros/cros_library.h"
17 #include "chrome/browser/chromeos/cros/network_library.h" 18 #include "chrome/browser/chromeos/cros/network_library.h"
18 #include "chrome/browser/chromeos/customization_document.h" 19 #include "chrome/browser/chromeos/customization_document.h"
19 #include "chrome/browser/chromeos/login/wizard_controller.h" 20 #include "chrome/browser/chromeos/login/wizard_controller.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 WebUIMessageHandler* RegisterPageHandler::Attach(WebUI* web_ui) { 199 WebUIMessageHandler* RegisterPageHandler::Attach(WebUI* web_ui) {
199 return WebUIMessageHandler::Attach(web_ui); 200 return WebUIMessageHandler::Attach(web_ui);
200 } 201 }
201 202
202 void RegisterPageHandler::Init() { 203 void RegisterPageHandler::Init() {
203 } 204 }
204 205
205 void RegisterPageHandler::RegisterMessages() { 206 void RegisterPageHandler::RegisterMessages() {
206 #if defined(OS_CHROMEOS) 207 #if defined(OS_CHROMEOS)
207 web_ui_->RegisterMessageCallback(kJsCallbackGetRegistrationUrl, 208 web_ui_->RegisterMessageCallback(kJsCallbackGetRegistrationUrl,
208 NewCallback(this, &RegisterPageHandler::HandleGetRegistrationUrl)); 209 base::Bind(&RegisterPageHandler::HandleGetRegistrationUrl,
210 base::Unretained(this)));
209 web_ui_->RegisterMessageCallback(kJsCallbackUserInfo, 211 web_ui_->RegisterMessageCallback(kJsCallbackUserInfo,
210 NewCallback(this, &RegisterPageHandler::HandleGetUserInfo)); 212 base::Bind(&RegisterPageHandler::HandleGetUserInfo,
213 base::Unretained(this)));
211 #endif 214 #endif
212 } 215 }
213 216
214 void RegisterPageHandler::HandleGetRegistrationUrl(const ListValue* args) { 217 void RegisterPageHandler::HandleGetRegistrationUrl(const ListValue* args) {
215 #if defined(OS_CHROMEOS) 218 #if defined(OS_CHROMEOS)
216 chromeos::StartupCustomizationDocument* customization = 219 chromeos::StartupCustomizationDocument* customization =
217 chromeos::StartupCustomizationDocument::GetInstance(); 220 chromeos::StartupCustomizationDocument::GetInstance();
218 if (chromeos::WizardController::default_controller() && 221 if (chromeos::WizardController::default_controller() &&
219 customization->IsReady()) { 222 customization->IsReady()) {
220 const std::string& url = customization->registration_url(); 223 const std::string& url = customization->registration_url();
221 VLOG(1) << "Loading registration form with URL: " << url; 224 VLOG(1) << "Loading registration form with URL: " << url;
222 GURL register_url(url); 225 GURL register_url(url);
223 if (!register_url.is_valid()) { 226 if (!register_url.is_valid()) {
224 SkipRegistration("Registration URL defined in manifest is invalid."); 227 SkipRegistration("Registration URL defined in manifest is invalid.");
225 return; 228 return;
226 } 229 }
227 StringValue url_value(url); 230 StringValue url_value(url);
228 web_ui_->CallJavascriptFunction(kJsApiSetRegistrationUrl, url_value); 231 web_ui_->CallJavascriptFunction(kJsApiSetRegistrationUrl, url_value);
229 } else { 232 } else {
230 SkipRegistration("Startup manifest not defined."); 233 SkipRegistration("Startup manifest not defined.");
231 } 234 }
232 #endif 235 #endif
233 } 236 }
234 237
235 void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) { 238 void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) {
236 #if defined(OS_CHROMEOS) 239 #if defined(OS_CHROMEOS)
237 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { 240 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) {
238 version_loader_.GetVersion( 241 version_loader_.GetVersion(
239 &version_consumer_, 242 &version_consumer_,
240 NewCallback(this, 243 base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)),
241 &RegisterPageHandler::OnVersion),
242 chromeos::VersionLoader::VERSION_FULL); 244 chromeos::VersionLoader::VERSION_FULL);
243 } else { 245 } else {
244 SkipRegistration("CrosLibrary is not loaded."); 246 SkipRegistration("CrosLibrary is not loaded.");
245 } 247 }
246 #endif 248 #endif
247 } 249 }
248 250
249 #if defined(OS_CHROMEOS) 251 #if defined(OS_CHROMEOS)
250 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle, 252 void RegisterPageHandler::OnVersion(chromeos::VersionLoader::Handle handle,
251 std::string version) { 253 std::string version) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 RegisterPageUI::RegisterPageUI(TabContents* contents) : ChromeWebUI(contents) { 308 RegisterPageUI::RegisterPageUI(TabContents* contents) : ChromeWebUI(contents) {
307 RegisterPageHandler* handler = new RegisterPageHandler(); 309 RegisterPageHandler* handler = new RegisterPageHandler();
308 AddMessageHandler((handler)->Attach(this)); 310 AddMessageHandler((handler)->Attach(this));
309 handler->Init(); 311 handler->Init();
310 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource(); 312 RegisterPageUIHTMLSource* html_source = new RegisterPageUIHTMLSource();
311 313
312 // Set up the chrome://register/ source. 314 // Set up the chrome://register/ source.
313 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 315 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
314 profile->GetChromeURLDataManager()->AddDataSource(html_source); 316 profile->GetChromeURLDataManager()->AddDataSource(html_source);
315 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698