| 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 {"basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA}, | 278 {"basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA}, |
| 279 {"fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA}, | 279 {"fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA}, |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 RegisterStrings(localized_strings, resources, arraysize(resources)); | 282 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 283 RegisterTitle(localized_strings, "syncSetupOverlay", IDS_SYNC_SETUP_TITLE); | 283 RegisterTitle(localized_strings, "syncSetupOverlay", IDS_SYNC_SETUP_TITLE); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void SyncSetupHandler::ConfigureSyncDone() { | 286 void SyncSetupHandler::ConfigureSyncDone() { |
| 287 base::StringValue page("done"); | 287 base::StringValue page("done"); |
| 288 web_ui()->CallJavascriptFunction( | 288 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 289 "SyncSetupOverlay.showSyncSetupPage", page); | 289 page); |
| 290 | 290 |
| 291 // Suppress the sign in promo once the user starts sync. This way the user | 291 // Suppress the sign in promo once the user starts sync. This way the user |
| 292 // doesn't see the sign in promo even if they sign out later on. | 292 // doesn't see the sign in promo even if they sign out later on. |
| 293 signin::SetUserSkippedPromo(GetProfile()); | 293 signin::SetUserSkippedPromo(GetProfile()); |
| 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(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 433 DCHECK(!backend_start_timer_); | 433 DCHECK(!backend_start_timer_); |
| 434 backend_start_timer_.reset(new base::OneShotTimer()); | 434 backend_start_timer_.reset(new base::OneShotTimer()); |
| 435 backend_start_timer_->Start(FROM_HERE, | 435 backend_start_timer_->Start(FROM_HERE, |
| 436 base::TimeDelta::FromSeconds(kTimeoutSec), | 436 base::TimeDelta::FromSeconds(kTimeoutSec), |
| 437 this, &SyncSetupHandler::DisplayTimeout); | 437 this, &SyncSetupHandler::DisplayTimeout); |
| 438 | 438 |
| 439 web_ui()->CallJavascriptFunction( | 439 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 440 "SyncSetupOverlay.showSyncSetupPage", page, args); | 440 page, args); |
| 441 } | 441 } |
| 442 | 442 |
| 443 // TODO(kochi): Handle error conditions other than timeout. | 443 // TODO(kochi): Handle error conditions other than timeout. |
| 444 // http://crbug.com/128692 | 444 // http://crbug.com/128692 |
| 445 void SyncSetupHandler::DisplayTimeout() { | 445 void SyncSetupHandler::DisplayTimeout() { |
| 446 // Stop a timer to handle timeout in waiting for checking network connection. | 446 // Stop a timer to handle timeout in waiting for checking network connection. |
| 447 backend_start_timer_.reset(); | 447 backend_start_timer_.reset(); |
| 448 | 448 |
| 449 // Do not listen to sync startup events. | 449 // Do not listen to sync startup events. |
| 450 sync_startup_tracker_.reset(); | 450 sync_startup_tracker_.reset(); |
| 451 | 451 |
| 452 base::StringValue page("timeout"); | 452 base::StringValue page("timeout"); |
| 453 base::DictionaryValue args; | 453 base::DictionaryValue args; |
| 454 web_ui()->CallJavascriptFunction( | 454 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 455 "SyncSetupOverlay.showSyncSetupPage", page, args); | 455 page, args); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void SyncSetupHandler::OnDidClosePage(const base::ListValue* args) { | 458 void SyncSetupHandler::OnDidClosePage(const base::ListValue* args) { |
| 459 CloseSyncSetup(); | 459 CloseSyncSetup(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void SyncSetupHandler::SyncStartupFailed() { | 462 void SyncSetupHandler::SyncStartupFailed() { |
| 463 // Stop a timer to handle timeout in waiting for checking network connection. | 463 // Stop a timer to handle timeout in waiting for checking network connection. |
| 464 backend_start_timer_.reset(); | 464 backend_start_timer_.reset(); |
| 465 | 465 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 | 787 |
| 788 void SyncSetupHandler::FocusUI() { | 788 void SyncSetupHandler::FocusUI() { |
| 789 DCHECK(IsActiveLogin()); | 789 DCHECK(IsActiveLogin()); |
| 790 WebContents* web_contents = web_ui()->GetWebContents(); | 790 WebContents* web_contents = web_ui()->GetWebContents(); |
| 791 web_contents->GetDelegate()->ActivateContents(web_contents); | 791 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 792 } | 792 } |
| 793 | 793 |
| 794 void SyncSetupHandler::CloseUI() { | 794 void SyncSetupHandler::CloseUI() { |
| 795 CloseSyncSetup(); | 795 CloseSyncSetup(); |
| 796 base::StringValue page("done"); | 796 base::StringValue page("done"); |
| 797 web_ui()->CallJavascriptFunction( | 797 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 798 "SyncSetupOverlay.showSyncSetupPage", page); | 798 page); |
| 799 } | 799 } |
| 800 | 800 |
| 801 bool SyncSetupHandler::IsExistingWizardPresent() { | 801 bool SyncSetupHandler::IsExistingWizardPresent() { |
| 802 LoginUIService* service = GetLoginUIService(); | 802 LoginUIService* service = GetLoginUIService(); |
| 803 DCHECK(service); | 803 DCHECK(service); |
| 804 return service->current_login_ui() != NULL; | 804 return service->current_login_ui() != NULL; |
| 805 } | 805 } |
| 806 | 806 |
| 807 bool SyncSetupHandler::FocusExistingWizardIfPresent() { | 807 bool SyncSetupHandler::FocusExistingWizardIfPresent() { |
| 808 if (!IsExistingWizardPresent()) | 808 if (!IsExistingWizardPresent()) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 args.SetString( | 931 args.SetString( |
| 932 "fullEncryptionBody", | 932 "fullEncryptionBody", |
| 933 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); | 933 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM)); |
| 934 } else { | 934 } else { |
| 935 args.SetString( | 935 args.SetString( |
| 936 "fullEncryptionBody", | 936 "fullEncryptionBody", |
| 937 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); | 937 GetStringUTF16(IDS_SYNC_FULL_ENCRYPTION_DATA)); |
| 938 } | 938 } |
| 939 | 939 |
| 940 base::StringValue page("configure"); | 940 base::StringValue page("configure"); |
| 941 web_ui()->CallJavascriptFunction( | 941 web_ui()->CallJavascriptFunctionUnsafe("SyncSetupOverlay.showSyncSetupPage", |
| 942 "SyncSetupOverlay.showSyncSetupPage", page, args); | 942 page, args); |
| 943 | 943 |
| 944 // Make sure the tab used for the Gaia sign in does not cover the settings | 944 // Make sure the tab used for the Gaia sign in does not cover the settings |
| 945 // tab. | 945 // tab. |
| 946 FocusUI(); | 946 FocusUI(); |
| 947 } | 947 } |
| 948 | 948 |
| 949 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 949 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
| 950 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 950 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
| 951 } | 951 } |
| OLD | NEW |