OLD | NEW |
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/options/options_sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/options/options_sync_setup_handler.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 "content/browser/tab_contents/tab_contents.h" |
9 | 10 |
10 void OptionsSyncSetupHandler::ShowSetupUI() { | 11 void OptionsSyncSetupHandler::ShowSetupUI() { |
11 ProfileSyncService* service = | 12 Profile* profile = |
12 web_ui_->GetProfile()->GetProfileSyncService(); | 13 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()); |
| 14 ProfileSyncService* service = profile->GetProfileSyncService(); |
13 DCHECK(service); | 15 DCHECK(service); |
14 | 16 |
15 // If the wizard is already visible, focus it. | 17 // If the wizard is already visible, focus it. |
16 if (service->get_wizard().IsVisible()) { | 18 if (service->get_wizard().IsVisible()) { |
17 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); | 19 web_ui_->CallJavascriptFunction("OptionsPage.closeOverlay"); |
18 service->get_wizard().Focus(); | 20 service->get_wizard().Focus(); |
19 return; | 21 return; |
20 } | 22 } |
21 | 23 |
22 // The user is trying to manually load a syncSetup URL. We should bring up | 24 // The user is trying to manually load a syncSetup URL. We should bring up |
23 // either a login or a configure flow based on the state of sync. | 25 // either a login or a configure flow based on the state of sync. |
24 if (service->HasSyncSetupCompleted()) { | 26 if (service->HasSyncSetupCompleted()) { |
25 if (service->IsPassphraseRequiredForDecryption()) { | 27 if (service->IsPassphraseRequiredForDecryption()) { |
26 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); | 28 service->get_wizard().Step(SyncSetupWizard::ENTER_PASSPHRASE); |
27 } else { | 29 } else { |
28 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); | 30 service->get_wizard().Step(SyncSetupWizard::CONFIGURE); |
29 } | 31 } |
30 } else { | 32 } else { |
31 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); | 33 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); |
32 } | 34 } |
33 | 35 |
34 // Show the Sync Setup page. | 36 // Show the Sync Setup page. |
35 scoped_ptr<Value> page(Value::CreateStringValue("syncSetup")); | 37 scoped_ptr<Value> page(Value::CreateStringValue("syncSetup")); |
36 web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", *page); | 38 web_ui_->CallJavascriptFunction("OptionsPage.navigateToPage", *page); |
37 } | 39 } |
OLD | NEW |