Chromium Code Reviews| 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/options/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/options/sync_setup_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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", | 455 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 456 page, args); | 456 page, args); |
| 457 } | 457 } |
| 458 | 458 |
| 459 void SyncSetupHandler::OnDidClosePage(const base::ListValue* args) { | 459 void SyncSetupHandler::OnDidClosePage(const base::ListValue* args) { |
| 460 CloseSyncSetup(); | 460 CloseSyncSetup(); |
| 461 } | 461 } |
| 462 | 462 |
| 463 void SyncSetupHandler::SyncStartupFailed() { | 463 void SyncSetupHandler::SyncStartupFailed() { |
| 464 // Stop a timer to handle timeout in waiting for checking network connection. | 464 // Stop a timer to handle timeout in waiting for checking network connection. |
| 465 backend_start_timer_.reset(); | 465 backend_start_timer_.reset(); |
|
skym
2016/12/05 19:38:56
Okay i'm gonna stop commenting, backend is everywh
maxbogue
2016/12/05 22:17:11
Done.
| |
| 466 | 466 |
| 467 // Just close the sync overlay (the idea is that the base settings page will | 467 // Just close the sync overlay (the idea is that the base settings page will |
| 468 // display the current error.) | 468 // display the current error.) |
| 469 CloseUI(); | 469 CloseUI(); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void SyncSetupHandler::SyncStartupCompleted() { | 472 void SyncSetupHandler::SyncStartupCompleted() { |
| 473 ProfileSyncService* service = GetSyncService(); | 473 ProfileSyncService* service = GetSyncService(); |
| 474 DCHECK(service->IsBackendInitialized()); | 474 DCHECK(service->IsEngineInitialized()); |
| 475 | 475 |
| 476 // Stop a timer to handle timeout in waiting for checking network connection. | 476 // Stop a timer to handle timeout in waiting for checking network connection. |
| 477 backend_start_timer_.reset(); | 477 backend_start_timer_.reset(); |
| 478 | 478 |
| 479 DisplayConfigureSync(false); | 479 DisplayConfigureSync(false); |
| 480 } | 480 } |
| 481 | 481 |
| 482 Profile* SyncSetupHandler::GetProfile() const { | 482 Profile* SyncSetupHandler::GetProfile() const { |
| 483 return Profile::FromWebUI(web_ui()); | 483 return Profile::FromWebUI(web_ui()); |
| 484 } | 484 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 508 NOTREACHED(); | 508 NOTREACHED(); |
| 509 return; | 509 return; |
| 510 } | 510 } |
| 511 | 511 |
| 512 // Start configuring the ProfileSyncService using the configuration passed | 512 // Start configuring the ProfileSyncService using the configuration passed |
| 513 // to us from the JS layer. | 513 // to us from the JS layer. |
| 514 ProfileSyncService* service = GetSyncService(); | 514 ProfileSyncService* service = GetSyncService(); |
| 515 | 515 |
| 516 // If the sync engine has shutdown for some reason, just close the sync | 516 // If the sync engine has shutdown for some reason, just close the sync |
| 517 // dialog. | 517 // dialog. |
| 518 if (!service || !service->IsBackendInitialized()) { | 518 if (!service || !service->IsEngineInitialized()) { |
| 519 CloseUI(); | 519 CloseUI(); |
| 520 return; | 520 return; |
| 521 } | 521 } |
| 522 | 522 |
| 523 // Don't allow "encrypt all" if the ProfileSyncService doesn't allow it. | 523 // Don't allow "encrypt all" if the ProfileSyncService doesn't allow it. |
| 524 // The UI is hidden, but the user may have enabled it e.g. by fiddling with | 524 // The UI is hidden, but the user may have enabled it e.g. by fiddling with |
| 525 // the web inspector. | 525 // the web inspector. |
| 526 if (!service->IsEncryptEverythingAllowed()) | 526 if (!service->IsEncryptEverythingAllowed()) |
| 527 configuration.encrypt_all = false; | 527 configuration.encrypt_all = false; |
| 528 | 528 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 service->current_login_ui()->FocusUI(); | 814 service->current_login_ui()->FocusUI(); |
| 815 return true; | 815 return true; |
| 816 } | 816 } |
| 817 | 817 |
| 818 void SyncSetupHandler::DisplayConfigureSync(bool passphrase_failed) { | 818 void SyncSetupHandler::DisplayConfigureSync(bool passphrase_failed) { |
| 819 // Should never call this when we are not signed in. | 819 // Should never call this when we are not signed in. |
| 820 DCHECK(SigninManagerFactory::GetForProfile( | 820 DCHECK(SigninManagerFactory::GetForProfile( |
| 821 GetProfile())->IsAuthenticated()); | 821 GetProfile())->IsAuthenticated()); |
| 822 ProfileSyncService* service = GetSyncService(); | 822 ProfileSyncService* service = GetSyncService(); |
| 823 DCHECK(service); | 823 DCHECK(service); |
| 824 if (!service->IsBackendInitialized()) { | 824 if (!service->IsEngineInitialized()) { |
| 825 service->RequestStart(); | 825 service->RequestStart(); |
| 826 | 826 |
| 827 // See if it's even possible to bring up the sync backend - if not | 827 // See if it's even possible to bring up the sync backend - if not |
| 828 // (unrecoverable error?), don't bother displaying a spinner that will be | 828 // (unrecoverable error?), don't bother displaying a spinner that will be |
| 829 // immediately closed because this leads to some ugly infinite UI loop (see | 829 // immediately closed because this leads to some ugly infinite UI loop (see |
| 830 // http://crbug.com/244769). | 830 // http://crbug.com/244769). |
| 831 if (SyncStartupTracker::GetSyncServiceState(GetProfile()) != | 831 if (SyncStartupTracker::GetSyncServiceState(GetProfile()) != |
| 832 SyncStartupTracker::SYNC_STARTUP_ERROR) { | 832 SyncStartupTracker::SYNC_STARTUP_ERROR) { |
| 833 DisplaySpinner(); | 833 DisplaySpinner(); |
| 834 } | 834 } |
| 835 | 835 |
| 836 // Start SyncSetupTracker to wait for sync to initialize. | 836 // Start SyncSetupTracker to wait for sync to initialize. |
| 837 sync_startup_tracker_.reset( | 837 sync_startup_tracker_.reset( |
| 838 new SyncStartupTracker(GetProfile(), this)); | 838 new SyncStartupTracker(GetProfile(), this)); |
| 839 return; | 839 return; |
| 840 } | 840 } |
| 841 | 841 |
| 842 // Should only get here if user is signed in and sync is initialized, so no | 842 // Should only get here if user is signed in and sync is initialized, so no |
| 843 // longer need a SyncStartupTracker. | 843 // longer need a SyncStartupTracker. |
| 844 sync_startup_tracker_.reset(); | 844 sync_startup_tracker_.reset(); |
| 845 configuring_sync_ = true; | 845 configuring_sync_ = true; |
| 846 DCHECK(service->IsBackendInitialized()) | 846 DCHECK(service->IsEngineInitialized()) |
| 847 << "Cannot configure sync until the sync backend is initialized"; | 847 << "Cannot configure sync until the sync backend is initialized"; |
| 848 | 848 |
| 849 // Setup args for the sync configure screen: | 849 // Setup args for the sync configure screen: |
| 850 // syncAllDataTypes: true if the user wants to sync everything | 850 // syncAllDataTypes: true if the user wants to sync everything |
| 851 // syncNothing: true if the user wants to sync nothing | 851 // syncNothing: true if the user wants to sync nothing |
| 852 // <data_type>Registered: true if the associated data type is supported | 852 // <data_type>Registered: true if the associated data type is supported |
| 853 // <data_type>Synced: true if the user wants to sync that specific data type | 853 // <data_type>Synced: true if the user wants to sync that specific data type |
| 854 // paymentsIntegrationEnabled: true if the user wants Payments integration | 854 // paymentsIntegrationEnabled: true if the user wants Payments integration |
| 855 // encryptionEnabled: true if sync supports encryption | 855 // encryptionEnabled: true if sync supports encryption |
| 856 // encryptAllData: true if user wants to encrypt all data (not just | 856 // encryptAllData: true if user wants to encrypt all data (not just |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 944 page, args); | 944 page, args); |
| 945 | 945 |
| 946 // Make sure the tab used for the Gaia sign in does not cover the settings | 946 // Make sure the tab used for the Gaia sign in does not cover the settings |
| 947 // tab. | 947 // tab. |
| 948 FocusUI(); | 948 FocusUI(); |
| 949 } | 949 } |
| 950 | 950 |
| 951 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 951 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
| 952 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 952 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
| 953 } | 953 } |
| OLD | NEW |