OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 } | 408 } |
409 | 409 |
410 bool SyncSetupHandler::IsActiveLogin() const { | 410 bool SyncSetupHandler::IsActiveLogin() const { |
411 // LoginUIService can be NULL if page is brought up in incognito mode | 411 // LoginUIService can be NULL if page is brought up in incognito mode |
412 // (i.e. if the user is running in guest mode in cros and brings up settings). | 412 // (i.e. if the user is running in guest mode in cros and brings up settings). |
413 LoginUIService* service = GetLoginUIService(); | 413 LoginUIService* service = GetLoginUIService(); |
414 return service && (service->current_login_ui() == web_ui()); | 414 return service && (service->current_login_ui() == web_ui()); |
415 } | 415 } |
416 | 416 |
417 void SyncSetupHandler::RegisterMessages() { | 417 void SyncSetupHandler::RegisterMessages() { |
418 web_ui()->RegisterMessageCallback("SyncSetupDidClosePage", | 418 web_ui()->RegisterMessageCallback( |
| 419 "SyncSetupDidClosePage", |
419 base::Bind(&SyncSetupHandler::OnDidClosePage, | 420 base::Bind(&SyncSetupHandler::OnDidClosePage, |
420 base::Unretained(this))); | 421 base::Unretained(this))); |
421 web_ui()->RegisterMessageCallback("SyncSetupSubmitAuth", | 422 web_ui()->RegisterMessageCallback( |
| 423 "SyncSetupSubmitAuth", |
422 base::Bind(&SyncSetupHandler::HandleSubmitAuth, | 424 base::Bind(&SyncSetupHandler::HandleSubmitAuth, |
423 base::Unretained(this))); | 425 base::Unretained(this))); |
424 web_ui()->RegisterMessageCallback("SyncSetupConfigure", | 426 web_ui()->RegisterMessageCallback( |
| 427 "SyncSetupConfigure", |
425 base::Bind(&SyncSetupHandler::HandleConfigure, | 428 base::Bind(&SyncSetupHandler::HandleConfigure, |
426 base::Unretained(this))); | 429 base::Unretained(this))); |
427 web_ui()->RegisterMessageCallback("SyncSetupAttachHandler", | 430 web_ui()->RegisterMessageCallback( |
| 431 "SyncSetupAttachHandler", |
428 base::Bind(&SyncSetupHandler::HandleAttachHandler, | 432 base::Bind(&SyncSetupHandler::HandleAttachHandler, |
429 base::Unretained(this))); | 433 base::Unretained(this))); |
430 web_ui()->RegisterMessageCallback("SyncSetupShowErrorUI", | 434 web_ui()->RegisterMessageCallback( |
| 435 "SyncSetupShowErrorUI", |
431 base::Bind(&SyncSetupHandler::HandleShowErrorUI, | 436 base::Bind(&SyncSetupHandler::HandleShowErrorUI, |
432 base::Unretained(this))); | 437 base::Unretained(this))); |
433 web_ui()->RegisterMessageCallback("SyncSetupShowSetupUI", | 438 web_ui()->RegisterMessageCallback( |
| 439 "SyncSetupShowSetupUI", |
434 base::Bind(&SyncSetupHandler::HandleShowSetupUI, | 440 base::Bind(&SyncSetupHandler::HandleShowSetupUI, |
435 base::Unretained(this))); | 441 base::Unretained(this))); |
436 } | 442 } |
437 | 443 |
438 SigninManager* SyncSetupHandler::GetSignin() const { | 444 SigninManager* SyncSetupHandler::GetSignin() const { |
439 return SigninManagerFactory::GetForProfile(GetProfile()); | 445 return SigninManagerFactory::GetForProfile(GetProfile()); |
440 } | 446 } |
441 | 447 |
442 void SyncSetupHandler::DisplayGaiaLogin(bool fatal_error) { | 448 void SyncSetupHandler::DisplayGaiaLogin(bool fatal_error) { |
443 DisplayGaiaLoginWithErrorMessage(string16(), fatal_error); | 449 DisplayGaiaLoginWithErrorMessage(string16(), fatal_error); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 if (i != current_profile_index && AreUserNamesEqual( | 903 if (i != current_profile_index && AreUserNamesEqual( |
898 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 904 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
899 *error_message = l10n_util::GetStringUTF16( | 905 *error_message = l10n_util::GetStringUTF16( |
900 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 906 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
901 return false; | 907 return false; |
902 } | 908 } |
903 } | 909 } |
904 | 910 |
905 return true; | 911 return true; |
906 } | 912 } |
OLD | NEW |