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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); | 128 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); |
129 if (!username.empty()) | 129 if (!username.empty()) |
130 return; | 130 return; |
131 | 131 |
132 content::WebContents* web_contents = web_ui()->GetWebContents(); | 132 content::WebContents* web_contents = web_ui()->GetWebContents(); |
133 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 133 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
134 if (!browser) | 134 if (!browser) |
135 return; | 135 return; |
136 | 136 |
137 // The user isn't signed in, show the sign in promo. | 137 // The user isn't signed in, show the sign in promo. |
138 signin::Source source = | 138 signin_metrics::Source source = |
139 web_contents->GetURL().spec() == chrome::kChromeUIAppsURL ? | 139 web_contents->GetURL().spec() == chrome::kChromeUIAppsURL ? |
140 signin::SOURCE_APPS_PAGE_LINK : | 140 signin_metrics::SOURCE_APPS_PAGE_LINK : |
141 signin::SOURCE_NTP_LINK; | 141 signin_metrics::SOURCE_NTP_LINK; |
142 chrome::ShowBrowserSignin(browser, source); | 142 chrome::ShowBrowserSignin(browser, source); |
143 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); | 143 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); |
144 } | 144 } |
145 | 145 |
146 void NTPLoginHandler::RecordInHistogram(int type) { | 146 void NTPLoginHandler::RecordInHistogram(int type) { |
147 // Invalid type to record. | 147 // Invalid type to record. |
148 if (type < NTP_SIGN_IN_PROMO_VIEWED || | 148 if (type < NTP_SIGN_IN_PROMO_VIEWED || |
149 type > NTP_SIGN_IN_PROMO_CLICKED) { | 149 type > NTP_SIGN_IN_PROMO_CLICKED) { |
150 NOTREACHED(); | 150 NOTREACHED(); |
151 } else { | 151 } else { |
152 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type, | 152 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type, |
153 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY); | 153 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY); |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 void NTPLoginHandler::HandleLoginMessageSeen(const base::ListValue* args) { | 157 void NTPLoginHandler::HandleLoginMessageSeen(const base::ListValue* args) { |
158 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 158 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
159 prefs::kSignInPromoShowNTPBubble, false); | 159 prefs::kSignInPromoShowNTPBubble, false); |
160 NewTabUI* ntp_ui = NewTabUI::FromWebUIController(web_ui()->GetController()); | 160 NewTabUI* ntp_ui = NewTabUI::FromWebUIController(web_ui()->GetController()); |
161 // When instant extended is enabled, there may not be a NewTabUI object. | 161 // When instant extended is enabled, there may not be a NewTabUI object. |
162 if (ntp_ui) | 162 if (ntp_ui) |
163 ntp_ui->set_showing_sync_bubble(true); | 163 ntp_ui->set_showing_sync_bubble(true); |
164 } | 164 } |
165 | 165 |
166 void NTPLoginHandler::HandleShowAdvancedLoginUI(const base::ListValue* args) { | 166 void NTPLoginHandler::HandleShowAdvancedLoginUI(const base::ListValue* args) { |
167 Browser* browser = | 167 Browser* browser = |
168 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 168 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
169 if (browser) | 169 if (browser) |
170 chrome::ShowBrowserSignin(browser, signin::SOURCE_NTP_LINK); | 170 chrome::ShowBrowserSignin(browser, signin_metrics::SOURCE_NTP_LINK); |
171 } | 171 } |
172 | 172 |
173 void NTPLoginHandler::UpdateLogin() { | 173 void NTPLoginHandler::UpdateLogin() { |
174 Profile* profile = Profile::FromWebUI(web_ui()); | 174 Profile* profile = Profile::FromWebUI(web_ui()); |
175 std::string username = | 175 std::string username = |
176 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); | 176 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); |
177 | 177 |
178 base::string16 header, sub_header; | 178 base::string16 header, sub_header; |
179 std::string icon_url; | 179 std::string icon_url; |
180 if (!username.empty()) { | 180 if (!username.empty()) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 values->SetString("login_status_message", message); | 252 values->SetString("login_status_message", message); |
253 values->SetString("login_status_url", | 253 values->SetString("login_status_url", |
254 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); | 254 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); |
255 values->SetString("login_status_advanced", | 255 values->SetString("login_status_advanced", |
256 hide_sync ? base::string16() : | 256 hide_sync ? base::string16() : |
257 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); | 257 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); |
258 values->SetString("login_status_dismiss", | 258 values->SetString("login_status_dismiss", |
259 hide_sync ? base::string16() : | 259 hide_sync ? base::string16() : |
260 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); | 260 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); |
261 } | 261 } |
OLD | NEW |