OLD | NEW |
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" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 void NewTabPageSyncHandler::HandleSyncLinkClicked(const base::ListValue* args) { | 126 void NewTabPageSyncHandler::HandleSyncLinkClicked(const base::ListValue* args) { |
127 DCHECK(!waiting_for_initial_page_load_); | 127 DCHECK(!waiting_for_initial_page_load_); |
128 if (!sync_service_ || !sync_service_->IsSyncEnabled()) | 128 if (!sync_service_ || !sync_service_->IsSyncEnabled()) |
129 return; | 129 return; |
130 Browser* browser = | 130 Browser* browser = |
131 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 131 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
132 if (!browser || browser->IsAttemptingToCloseBrowser()) | 132 if (!browser || browser->IsAttemptingToCloseBrowser()) |
133 return; | 133 return; |
134 chrome::ShowBrowserSignin(browser, signin::SOURCE_NTP_LINK); | 134 chrome::ShowBrowserSignin(browser, signin_metrics::SOURCE_NTP_LINK); |
135 | 135 |
136 if (sync_service_->HasSyncSetupCompleted()) { | 136 if (sync_service_->HasSyncSetupCompleted()) { |
137 base::string16 user = base::UTF8ToUTF16(SigninManagerFactory::GetForProfile( | 137 base::string16 user = base::UTF8ToUTF16(SigninManagerFactory::GetForProfile( |
138 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername()); | 138 Profile::FromWebUI(web_ui()))->GetAuthenticatedUsername()); |
139 base::DictionaryValue value; | 139 base::DictionaryValue value; |
140 value.SetString("syncEnabledMessage", | 140 value.SetString("syncEnabledMessage", |
141 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, | 141 l10n_util::GetStringFUTF16(IDS_SYNC_NTP_SYNCED_TO, |
142 user)); | 142 user)); |
143 web_ui()->CallJavascriptFunction("ntp.syncAlreadyEnabled", value); | 143 web_ui()->CallJavascriptFunction("ntp.syncAlreadyEnabled", value); |
144 } else { | 144 } else { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if (linkurl.empty()) { | 195 if (linkurl.empty()) { |
196 value.SetBoolean("linkurlisset", false); | 196 value.SetBoolean("linkurlisset", false); |
197 } else { | 197 } else { |
198 value.SetBoolean("linkurlisset", true); | 198 value.SetBoolean("linkurlisset", true); |
199 value.SetString("linkurl", linkurl); | 199 value.SetString("linkurl", linkurl); |
200 } | 200 } |
201 } | 201 } |
202 } | 202 } |
203 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); | 203 web_ui()->CallJavascriptFunction("ntp.syncMessageChanged", value); |
204 } | 204 } |
OLD | NEW |