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/ntp_login_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 void NTPLoginHandler::HandleInitializeSyncLogin(const ListValue* args) { | 123 void NTPLoginHandler::HandleInitializeSyncLogin(const ListValue* args) { |
124 UpdateLogin(); | 124 UpdateLogin(); |
125 } | 125 } |
126 | 126 |
127 void NTPLoginHandler::HandleShowSyncLoginUI(const ListValue* args) { | 127 void NTPLoginHandler::HandleShowSyncLoginUI(const ListValue* args) { |
128 Profile* profile = Profile::FromWebUI(web_ui()); | 128 Profile* profile = Profile::FromWebUI(web_ui()); |
129 std::string username = profile->GetPrefs()->GetString( | 129 std::string username = profile->GetPrefs()->GetString( |
130 prefs::kGoogleServicesUsername); | 130 prefs::kGoogleServicesUsername); |
131 content::WebContents* web_contents = web_ui()->GetWebContents(); | 131 content::WebContents* web_contents = web_ui()->GetWebContents(); |
132 Browser* browser = browser::FindBrowserWithWebContents(web_contents); | 132 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
133 if (!browser) | 133 if (!browser) |
134 return; | 134 return; |
135 | 135 |
136 if (username.empty()) { | 136 if (username.empty()) { |
137 #if !defined(OS_ANDROID) | 137 #if !defined(OS_ANDROID) |
138 // The user isn't signed in, show the sync promo. | 138 // The user isn't signed in, show the sync promo. |
139 if (SyncPromoUI::ShouldShowSyncPromo(profile)) { | 139 if (SyncPromoUI::ShouldShowSyncPromo(profile)) { |
140 chrome::ShowSyncSetup(browser, SyncPromoUI::SOURCE_NTP_LINK); | 140 chrome::ShowSyncSetup(browser, SyncPromoUI::SOURCE_NTP_LINK); |
141 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); | 141 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); |
142 } | 142 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 void NTPLoginHandler::HandleLoginMessageSeen(const ListValue* args) { | 180 void NTPLoginHandler::HandleLoginMessageSeen(const ListValue* args) { |
181 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 181 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
182 prefs::kSyncPromoShowNTPBubble, false); | 182 prefs::kSyncPromoShowNTPBubble, false); |
183 NewTabUI* ntp_ui = NewTabUI::FromWebUIController(web_ui()->GetController()); | 183 NewTabUI* ntp_ui = NewTabUI::FromWebUIController(web_ui()->GetController()); |
184 ntp_ui->set_showing_sync_bubble(true); | 184 ntp_ui->set_showing_sync_bubble(true); |
185 } | 185 } |
186 | 186 |
187 void NTPLoginHandler::HandleShowAdvancedLoginUI(const ListValue* args) { | 187 void NTPLoginHandler::HandleShowAdvancedLoginUI(const ListValue* args) { |
188 Browser* browser = | 188 Browser* browser = |
189 browser::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 189 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
190 if (browser) | 190 if (browser) |
191 chrome::ShowSyncSetup(browser, SyncPromoUI::SOURCE_NTP_LINK); | 191 chrome::ShowSyncSetup(browser, SyncPromoUI::SOURCE_NTP_LINK); |
192 } | 192 } |
193 | 193 |
194 void NTPLoginHandler::UpdateLogin() { | 194 void NTPLoginHandler::UpdateLogin() { |
195 Profile* profile = Profile::FromWebUI(web_ui()); | 195 Profile* profile = Profile::FromWebUI(web_ui()); |
196 std::string username = profile->GetPrefs()->GetString( | 196 std::string username = profile->GetPrefs()->GetString( |
197 prefs::kGoogleServicesUsername); | 197 prefs::kGoogleServicesUsername); |
198 | 198 |
199 string16 header, sub_header; | 199 string16 header, sub_header; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 272 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
273 values->SetString("login_status_url", | 273 values->SetString("login_status_url", |
274 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); | 274 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); |
275 values->SetString("login_status_advanced", | 275 values->SetString("login_status_advanced", |
276 hide_sync ? string16() : | 276 hide_sync ? string16() : |
277 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 277 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
278 values->SetString("login_status_dismiss", | 278 values->SetString("login_status_dismiss", |
279 hide_sync ? string16() : | 279 hide_sync ? string16() : |
280 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 280 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
281 } | 281 } |
OLD | NEW |