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

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc

Issue 9456031: Remove PSS::ShowLoginDialog() and obsolete IDC_SYNC_BOOKMARKS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 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 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/ntp/new_tab_page_sync_handler.h" 5 #include "chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/string_split.h" 11 #include "base/string_split.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/net/chrome_url_request_context.h" 15 #include "chrome/browser/net/chrome_url_request_context.h"
16 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/signin/signin_manager.h"
19 #include "chrome/browser/signin/signin_manager_factory.h"
18 #include "chrome/browser/sync/profile_sync_service.h" 20 #include "chrome/browser/sync/profile_sync_service.h"
19 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
22 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
20 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
21 #include "content/browser/renderer_host/render_view_host.h" 25 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/public/browser/web_ui.h" 26 #include "content/public/browser/web_ui.h"
23 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
24 #include "net/base/cookie_monster.h" 28 #include "net/base/cookie_monster.h"
25 #include "net/url_request/url_request_context.h" 29 #include "net/url_request/url_request_context.h"
26 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
27 31
28 // Default URL for the sync web interface. 32 // Default URL for the sync web interface.
29 // 33 //
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 &link_text); 113 &link_text);
110 SendSyncMessageToPage(FromSyncStatusMessageType(type), 114 SendSyncMessageToPage(FromSyncStatusMessageType(type),
111 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); 115 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text));
112 } 116 }
113 117
114 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { 118 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) {
115 DCHECK(!waiting_for_initial_page_load_); 119 DCHECK(!waiting_for_initial_page_load_);
116 DCHECK(sync_service_); 120 DCHECK(sync_service_);
117 if (!sync_service_->IsSyncEnabled()) 121 if (!sync_service_->IsSyncEnabled())
118 return; 122 return;
119 if (sync_service_->HasSyncSetupCompleted()) { 123 Profile* profile = Profile::FromWebUI(web_ui());
124 string16 user = UTF8ToUTF16(
125 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername());
126 if (user.empty()) {
127 // User is not signed in.
128 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.
129 LoginUIServiceFactory::GetForProfile(profile)->ShowLoginUI();
130 } else {
131 // User is already signed in - should not be possible for the user to be
132 // signed in without sync being setup, so if the link is visible there
133 // must have been some kind of error.
134 DCHECK(sync_service_->HasSyncSetupCompleted());
120 sync_service_->ShowErrorUI(); 135 sync_service_->ShowErrorUI();
121 string16 user = UTF8ToUTF16(sync_service_->profile()->GetPrefs()->GetString(
122 prefs::kGoogleServicesUsername));
123 DictionaryValue value; 136 DictionaryValue value;
124 value.SetString("syncEnabledMessage", 137 value.SetString("syncEnabledMessage",
125 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, 138 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO,
126 user)); 139 user));
127 web_ui()->CallJavascriptFunction("syncAlreadyEnabled", value); 140 web_ui()->CallJavascriptFunction("syncAlreadyEnabled", value);
128 } else {
129 // User clicked the 'Start now' link to begin syncing.
130 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_NTP);
131 sync_service_->ShowLoginDialog();
132 } 141 }
133 } 142 }
134 143
135 void NewTabPageSyncHandler::OnStateChanged() { 144 void NewTabPageSyncHandler::OnStateChanged() {
136 // Don't do anything if the page has not yet loaded. 145 // Don't do anything if the page has not yet loaded.
137 if (waiting_for_initial_page_load_) 146 if (waiting_for_initial_page_load_)
138 return; 147 return;
139 BuildAndSendSyncStatus(); 148 BuildAndSendSyncStatus();
140 } 149 }
141 150
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 if (linkurl.empty()) { 183 if (linkurl.empty()) {
175 value.SetBoolean("linkurlisset", false); 184 value.SetBoolean("linkurlisset", false);
176 } else { 185 } else {
177 value.SetBoolean("linkurlisset", true); 186 value.SetBoolean("linkurlisset", true);
178 value.SetString("linkurl", linkurl); 187 value.SetString("linkurl", linkurl);
179 } 188 }
180 } 189 }
181 } 190 }
182 web_ui()->CallJavascriptFunction("syncMessageChanged", value); 191 web_ui()->CallJavascriptFunction("syncMessageChanged", value);
183 } 192 }
OLDNEW
« chrome/browser/ui/browser.cc ('K') | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698