OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/options2/options_sync_setup_handler.h" |
| 6 |
| 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/sync/profile_sync_service.h" |
| 9 |
| 10 OptionsSyncSetupHandler::OptionsSyncSetupHandler( |
| 11 ProfileManager* profile_manager) : SyncSetupHandler2(profile_manager) { |
| 12 } |
| 13 |
| 14 OptionsSyncSetupHandler::~OptionsSyncSetupHandler() { |
| 15 } |
| 16 |
| 17 void OptionsSyncSetupHandler::StepWizardForShowSetupUI() { |
| 18 ProfileSyncService* service = |
| 19 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); |
| 20 DCHECK(service); |
| 21 |
| 22 // We should bring up either a login or a configure flow based on the state of |
| 23 // sync. |
| 24 if (service->HasSyncSetupCompleted()) { |
| 25 if (service->IsPassphraseRequiredForDecryption()) { |
| 26 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); |
| 27 } else { |
| 28 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); |
| 29 } |
| 30 } else { |
| 31 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); |
| 32 } |
| 33 } |
| 34 |
| 35 void OptionsSyncSetupHandler::ShowSetupUI() { |
| 36 ProfileSyncService* service = |
| 37 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); |
| 38 DCHECK(service); |
| 39 |
| 40 // The user is trying to manually load a syncSetup URL. We should bring up |
| 41 // either a login or a configure flow based on the state of sync. |
| 42 if (service->HasSyncSetupCompleted()) { |
| 43 if (service->IsPassphraseRequiredForDecryption()) { |
| 44 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); |
| 45 } else { |
| 46 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); |
| 47 } |
| 48 } else { |
| 49 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); |
| 50 } |
| 51 |
| 52 // Show the Sync Setup page. |
| 53 scoped_ptr<Value> page(Value::CreateStringValue("syncSetup")); |
| 54 web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", *page); |
| 55 } |
OLD | NEW |