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

Side by Side Diff: chrome/browser/dom_ui/new_tab_page_sync_handler.cc

Issue 462011: Notify user that Chrome is already synced if promo banner "sync me" link is c... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | « no previous file | chrome/browser/dom_ui/ntp_resource_cache.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/dom_ui/new_tab_page_sync_handler.h" 5 #include "chrome/browser/dom_ui/new_tab_page_sync_handler.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "chrome/browser/net/chrome_url_request_context.h" 11 #include "chrome/browser/net/chrome_url_request_context.h"
11 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
12 #include "chrome/browser/renderer_host/render_view_host.h" 13 #include "chrome/browser/renderer_host/render_view_host.h"
13 #include "chrome/browser/tab_contents/tab_contents.h" 14 #include "chrome/browser/tab_contents/tab_contents.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/common/pref_service.h" 16 #include "chrome/common/pref_service.h"
16 #include "grit/browser_resources.h" 17 #include "grit/browser_resources.h"
17 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
18 #include "net/base/cookie_monster.h" 19 #include "net/base/cookie_monster.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 sync_ui_util::MessageType type = 142 sync_ui_util::MessageType type =
142 sync_ui_util::GetStatusLabels(sync_service_, &status_msg, &link_text); 143 sync_ui_util::GetStatusLabels(sync_service_, &status_msg, &link_text);
143 SendSyncMessageToPage(FromSyncStatusMessageType(type), 144 SendSyncMessageToPage(FromSyncStatusMessageType(type),
144 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text)); 145 UTF16ToUTF8(status_msg), UTF16ToUTF8(link_text));
145 } 146 }
146 147
147 void NewTabPageSyncHandler::HandleSyncLinkClicked(const Value* value) { 148 void NewTabPageSyncHandler::HandleSyncLinkClicked(const Value* value) {
148 DCHECK(!waiting_for_initial_page_load_); 149 DCHECK(!waiting_for_initial_page_load_);
149 DCHECK(sync_service_); 150 DCHECK(sync_service_);
150 if (sync_service_->HasSyncSetupCompleted()) { 151 if (sync_service_->HasSyncSetupCompleted()) {
151 // User clicked the 'Login again' link to re-authenticate. 152 DictionaryValue value;
152 sync_service_->ShowLoginDialog(); 153 value.SetString(L"syncEnabledMessage",
154 l10n_util::GetStringF(IDS_SYNC_NTP_SYNCED_TO,
155 UTF16ToWide(sync_service_->GetAuthenticatedUsername())));
156 dom_ui_->CallJavascriptFunction(L"syncAlreadyEnabled", value);
153 } else { 157 } else {
154 // User clicked the 'Start now' link to begin syncing. 158 // User clicked the 'Start now' link to begin syncing.
155 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_NTP); 159 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_NTP);
156 sync_service_->EnableForUser(); 160 sync_service_->EnableForUser();
157 } 161 }
158 } 162 }
159 163
160 void NewTabPageSyncHandler::OnStateChanged() { 164 void NewTabPageSyncHandler::OnStateChanged() {
161 // Don't do anything if the page has not yet loaded. 165 // Don't do anything if the page has not yet loaded.
162 if (waiting_for_initial_page_load_) 166 if (waiting_for_initial_page_load_)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (linkurl.empty()) { 214 if (linkurl.empty()) {
211 value.SetBoolean(L"linkurlisset", false); 215 value.SetBoolean(L"linkurlisset", false);
212 } else { 216 } else {
213 value.SetBoolean(L"linkurlisset", true); 217 value.SetBoolean(L"linkurlisset", true);
214 value.SetString(L"linkurl", linkurl); 218 value.SetString(L"linkurl", linkurl);
215 } 219 }
216 } 220 }
217 } 221 }
218 dom_ui_->CallJavascriptFunction(L"syncMessageChanged", value); 222 dom_ui_->CallJavascriptFunction(L"syncMessageChanged", value);
219 } 223 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/dom_ui/ntp_resource_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698