| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 {"encryptionSectionTitle", IDS_SYNC_ENCRYPTION_SECTION_TITLE}, | 278 {"encryptionSectionTitle", IDS_SYNC_ENCRYPTION_SECTION_TITLE}, |
| 279 {"basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA}, | 279 {"basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA}, |
| 280 {"fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA}, | 280 {"fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA}, |
| 281 }; | 281 }; |
| 282 | 282 |
| 283 RegisterStrings(localized_strings, resources, arraysize(resources)); | 283 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 284 RegisterTitle(localized_strings, "syncSetupOverlay", IDS_SYNC_SETUP_TITLE); | 284 RegisterTitle(localized_strings, "syncSetupOverlay", IDS_SYNC_SETUP_TITLE); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void SyncSetupHandler::ConfigureSyncDone() { | 287 void SyncSetupHandler::ConfigureSyncDone() { |
| 288 base::StringValue page("done"); | 288 base::Value page("done"); |
| 289 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", | 289 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 290 page); | 290 page); |
| 291 | 291 |
| 292 // Suppress the sign in promo once the user starts sync. This way the user | 292 // Suppress the sign in promo once the user starts sync. This way the user |
| 293 // doesn't see the sign in promo even if they sign out later on. | 293 // doesn't see the sign in promo even if they sign out later on. |
| 294 signin::SetUserSkippedPromo(GetProfile()); | 294 signin::SetUserSkippedPromo(GetProfile()); |
| 295 | 295 |
| 296 ProfileSyncService* service = GetSyncService(); | 296 ProfileSyncService* service = GetSyncService(); |
| 297 DCHECK(service); | 297 DCHECK(service); |
| 298 if (!service->IsFirstSetupComplete()) { | 298 if (!service->IsFirstSetupComplete()) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 420 |
| 421 ProfileSyncService* service = GetSyncService(); | 421 ProfileSyncService* service = GetSyncService(); |
| 422 if (service) | 422 if (service) |
| 423 sync_blocker_ = service->GetSetupInProgressHandle(); | 423 sync_blocker_ = service->GetSetupInProgressHandle(); |
| 424 | 424 |
| 425 return true; | 425 return true; |
| 426 } | 426 } |
| 427 | 427 |
| 428 void SyncSetupHandler::DisplaySpinner() { | 428 void SyncSetupHandler::DisplaySpinner() { |
| 429 configuring_sync_ = true; | 429 configuring_sync_ = true; |
| 430 base::StringValue page("spinner"); | 430 base::Value page("spinner"); |
| 431 base::DictionaryValue args; | 431 base::DictionaryValue args; |
| 432 | 432 |
| 433 const int kTimeoutSec = 30; | 433 const int kTimeoutSec = 30; |
| 434 DCHECK(!engine_start_timer_); | 434 DCHECK(!engine_start_timer_); |
| 435 engine_start_timer_.reset(new base::OneShotTimer()); | 435 engine_start_timer_.reset(new base::OneShotTimer()); |
| 436 engine_start_timer_->Start(FROM_HERE, | 436 engine_start_timer_->Start(FROM_HERE, |
| 437 base::TimeDelta::FromSeconds(kTimeoutSec), this, | 437 base::TimeDelta::FromSeconds(kTimeoutSec), this, |
| 438 &SyncSetupHandler::DisplayTimeout); | 438 &SyncSetupHandler::DisplayTimeout); |
| 439 | 439 |
| 440 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", | 440 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 441 page, args); | 441 page, args); |
| 442 } | 442 } |
| 443 | 443 |
| 444 // TODO(kochi): Handle error conditions other than timeout. | 444 // TODO(kochi): Handle error conditions other than timeout. |
| 445 // http://crbug.com/128692 | 445 // http://crbug.com/128692 |
| 446 void SyncSetupHandler::DisplayTimeout() { | 446 void SyncSetupHandler::DisplayTimeout() { |
| 447 // Stop a timer to handle timeout in waiting for checking network connection. | 447 // Stop a timer to handle timeout in waiting for checking network connection. |
| 448 engine_start_timer_.reset(); | 448 engine_start_timer_.reset(); |
| 449 | 449 |
| 450 // Do not listen to sync startup events. | 450 // Do not listen to sync startup events. |
| 451 sync_startup_tracker_.reset(); | 451 sync_startup_tracker_.reset(); |
| 452 | 452 |
| 453 base::StringValue page("timeout"); | 453 base::Value page("timeout"); |
| 454 base::DictionaryValue args; | 454 base::DictionaryValue args; |
| 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() { |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 } | 790 } |
| 791 | 791 |
| 792 void SyncSetupHandler::FocusUI() { | 792 void SyncSetupHandler::FocusUI() { |
| 793 DCHECK(IsActiveLogin()); | 793 DCHECK(IsActiveLogin()); |
| 794 WebContents* web_contents = web_ui()->GetWebContents(); | 794 WebContents* web_contents = web_ui()->GetWebContents(); |
| 795 web_contents->GetDelegate()->ActivateContents(web_contents); | 795 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 796 } | 796 } |
| 797 | 797 |
| 798 void SyncSetupHandler::CloseUI() { | 798 void SyncSetupHandler::CloseUI() { |
| 799 CloseSyncSetup(); | 799 CloseSyncSetup(); |
| 800 base::StringValue page("done"); | 800 base::Value page("done"); |
| 801 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", | 801 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 802 page); | 802 page); |
| 803 } | 803 } |
| 804 | 804 |
| 805 bool SyncSetupHandler::IsExistingWizardPresent() { | 805 bool SyncSetupHandler::IsExistingWizardPresent() { |
| 806 LoginUIService* service = GetLoginUIService(); | 806 LoginUIService* service = GetLoginUIService(); |
| 807 DCHECK(service); | 807 DCHECK(service); |
| 808 return service->current_login_ui() != NULL; | 808 return service->current_login_ui() != NULL; |
| 809 } | 809 } |
| 810 | 810 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 } else if (passphrase_type == syncer::PassphraseType::CUSTOM_PASSPHRASE) { | 935 } else if (passphrase_type == syncer::PassphraseType::CUSTOM_PASSPHRASE) { |
| 936 args.SetString( | 936 args.SetString( |
| 937 "fullEncryptionBody", | 937 "fullEncryptionBody", |
| 938 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); | 938 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| 939 } else { | 939 } else { |
| 940 args.SetString( | 940 args.SetString( |
| 941 "fullEncryptionBody", | 941 "fullEncryptionBody", |
| 942 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); | 942 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); |
| 943 } | 943 } |
| 944 | 944 |
| 945 base::StringValue page("configure"); | 945 base::Value page("configure"); |
| 946 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", | 946 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 947 page, args); | 947 page, args); |
| 948 | 948 |
| 949 // Make sure the tab used for the Gaia sign in does not cover the settings | 949 // Make sure the tab used for the Gaia sign in does not cover the settings |
| 950 // tab. | 950 // tab. |
| 951 FocusUI(); | 951 FocusUI(); |
| 952 } | 952 } |
| 953 | 953 |
| 954 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 954 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
| 955 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 955 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
| 956 } | 956 } |
| OLD | NEW |