Chromium Code Reviews| Index: chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc |
| diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc |
| index aba9c8f7f53f7e81d04935c2e94250b8b6d99127..720eb77138d4a4e4a1fcb4b3f7e2e55cc5d38787 100644 |
| --- a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc |
| +++ b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc |
| @@ -15,8 +15,12 @@ |
| #include "chrome/browser/net/chrome_url_request_context.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/signin/signin_manager.h" |
| +#include "chrome/browser/signin/signin_manager_factory.h" |
| #include "chrome/browser/sync/profile_sync_service.h" |
| #include "chrome/browser/sync/profile_sync_service_factory.h" |
| +#include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| +#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| #include "chrome/common/pref_names.h" |
| #include "content/browser/renderer_host/render_view_host.h" |
| #include "content/public/browser/web_ui.h" |
| @@ -116,19 +120,24 @@ void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { |
| DCHECK(sync_service_); |
| if (!sync_service_->IsSyncEnabled()) |
| return; |
| - if (sync_service_->HasSyncSetupCompleted()) { |
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + string16 user = UTF8ToUTF16( |
| + SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername()); |
| + if (user.empty()) { |
| + // User is not signed in. |
| + ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_NTP); |
|
sail
2012/02/24 01:27:37
Do you think we could make this match Browser::Sho
Andrew T Wilson (Slow)
2012/02/24 01:49:38
Can you clarify what you mean? Are you saying that
Andrew T Wilson (Slow)
2012/02/24 22:12:11
Changed this to call ShowSyncSetup() as requested.
|
| + LoginUIServiceFactory::GetForProfile(profile)->ShowLoginUI(); |
| + } else { |
| + // User is already signed in - should not be possible for the user to be |
| + // signed in without sync being setup, so if the link is visible there |
| + // must have been some kind of error. |
| + DCHECK(sync_service_->HasSyncSetupCompleted()); |
| sync_service_->ShowErrorUI(); |
| - string16 user = UTF8ToUTF16(sync_service_->profile()->GetPrefs()->GetString( |
| - prefs::kGoogleServicesUsername)); |
| DictionaryValue value; |
| value.SetString("syncEnabledMessage", |
| l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, |
| user)); |
| web_ui()->CallJavascriptFunction("syncAlreadyEnabled", value); |
| - } else { |
| - // User clicked the 'Start now' link to begin syncing. |
| - ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_NTP); |
| - sync_service_->ShowLoginDialog(); |
| } |
| } |