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

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: Addressed review feedback. 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
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser.h"
23 #include "chrome/browser/ui/browser_list.h"
24 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
25 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
20 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
21 #include "content/browser/renderer_host/render_view_host.h" 27 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
23 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
24 #include "net/base/cookie_monster.h" 30 #include "net/base/cookie_monster.h"
25 #include "net/url_request/url_request_context.h" 31 #include "net/url_request/url_request_context.h"
26 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
27 33
28 // Default URL for the sync web interface. 34 // Default URL for the sync web interface.
29 // 35 //
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 &link_text); 115 &link_text);
110 SendSyncMessageToPage(FromSyncStatusMessageType(type), 116 SendSyncMessageToPage(FromSyncStatusMessageType(type),
111 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); 117 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text));
112 } 118 }
113 119
114 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) { 120 void NewTabPageSyncHandler::HandleSyncLinkClicked(const ListValue* args) {
115 DCHECK(!waiting_for_initial_page_load_); 121 DCHECK(!waiting_for_initial_page_load_);
116 DCHECK(sync_service_); 122 DCHECK(sync_service_);
117 if (!sync_service_->IsSyncEnabled()) 123 if (!sync_service_->IsSyncEnabled())
118 return; 124 return;
125 Browser* browser =
126 BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents());
127 if (!browser || browser->IsAttemptingToCloseBrowser())
128 return;
129 browser->ShowSyncSetup();
130
119 if (sync_service_->HasSyncSetupCompleted()) { 131 if (sync_service_->HasSyncSetupCompleted()) {
120 sync_service_->ShowErrorUI(); 132 string16 user = UTF8ToUTF16(SigninManagerFactory::GetForProfile(
121 string16 user = UTF8ToUTF16(sync_service_->profile()->GetPrefs()->GetString( 133 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername());
122 prefs::kGoogleServicesUsername));
123 DictionaryValue value; 134 DictionaryValue value;
124 value.SetString("syncEnabledMessage", 135 value.SetString("syncEnabledMessage",
125 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, 136 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO,
126 user)); 137 user));
127 web_ui()->CallJavascriptFunction("syncAlreadyEnabled", value); 138 web_ui()->CallJavascriptFunction("syncAlreadyEnabled", value);
128 } else { 139 } else {
129 // User clicked the 'Start now' link to begin syncing.
130 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_NTP); 140 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
« no previous file with comments | « 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