OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/options2/options_sync_setup_handler2.h" | |
6 | |
7 #include "chrome/browser/profiles/profile.h" | |
8 #include "chrome/browser/sync/profile_sync_service.h" | |
9 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
10 #include "content/public/browser/web_ui.h" | |
11 | |
12 namespace options2 { | |
13 | |
14 OptionsSyncSetupHandler::OptionsSyncSetupHandler( | |
15 ProfileManager* profile_manager) : SyncSetupHandler2(profile_manager) { | |
16 } | |
17 | |
18 OptionsSyncSetupHandler::~OptionsSyncSetupHandler() { | |
19 } | |
20 | |
21 void OptionsSyncSetupHandler::StepWizardForShowSetupUI() { | |
22 ProfileSyncService* service(ProfileSyncServiceFactory:: | |
23 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | |
24 DCHECK(service); | |
25 | |
26 // We should bring up either a login or a configure flow based on the state of | |
27 // sync. | |
28 if (service->HasSyncSetupCompleted()) { | |
29 if (service->IsPassphraseRequiredForDecryption()) { | |
30 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); | |
31 } else { | |
32 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); | |
33 } | |
34 } else { | |
35 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); | |
36 } | |
37 } | |
38 | |
39 void OptionsSyncSetupHandler::ShowSetupUI() { | |
40 ProfileSyncService* service(ProfileSyncServiceFactory:: | |
41 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | |
42 DCHECK(service); | |
43 | |
44 // The user is trying to manually load a syncSetup URL. We should bring up | |
45 // either a login or a configure flow based on the state of sync. | |
46 if (service->HasSyncSetupCompleted()) { | |
47 if (service->IsPassphraseRequiredForDecryption()) { | |
48 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); | |
49 } else { | |
50 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); | |
51 } | |
52 } else { | |
53 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); | |
54 } | |
55 | |
56 // Show the Sync Setup page. | |
57 scoped_ptr<Value> page(Value::CreateStringValue("syncSetup")); | |
58 web_ui()->CallJavascriptFunction("OptionsPage.navigateToPage", *page); | |
59 } | |
60 | |
61 } // namespace options2 | |
OLD | NEW |