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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_login_handler.cc

Issue 776423002: The Apps ntp page should not display an avatar menu when clicking on the username. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/test/base/test_browser_window.h » ('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) 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const content::NotificationSource& source, 116 const content::NotificationSource& source,
117 const content::NotificationDetails& details) { 117 const content::NotificationDetails& details) {
118 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); 118 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type);
119 UpdateLogin(); 119 UpdateLogin();
120 } 120 }
121 121
122 void NTPLoginHandler::HandleInitializeSyncLogin(const base::ListValue* args) { 122 void NTPLoginHandler::HandleInitializeSyncLogin(const base::ListValue* args) {
123 UpdateLogin(); 123 UpdateLogin();
124 } 124 }
125 125
126 void NTPLoginHandler::HandleShowSyncLoginUI(const base::ListValue* args) { 126 void NTPLoginHandler::HandleShowSyncLoginUI(const base::ListValue* args) {
Dan Beam 2014/12/11 01:40:19 nit: I think the code makes more sense organized l
noms (inactive) 2014/12/12 18:19:30 Done.
127 Profile* profile = Profile::FromWebUI(web_ui()); 127 Profile* profile = Profile::FromWebUI(web_ui());
128 std::string username = profile->GetPrefs()->GetString( 128 std::string username = profile->GetPrefs()->GetString(
129 prefs::kGoogleServicesUsername); 129 prefs::kGoogleServicesUsername);
130 content::WebContents* web_contents = web_ui()->GetWebContents(); 130 content::WebContents* web_contents = web_ui()->GetWebContents();
131 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 131 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
132 if (!browser) 132 if (!browser)
133 return; 133 return;
134 134
135 if (username.empty()) { 135 if (!username.empty())
136 // The user isn't signed in, show the sign in promo. 136 return;
137 if (signin::ShouldShowPromo(profile)) {
138 signin::Source source =
139 (web_contents->GetURL().spec() == chrome::kChromeUIAppsURL) ?
140 signin::SOURCE_APPS_PAGE_LINK :
141 signin::SOURCE_NTP_LINK;
142 chrome::ShowBrowserSignin(browser, source);
143 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
144 }
145 } else if (args->GetSize() == 4) {
146 // The user is signed in, show the profiles menu.
147 double x = 0;
148 double y = 0;
149 double width = 0;
150 double height = 0;
151 bool success = args->GetDouble(0, &x);
152 DCHECK(success);
153 success = args->GetDouble(1, &y);
154 DCHECK(success);
155 success = args->GetDouble(2, &width);
156 DCHECK(success);
157 success = args->GetDouble(3, &height);
158 DCHECK(success);
159 137
160 double zoom = content::ZoomLevelToZoomFactor( 138 // The user isn't signed in, show the sign in promo.
161 ZoomController::FromWebContents(web_contents)->GetZoomLevel()); 139 if (signin::ShouldShowPromo(profile)) {
162 gfx::Rect rect(x * zoom, y * zoom, width * zoom, height * zoom); 140 signin::Source source =
163 141 (web_contents->GetURL().spec() == chrome::kChromeUIAppsURL) ?
Dan Beam 2014/12/11 01:40:19 nit: unnecessary ()
noms (inactive) 2014/12/12 18:19:30 Done.
164 browser->window()->ShowAvatarBubble(web_ui()->GetWebContents(), rect); 142 signin::SOURCE_APPS_PAGE_LINK :
165 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::NTP_AVATAR_BUBBLE); 143 signin::SOURCE_NTP_LINK;
144 chrome::ShowBrowserSignin(browser, source);
145 RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
166 } 146 }
167 } 147 }
168 148
169 void NTPLoginHandler::RecordInHistogram(int type) { 149 void NTPLoginHandler::RecordInHistogram(int type) {
170 // Invalid type to record. 150 // Invalid type to record.
171 if (type < NTP_SIGN_IN_PROMO_VIEWED || 151 if (type < NTP_SIGN_IN_PROMO_VIEWED ||
172 type > NTP_SIGN_IN_PROMO_CLICKED) { 152 type > NTP_SIGN_IN_PROMO_CLICKED) {
173 NOTREACHED(); 153 NOTREACHED();
174 } else { 154 } else {
175 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type, 155 UMA_HISTOGRAM_ENUMERATION("SyncPromo.NTPPromo", type,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 values->SetString("login_status_message", message); 255 values->SetString("login_status_message", message);
276 values->SetString("login_status_url", 256 values->SetString("login_status_url",
277 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); 257 hide_sync ? std::string() : chrome::kSyncLearnMoreURL);
278 values->SetString("login_status_advanced", 258 values->SetString("login_status_advanced",
279 hide_sync ? base::string16() : 259 hide_sync ? base::string16() :
280 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 260 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
281 values->SetString("login_status_dismiss", 261 values->SetString("login_status_dismiss",
282 hide_sync ? base::string16() : 262 hide_sync ? base::string16() :
283 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 263 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
284 } 264 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698