| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 void PeopleHandler::DisplaySpinner() { | 316 void PeopleHandler::DisplaySpinner() { |
| 317 configuring_sync_ = true; | 317 configuring_sync_ = true; |
| 318 | 318 |
| 319 const int kTimeoutSec = 30; | 319 const int kTimeoutSec = 30; |
| 320 DCHECK(!engine_start_timer_); | 320 DCHECK(!engine_start_timer_); |
| 321 engine_start_timer_.reset(new base::OneShotTimer()); | 321 engine_start_timer_.reset(new base::OneShotTimer()); |
| 322 engine_start_timer_->Start(FROM_HERE, | 322 engine_start_timer_->Start(FROM_HERE, |
| 323 base::TimeDelta::FromSeconds(kTimeoutSec), this, | 323 base::TimeDelta::FromSeconds(kTimeoutSec), this, |
| 324 &PeopleHandler::DisplayTimeout); | 324 &PeopleHandler::DisplayTimeout); |
| 325 | 325 |
| 326 CallJavascriptFunction("cr.webUIListenerCallback", | 326 FireWebUIListener("page-status-changed", base::Value(kSpinnerPageStatus)); |
| 327 base::Value("page-status-changed"), | |
| 328 base::Value(kSpinnerPageStatus)); | |
| 329 } | 327 } |
| 330 | 328 |
| 331 void PeopleHandler::DisplayTimeout() { | 329 void PeopleHandler::DisplayTimeout() { |
| 332 // Stop a timer to handle timeout in waiting for checking network connection. | 330 // Stop a timer to handle timeout in waiting for checking network connection. |
| 333 engine_start_timer_.reset(); | 331 engine_start_timer_.reset(); |
| 334 | 332 |
| 335 // Do not listen to sync startup events. | 333 // Do not listen to sync startup events. |
| 336 sync_startup_tracker_.reset(); | 334 sync_startup_tracker_.reset(); |
| 337 | 335 |
| 338 CallJavascriptFunction("cr.webUIListenerCallback", | 336 FireWebUIListener("page-status-changed", base::Value(kTimeoutPageStatus)); |
| 339 base::Value("page-status-changed"), | |
| 340 base::Value(kTimeoutPageStatus)); | |
| 341 } | 337 } |
| 342 | 338 |
| 343 void PeopleHandler::OnDidClosePage(const base::ListValue* args) { | 339 void PeopleHandler::OnDidClosePage(const base::ListValue* args) { |
| 344 MarkFirstSetupComplete(); | 340 MarkFirstSetupComplete(); |
| 345 CloseSyncSetup(); | 341 CloseSyncSetup(); |
| 346 } | 342 } |
| 347 | 343 |
| 348 void PeopleHandler::SyncStartupFailed() { | 344 void PeopleHandler::SyncStartupFailed() { |
| 349 // Stop a timer to handle timeout in waiting for checking network connection. | 345 // Stop a timer to handle timeout in waiting for checking network connection. |
| 350 engine_start_timer_.reset(); | 346 engine_start_timer_.reset(); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 PushSyncPrefs(); | 684 PushSyncPrefs(); |
| 689 } | 685 } |
| 690 | 686 |
| 691 void PeopleHandler::FocusUI() { | 687 void PeopleHandler::FocusUI() { |
| 692 WebContents* web_contents = web_ui()->GetWebContents(); | 688 WebContents* web_contents = web_ui()->GetWebContents(); |
| 693 web_contents->GetDelegate()->ActivateContents(web_contents); | 689 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 694 } | 690 } |
| 695 | 691 |
| 696 void PeopleHandler::CloseUI() { | 692 void PeopleHandler::CloseUI() { |
| 697 CloseSyncSetup(); | 693 CloseSyncSetup(); |
| 698 CallJavascriptFunction("cr.webUIListenerCallback", | 694 FireWebUIListener("page-status-changed", base::Value(kDonePageStatus)); |
| 699 base::Value("page-status-changed"), | |
| 700 base::Value(kDonePageStatus)); | |
| 701 } | 695 } |
| 702 | 696 |
| 703 void PeopleHandler::GoogleSigninSucceeded(const std::string& /* account_id */, | 697 void PeopleHandler::GoogleSigninSucceeded(const std::string& /* account_id */, |
| 704 const std::string& /* username */, | 698 const std::string& /* username */, |
| 705 const std::string& /* password */) { | 699 const std::string& /* password */) { |
| 706 UpdateSyncStatus(); | 700 UpdateSyncStatus(); |
| 707 } | 701 } |
| 708 | 702 |
| 709 void PeopleHandler::GoogleSignedOut(const std::string& /* account_id */, | 703 void PeopleHandler::GoogleSignedOut(const std::string& /* account_id */, |
| 710 const std::string& /* username */) { | 704 const std::string& /* username */) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 default: | 872 default: |
| 879 args.SetString("fullEncryptionBody", | 873 args.SetString("fullEncryptionBody", |
| 880 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); | 874 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| 881 break; | 875 break; |
| 882 } | 876 } |
| 883 } else if (passphrase_type == syncer::PassphraseType::CUSTOM_PASSPHRASE) { | 877 } else if (passphrase_type == syncer::PassphraseType::CUSTOM_PASSPHRASE) { |
| 884 args.SetString("fullEncryptionBody", | 878 args.SetString("fullEncryptionBody", |
| 885 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); | 879 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| 886 } | 880 } |
| 887 | 881 |
| 888 CallJavascriptFunction("cr.webUIListenerCallback", | 882 FireWebUIListener("sync-prefs-changed", args); |
| 889 base::Value("sync-prefs-changed"), args); | |
| 890 } | 883 } |
| 891 | 884 |
| 892 LoginUIService* PeopleHandler::GetLoginUIService() const { | 885 LoginUIService* PeopleHandler::GetLoginUIService() const { |
| 893 return LoginUIServiceFactory::GetForProfile(profile_); | 886 return LoginUIServiceFactory::GetForProfile(profile_); |
| 894 } | 887 } |
| 895 | 888 |
| 896 void PeopleHandler::UpdateSyncStatus() { | 889 void PeopleHandler::UpdateSyncStatus() { |
| 897 CallJavascriptFunction("cr.webUIListenerCallback", | 890 FireWebUIListener("sync-status-changed", *GetSyncStatusDictionary()); |
| 898 base::Value("sync-status-changed"), | |
| 899 *GetSyncStatusDictionary()); | |
| 900 } | 891 } |
| 901 | 892 |
| 902 void PeopleHandler::MarkFirstSetupComplete() { | 893 void PeopleHandler::MarkFirstSetupComplete() { |
| 903 // Suppress the sign in promo once the user starts sync. This way the user | 894 // Suppress the sign in promo once the user starts sync. This way the user |
| 904 // doesn't see the sign in promo even if they sign out later on. | 895 // doesn't see the sign in promo even if they sign out later on. |
| 905 signin::SetUserSkippedPromo(profile_); | 896 signin::SetUserSkippedPromo(profile_); |
| 906 | 897 |
| 907 ProfileSyncService* service = GetSyncService(); | 898 ProfileSyncService* service = GetSyncService(); |
| 908 // The sync service may be nullptr if it has been just disabled by policy. | 899 // The sync service may be nullptr if it has been just disabled by policy. |
| 909 if (!service || service->IsFirstSetupComplete()) | 900 if (!service || service->IsFirstSetupComplete()) |
| 910 return; | 901 return; |
| 911 | 902 |
| 912 // This is the first time configuring sync, so log it. | 903 // This is the first time configuring sync, so log it. |
| 913 base::FilePath profile_file_path = profile_->GetPath(); | 904 base::FilePath profile_file_path = profile_->GetPath(); |
| 914 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 905 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
| 915 | 906 |
| 916 // We're done configuring, so notify ProfileSyncService that it is OK to | 907 // We're done configuring, so notify ProfileSyncService that it is OK to |
| 917 // start syncing. | 908 // start syncing. |
| 918 sync_blocker_.reset(); | 909 sync_blocker_.reset(); |
| 919 service->SetFirstSetupComplete(); | 910 service->SetFirstSetupComplete(); |
| 920 } | 911 } |
| 921 | 912 |
| 922 } // namespace settings | 913 } // namespace settings |
| OLD | NEW |