Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/ui/webui/options2/options_sync_setup_handler2.cc

Issue 9169096: Remove a bunch of GetProfileSyncService callers to use the new factory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm todos Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/options2/options_sync_setup_handler2.h" 5 #include "chrome/browser/ui/webui/options2/options_sync_setup_handler2.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sync/profile_sync_service.h" 8 #include "chrome/browser/sync/profile_sync_service.h"
9 #include "chrome/browser/sync/profile_sync_service_factory.h"
9 #include "content/public/browser/web_ui.h" 10 #include "content/public/browser/web_ui.h"
10 11
11 namespace options2 { 12 namespace options2 {
12 13
13 OptionsSyncSetupHandler::OptionsSyncSetupHandler( 14 OptionsSyncSetupHandler::OptionsSyncSetupHandler(
14 ProfileManager* profile_manager) : SyncSetupHandler2(profile_manager) { 15 ProfileManager* profile_manager) : SyncSetupHandler2(profile_manager) {
15 } 16 }
16 17
17 OptionsSyncSetupHandler::~OptionsSyncSetupHandler() { 18 OptionsSyncSetupHandler::~OptionsSyncSetupHandler() {
18 } 19 }
19 20
20 void OptionsSyncSetupHandler::StepWizardForShowSetupUI() { 21 void OptionsSyncSetupHandler::StepWizardForShowSetupUI() {
21 ProfileSyncService* service = 22 ProfileSyncService* service(ProfileSyncServiceFactory::
22 Profile::FromWebUI(web_ui())->GetProfileSyncService(); 23 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
23 DCHECK(service); 24 DCHECK(service);
24 25
25 // We should bring up either a login or a configure flow based on the state of 26 // We should bring up either a login or a configure flow based on the state of
26 // sync. 27 // sync.
27 if (service->HasSyncSetupCompleted()) { 28 if (service->HasSyncSetupCompleted()) {
28 if (service->IsPassphraseRequiredForDecryption()) { 29 if (service->IsPassphraseRequiredForDecryption()) {
29 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); 30 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE);
30 } else { 31 } else {
31 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); 32 service->get_wizard().Step(SyncSetupWizard::CONFIGURE);
32 } 33 }
33 } else { 34 } else {
34 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); 35 service->get_wizard().Step(SyncSetupWizard::GetLoginState());
35 } 36 }
36 } 37 }
37 38
38 void OptionsSyncSetupHandler::ShowSetupUI() { 39 void OptionsSyncSetupHandler::ShowSetupUI() {
39 ProfileSyncService* service = 40 ProfileSyncService* service(ProfileSyncServiceFactory::
40 Profile::FromWebUI(web_ui())->GetProfileSyncService(); 41 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
41 DCHECK(service); 42 DCHECK(service);
42 43
43 // The user is trying to manually load a syncSetup URL. We should bring up 44 // The user is trying to manually load a syncSetup URL. We should bring up
44 // either a login or a configure flow based on the state of sync. 45 // either a login or a configure flow based on the state of sync.
45 if (service->HasSyncSetupCompleted()) { 46 if (service->HasSyncSetupCompleted()) {
46 if (service->IsPassphraseRequiredForDecryption()) { 47 if (service->IsPassphraseRequiredForDecryption()) {
47 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); 48 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE);
48 } else { 49 } else {
49 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); 50 service->get_wizard().Step(SyncSetupWizard::CONFIGURE);
50 } 51 }
51 } else { 52 } else {
52 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); 53 service->get_wizard().Step(SyncSetupWizard::GetLoginState());
53 } 54 }
54 55
55 // Show the Sync Setup page. 56 // Show the Sync Setup page.
56 scoped_ptr<Value> page(Value::CreateStringValue("syncSetup")); 57 scoped_ptr<Value> page(Value::CreateStringValue("syncSetup"));
57 web_ui()->CallJavascriptFunction("OptionsPage.navigateToPage", *page); 58 web_ui()->CallJavascriptFunction("OptionsPage.navigateToPage", *page);
58 } 59 }
59 60
60 } // namespace options2 61 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698