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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 ProfileSyncService* service = GetSyncService(); | 295 ProfileSyncService* service = GetSyncService(); |
296 DCHECK(service); | 296 DCHECK(service); |
297 if (!service->IsFirstSetupComplete()) { | 297 if (!service->IsFirstSetupComplete()) { |
298 // This is the first time configuring sync, so log it. | 298 // This is the first time configuring sync, so log it. |
299 base::FilePath profile_file_path = GetProfile()->GetPath(); | 299 base::FilePath profile_file_path = GetProfile()->GetPath(); |
300 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 300 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
301 | 301 |
302 // We're done configuring, so notify ProfileSyncService that it is OK to | 302 // We're done configuring, so notify ProfileSyncService that it is OK to |
303 // start syncing. | 303 // start syncing. |
304 service->SetSetupInProgress(false); | 304 setup_handle_.reset(); |
305 service->SetFirstSetupComplete(); | 305 service->SetFirstSetupComplete(); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 bool SyncSetupHandler::IsActiveLogin() const { | 309 bool SyncSetupHandler::IsActiveLogin() const { |
310 // LoginUIService can be NULL if page is brought up in incognito mode | 310 // LoginUIService can be NULL if page is brought up in incognito mode |
311 // (i.e. if the user is running in guest mode in cros and brings up settings). | 311 // (i.e. if the user is running in guest mode in cros and brings up settings). |
312 LoginUIService* service = GetLoginUIService(); | 312 LoginUIService* service = GetLoginUIService(); |
313 return service && (service->current_login_ui() == this); | 313 return service && (service->current_login_ui() == this); |
314 } | 314 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 if (!IsActiveLogin()) | 412 if (!IsActiveLogin()) |
413 CloseSyncSetup(); | 413 CloseSyncSetup(); |
414 return false; | 414 return false; |
415 } | 415 } |
416 | 416 |
417 // Notify services that login UI is now active. | 417 // Notify services that login UI is now active. |
418 GetLoginUIService()->SetLoginUI(this); | 418 GetLoginUIService()->SetLoginUI(this); |
419 | 419 |
420 ProfileSyncService* service = GetSyncService(); | 420 ProfileSyncService* service = GetSyncService(); |
421 if (service) | 421 if (service) |
422 service->SetSetupInProgress(true); | 422 setup_handle_ = service->GetSetupInProgressHandle(); |
423 | 423 |
424 return true; | 424 return true; |
425 } | 425 } |
426 | 426 |
427 void SyncSetupHandler::DisplaySpinner() { | 427 void SyncSetupHandler::DisplaySpinner() { |
428 configuring_sync_ = true; | 428 configuring_sync_ = true; |
429 base::StringValue page("spinner"); | 429 base::StringValue page("spinner"); |
430 base::DictionaryValue args; | 430 base::DictionaryValue args; |
431 | 431 |
432 const int kTimeoutSec = 30; | 432 const int kTimeoutSec = 30; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 } | 719 } |
720 } | 720 } |
721 } | 721 } |
722 | 722 |
723 GetLoginUIService()->LoginUIClosed(this); | 723 GetLoginUIService()->LoginUIClosed(this); |
724 } | 724 } |
725 | 725 |
726 // Alert the sync service anytime the sync setup dialog is closed. This can | 726 // Alert the sync service anytime the sync setup dialog is closed. This can |
727 // happen due to the user clicking the OK or Cancel button, or due to the | 727 // happen due to the user clicking the OK or Cancel button, or due to the |
728 // dialog being closed by virtue of sync being disabled in the background. | 728 // dialog being closed by virtue of sync being disabled in the background. |
729 if (sync_service) | 729 setup_handle_.reset(); |
730 sync_service->SetSetupInProgress(false); | |
731 | 730 |
732 configuring_sync_ = false; | 731 configuring_sync_ = false; |
733 } | 732 } |
734 | 733 |
735 void SyncSetupHandler::OpenSyncSetup(bool creating_supervised_user) { | 734 void SyncSetupHandler::OpenSyncSetup(bool creating_supervised_user) { |
736 if (!PrepareSyncSetup()) | 735 if (!PrepareSyncSetup()) |
737 return; | 736 return; |
738 | 737 |
739 // There are several different UI flows that can bring the user here: | 738 // There are several different UI flows that can bring the user here: |
740 // 1) Signin promo. | 739 // 1) Signin promo. |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 "SyncSetupOverlay.showSyncSetupPage", page, args); | 941 "SyncSetupOverlay.showSyncSetupPage", page, args); |
943 | 942 |
944 // Make sure the tab used for the Gaia sign in does not cover the settings | 943 // Make sure the tab used for the Gaia sign in does not cover the settings |
945 // tab. | 944 // tab. |
946 FocusUI(); | 945 FocusUI(); |
947 } | 946 } |
948 | 947 |
949 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 948 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
950 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 949 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
951 } | 950 } |
OLD | NEW |