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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 base::Unretained(this))); | 571 base::Unretained(this))); |
572 web_ui()->RegisterMessageCallback( | 572 web_ui()->RegisterMessageCallback( |
573 "SyncSetupSubmitAuth", | 573 "SyncSetupSubmitAuth", |
574 base::Bind(&SyncSetupHandler::HandleSubmitAuth, | 574 base::Bind(&SyncSetupHandler::HandleSubmitAuth, |
575 base::Unretained(this))); | 575 base::Unretained(this))); |
576 web_ui()->RegisterMessageCallback( | 576 web_ui()->RegisterMessageCallback( |
577 "SyncSetupConfigure", | 577 "SyncSetupConfigure", |
578 base::Bind(&SyncSetupHandler::HandleConfigure, | 578 base::Bind(&SyncSetupHandler::HandleConfigure, |
579 base::Unretained(this))); | 579 base::Unretained(this))); |
580 web_ui()->RegisterMessageCallback( | 580 web_ui()->RegisterMessageCallback( |
581 "SyncSetupAttachHandler", | |
582 base::Bind(&SyncSetupHandler::HandleAttachHandler, | |
583 base::Unretained(this))); | |
584 web_ui()->RegisterMessageCallback( | |
585 "SyncSetupShowErrorUI", | 581 "SyncSetupShowErrorUI", |
586 base::Bind(&SyncSetupHandler::HandleShowErrorUI, | 582 base::Bind(&SyncSetupHandler::HandleShowErrorUI, |
587 base::Unretained(this))); | 583 base::Unretained(this))); |
588 web_ui()->RegisterMessageCallback( | 584 web_ui()->RegisterMessageCallback( |
589 "SyncSetupShowSetupUI", | 585 "SyncSetupShowSetupUI", |
590 base::Bind(&SyncSetupHandler::HandleShowSetupUI, | 586 base::Bind(&SyncSetupHandler::HandleShowSetupUI, |
591 base::Unretained(this))); | 587 base::Unretained(this))); |
592 web_ui()->RegisterMessageCallback( | 588 web_ui()->RegisterMessageCallback( |
593 "SyncSetupShowSetupUIWithoutLogin", | 589 "SyncSetupShowSetupUIWithoutLogin", |
594 base::Bind(&SyncSetupHandler::HandleShowSetupUIWithoutLogin, | 590 base::Bind(&SyncSetupHandler::HandleShowSetupUIWithoutLogin, |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 | 1025 |
1030 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CUSTOMIZE); | 1026 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CUSTOMIZE); |
1031 if (configuration.encrypt_all) | 1027 if (configuration.encrypt_all) |
1032 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_ENCRYPT); | 1028 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_ENCRYPT); |
1033 if (configuration.passphrase_is_gaia && !configuration.passphrase.empty()) | 1029 if (configuration.passphrase_is_gaia && !configuration.passphrase.empty()) |
1034 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_PASSPHRASE); | 1030 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_PASSPHRASE); |
1035 if (!configuration.sync_everything) | 1031 if (!configuration.sync_everything) |
1036 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CHOOSE); | 1032 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CHOOSE); |
1037 } | 1033 } |
1038 | 1034 |
1039 void SyncSetupHandler::HandleAttachHandler(const ListValue* args) { | |
1040 bool force_login = false; | |
1041 std::string json; | |
1042 if (args->GetString(0, &json) && !json.empty()) { | |
1043 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json)); | |
1044 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); | |
1045 result->GetBoolean("forceLogin", &force_login); | |
1046 } | |
1047 | |
1048 OpenSyncSetup(force_login); | |
1049 } | |
1050 | |
1051 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) { | 1035 void SyncSetupHandler::HandleShowErrorUI(const ListValue* args) { |
1052 DCHECK(!configuring_sync_); | 1036 DCHECK(!configuring_sync_); |
1053 | 1037 |
1054 ProfileSyncService* service = GetSyncService(); | 1038 ProfileSyncService* service = GetSyncService(); |
1055 DCHECK(service); | 1039 DCHECK(service); |
1056 | 1040 |
1057 // Bring up the existing wizard, or just display it on this page. | 1041 // Bring up the existing wizard, or just display it on this page. |
1058 if (!FocusExistingWizardIfPresent()) | 1042 if (!FocusExistingWizardIfPresent()) |
1059 OpenSyncSetup(false); | 1043 OpenSyncSetup(false); |
1060 } | 1044 } |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 if (i != current_profile_index && AreUserNamesEqual( | 1311 if (i != current_profile_index && AreUserNamesEqual( |
1328 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 1312 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
1329 *error_message = l10n_util::GetStringUTF16( | 1313 *error_message = l10n_util::GetStringUTF16( |
1330 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1314 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
1331 return false; | 1315 return false; |
1332 } | 1316 } |
1333 } | 1317 } |
1334 | 1318 |
1335 return true; | 1319 return true; |
1336 } | 1320 } |
OLD | NEW |