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

Side by Side Diff: chrome/browser/ui/webui/app_launcher_login_handler.cc

Issue 1473543002: Implement newly designed sign-in related histograms for desktop platorms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 5 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
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/app_launcher_login_handler.h" 5 #include "chrome/browser/ui/webui/app_launcher_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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 .email; 119 .email;
120 if (!username.empty()) 120 if (!username.empty())
121 return; 121 return;
122 122
123 content::WebContents* web_contents = web_ui()->GetWebContents(); 123 content::WebContents* web_contents = web_ui()->GetWebContents();
124 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 124 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
125 if (!browser) 125 if (!browser)
126 return; 126 return;
127 127
128 // The user isn't signed in, show the sign in promo. 128 // The user isn't signed in, show the sign in promo.
129 signin_metrics::Source source = 129 signin_metrics::AccessPoint access_point =
130 web_contents->GetURL().spec() == chrome::kChromeUIAppsURL ? 130 web_contents->GetURL().spec() == chrome::kChromeUIAppsURL
131 signin_metrics::SOURCE_APPS_PAGE_LINK : 131 ? signin_metrics::ACCESS_POINT_APPS_PAGE_LINK
132 signin_metrics::SOURCE_NTP_LINK; 132 : signin_metrics::ACCESS_POINT_NTP_LINK;
133 chrome::ShowBrowserSignin(browser, source); 133 chrome::ShowBrowserSignin(browser, access_point);
134 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED); 134 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
135 } 135 }
136 136
137 void AppLauncherLoginHandler::RecordInHistogram(int type) { 137 void AppLauncherLoginHandler::RecordInHistogram(int type) {
138 // Invalid type to record. 138 // Invalid type to record.
139 if (type < NTP_SIGN_IN_PROMO_VIEWED || 139 if (type < NTP_SIGN_IN_PROMO_VIEWED ||
140 type > NTP_SIGN_IN_PROMO_CLICKED) { 140 type > NTP_SIGN_IN_PROMO_CLICKED) {
141 NOTREACHED(); 141 NOTREACHED();
142 } else { 142 } else {
143 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type, 143 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type,
144 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY); 144 NTP_SIGN_IN_PROMO_BUCKET_BOUNDARY);
145 } 145 }
146 } 146 }
147 147
148 void AppLauncherLoginHandler::HandleLoginMessageSeen( 148 void AppLauncherLoginHandler::HandleLoginMessageSeen(
149 const base::ListValue* args) { 149 const base::ListValue* args) {
150 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 150 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
151 prefs::kSignInPromoShowNTPBubble, false); 151 prefs::kSignInPromoShowNTPBubble, false);
152 NewTabUI* ntp_ui = NewTabUI::FromWebUIController(web_ui()->GetController()); 152 NewTabUI* ntp_ui = NewTabUI::FromWebUIController(web_ui()->GetController());
153 // When instant extended is enabled, there may not be a NewTabUI object. 153 // When instant extended is enabled, there may not be a NewTabUI object.
154 if (ntp_ui) 154 if (ntp_ui)
155 ntp_ui->set_showing_sync_bubble(true); 155 ntp_ui->set_showing_sync_bubble(true);
156 } 156 }
157 157
158 void AppLauncherLoginHandler::HandleShowAdvancedLoginUI( 158 void AppLauncherLoginHandler::HandleShowAdvancedLoginUI(
159 const base::ListValue* args) { 159 const base::ListValue* args) {
160 Browser* browser = 160 content::WebContents* web_contents = web_ui()->GetWebContents();
161 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); 161 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
162 if (browser) 162 if (browser) {
Bernhard Bauer 2015/12/04 11:06:24 Return early if |browser| is null?
gogerald1 2015/12/04 20:49:09 Done.
163 chrome::ShowBrowserSignin(browser, signin_metrics::SOURCE_NTP_LINK); 163 signin_metrics::AccessPoint access_point =
164 web_contents->GetURL().spec() == chrome::kChromeUIAppsURL
165 ? signin_metrics::ACCESS_POINT_APPS_PAGE_LINK
166 : signin_metrics::ACCESS_POINT_NTP_LINK;
167 chrome::ShowBrowserSignin(browser, access_point);
168 }
164 } 169 }
165 170
166 void AppLauncherLoginHandler::UpdateLogin() { 171 void AppLauncherLoginHandler::UpdateLogin() {
167 std::string username = profile_info_watcher_->GetAuthenticatedUsername(); 172 std::string username = profile_info_watcher_->GetAuthenticatedUsername();
168 base::string16 header, sub_header; 173 base::string16 header, sub_header;
169 std::string icon_url; 174 std::string icon_url;
170 Profile* profile = Profile::FromWebUI(web_ui()); 175 Profile* profile = Profile::FromWebUI(web_ui());
171 if (!username.empty()) { 176 if (!username.empty()) {
172 ProfileInfoCache& cache = 177 ProfileInfoCache& cache =
173 g_browser_process->profile_manager()->GetProfileInfoCache(); 178 g_browser_process->profile_manager()->GetProfileInfoCache();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 values->SetString("login_status_message", message); 249 values->SetString("login_status_message", message);
245 values->SetString("login_status_url", 250 values->SetString("login_status_url",
246 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); 251 hide_sync ? std::string() : chrome::kSyncLearnMoreURL);
247 values->SetString("login_status_advanced", 252 values->SetString("login_status_advanced",
248 hide_sync ? base::string16() : 253 hide_sync ? base::string16() :
249 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 254 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
250 values->SetString("login_status_dismiss", 255 values->SetString("login_status_dismiss",
251 hide_sync ? base::string16() : 256 hide_sync ? base::string16() :
252 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 257 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
253 } 258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698