| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/settings/people_handler.h" | 5 #include "chrome/browser/ui/webui/settings/people_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // Stop a timer to handle timeout in waiting for checking network connection. | 349 // Stop a timer to handle timeout in waiting for checking network connection. |
| 350 backend_start_timer_.reset(); | 350 backend_start_timer_.reset(); |
| 351 | 351 |
| 352 // Just close the sync overlay (the idea is that the base settings page will | 352 // Just close the sync overlay (the idea is that the base settings page will |
| 353 // display the current error.) | 353 // display the current error.) |
| 354 CloseUI(); | 354 CloseUI(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void PeopleHandler::SyncStartupCompleted() { | 357 void PeopleHandler::SyncStartupCompleted() { |
| 358 ProfileSyncService* service = GetSyncService(); | 358 ProfileSyncService* service = GetSyncService(); |
| 359 DCHECK(service->IsBackendInitialized()); | 359 DCHECK(service->IsEngineInitialized()); |
| 360 | 360 |
| 361 // Stop a timer to handle timeout in waiting for checking network connection. | 361 // Stop a timer to handle timeout in waiting for checking network connection. |
| 362 backend_start_timer_.reset(); | 362 backend_start_timer_.reset(); |
| 363 | 363 |
| 364 sync_startup_tracker_.reset(); | 364 sync_startup_tracker_.reset(); |
| 365 | 365 |
| 366 PushSyncPrefs(); | 366 PushSyncPrefs(); |
| 367 } | 367 } |
| 368 | 368 |
| 369 ProfileSyncService* PeopleHandler::GetSyncService() const { | 369 ProfileSyncService* PeopleHandler::GetSyncService() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 382 PrefService* pref_service = profile_->GetPrefs(); | 382 PrefService* pref_service = profile_->GetPrefs(); |
| 383 pref_service->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, | 383 pref_service->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled, |
| 384 configuration.payments_integration_enabled); | 384 configuration.payments_integration_enabled); |
| 385 | 385 |
| 386 // Start configuring the ProfileSyncService using the configuration passed | 386 // Start configuring the ProfileSyncService using the configuration passed |
| 387 // to us from the JS layer. | 387 // to us from the JS layer. |
| 388 ProfileSyncService* service = GetSyncService(); | 388 ProfileSyncService* service = GetSyncService(); |
| 389 | 389 |
| 390 // If the sync engine has shutdown for some reason, just close the sync | 390 // If the sync engine has shutdown for some reason, just close the sync |
| 391 // dialog. | 391 // dialog. |
| 392 if (!service || !service->IsBackendInitialized()) { | 392 if (!service || !service->IsEngineInitialized()) { |
| 393 CloseSyncSetup(); | 393 CloseSyncSetup(); |
| 394 ResolveJavascriptCallback(*callback_id, base::StringValue(kDonePageStatus)); | 394 ResolveJavascriptCallback(*callback_id, base::StringValue(kDonePageStatus)); |
| 395 return; | 395 return; |
| 396 } | 396 } |
| 397 | 397 |
| 398 service->OnUserChoseDatatypes(configuration.sync_everything, | 398 service->OnUserChoseDatatypes(configuration.sync_everything, |
| 399 configuration.data_types); | 399 configuration.data_types); |
| 400 | 400 |
| 401 // Choosing data types to sync never fails. | 401 // Choosing data types to sync never fails. |
| 402 ResolveJavascriptCallback(*callback_id, | 402 ResolveJavascriptCallback(*callback_id, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 413 SyncConfigInfo configuration; | 413 SyncConfigInfo configuration; |
| 414 const base::Value* callback_id = nullptr; | 414 const base::Value* callback_id = nullptr; |
| 415 ParseConfigurationArguments(args, &configuration, &callback_id); | 415 ParseConfigurationArguments(args, &configuration, &callback_id); |
| 416 | 416 |
| 417 // Start configuring the ProfileSyncService using the configuration passed | 417 // Start configuring the ProfileSyncService using the configuration passed |
| 418 // to us from the JS layer. | 418 // to us from the JS layer. |
| 419 ProfileSyncService* service = GetSyncService(); | 419 ProfileSyncService* service = GetSyncService(); |
| 420 | 420 |
| 421 // If the sync engine has shutdown for some reason, just close the sync | 421 // If the sync engine has shutdown for some reason, just close the sync |
| 422 // dialog. | 422 // dialog. |
| 423 if (!service || !service->IsBackendInitialized()) { | 423 if (!service || !service->IsEngineInitialized()) { |
| 424 CloseSyncSetup(); | 424 CloseSyncSetup(); |
| 425 ResolveJavascriptCallback(*callback_id, base::StringValue(kDonePageStatus)); | 425 ResolveJavascriptCallback(*callback_id, base::StringValue(kDonePageStatus)); |
| 426 return; | 426 return; |
| 427 } | 427 } |
| 428 | 428 |
| 429 // Don't allow "encrypt all" if the ProfileSyncService doesn't allow it. | 429 // Don't allow "encrypt all" if the ProfileSyncService doesn't allow it. |
| 430 // The UI is hidden, but the user may have enabled it e.g. by fiddling with | 430 // The UI is hidden, but the user may have enabled it e.g. by fiddling with |
| 431 // the web inspector. | 431 // the web inspector. |
| 432 if (!service->IsEncryptEverythingAllowed()) | 432 if (!service->IsEncryptEverythingAllowed()) |
| 433 configuration.encrypt_all = false; | 433 configuration.encrypt_all = false; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 return; | 772 return; |
| 773 } | 773 } |
| 774 #endif | 774 #endif |
| 775 | 775 |
| 776 // Early exit if there is already a preferences push pending sync startup. | 776 // Early exit if there is already a preferences push pending sync startup. |
| 777 if (sync_startup_tracker_) | 777 if (sync_startup_tracker_) |
| 778 return; | 778 return; |
| 779 | 779 |
| 780 ProfileSyncService* service = GetSyncService(); | 780 ProfileSyncService* service = GetSyncService(); |
| 781 DCHECK(service); | 781 DCHECK(service); |
| 782 if (!service->IsBackendInitialized()) { | 782 if (!service->IsEngineInitialized()) { |
| 783 service->RequestStart(); | 783 service->RequestStart(); |
| 784 | 784 |
| 785 // See if it's even possible to bring up the sync backend - if not | 785 // See if it's even possible to bring up the sync backend - if not |
| 786 // (unrecoverable error?), don't bother displaying a spinner that will be | 786 // (unrecoverable error?), don't bother displaying a spinner that will be |
| 787 // immediately closed because this leads to some ugly infinite UI loop (see | 787 // immediately closed because this leads to some ugly infinite UI loop (see |
| 788 // http://crbug.com/244769). | 788 // http://crbug.com/244769). |
| 789 if (SyncStartupTracker::GetSyncServiceState(profile_) != | 789 if (SyncStartupTracker::GetSyncServiceState(profile_) != |
| 790 SyncStartupTracker::SYNC_STARTUP_ERROR) { | 790 SyncStartupTracker::SYNC_STARTUP_ERROR) { |
| 791 DisplaySpinner(); | 791 DisplaySpinner(); |
| 792 } | 792 } |
| 793 | 793 |
| 794 // Start SyncSetupTracker to wait for sync to initialize. | 794 // Start SyncSetupTracker to wait for sync to initialize. |
| 795 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this)); | 795 sync_startup_tracker_.reset(new SyncStartupTracker(profile_, this)); |
| 796 return; | 796 return; |
| 797 } | 797 } |
| 798 | 798 |
| 799 configuring_sync_ = true; | 799 configuring_sync_ = true; |
| 800 DCHECK(service->IsBackendInitialized()) | 800 DCHECK(service->IsEngineInitialized()) |
| 801 << "Cannot configure sync until the sync backend is initialized"; | 801 << "Cannot configure sync until the sync backend is initialized"; |
| 802 | 802 |
| 803 // Setup args for the sync configure screen: | 803 // Setup args for the sync configure screen: |
| 804 // syncAllDataTypes: true if the user wants to sync everything | 804 // syncAllDataTypes: true if the user wants to sync everything |
| 805 // <data_type>Registered: true if the associated data type is supported | 805 // <data_type>Registered: true if the associated data type is supported |
| 806 // <data_type>Synced: true if the user wants to sync that specific data type | 806 // <data_type>Synced: true if the user wants to sync that specific data type |
| 807 // paymentsIntegrationEnabled: true if the user wants Payments integration | 807 // paymentsIntegrationEnabled: true if the user wants Payments integration |
| 808 // encryptionEnabled: true if sync supports encryption | 808 // encryptionEnabled: true if sync supports encryption |
| 809 // encryptAllData: true if user wants to encrypt all data (not just | 809 // encryptAllData: true if user wants to encrypt all data (not just |
| 810 // passwords) | 810 // passwords) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 base::FilePath profile_file_path = profile_->GetPath(); | 913 base::FilePath profile_file_path = profile_->GetPath(); |
| 914 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 914 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
| 915 | 915 |
| 916 // We're done configuring, so notify ProfileSyncService that it is OK to | 916 // We're done configuring, so notify ProfileSyncService that it is OK to |
| 917 // start syncing. | 917 // start syncing. |
| 918 sync_blocker_.reset(); | 918 sync_blocker_.reset(); |
| 919 service->SetFirstSetupComplete(); | 919 service->SetFirstSetupComplete(); |
| 920 } | 920 } |
| 921 | 921 |
| 922 } // namespace settings | 922 } // namespace settings |
| OLD | NEW |