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

Side by Side Diff: chrome/browser/ui/chrome_pages.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: format 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/chrome_pages.h" 5 #include "chrome/browser/ui/chrome_pages.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; 350 params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE;
351 ShowSingletonTabOverwritingNTP(browser, params); 351 ShowSingletonTabOverwritingNTP(browser, params);
352 } 352 }
353 353
354 void ShowSearchEngineSettings(Browser* browser) { 354 void ShowSearchEngineSettings(Browser* browser) {
355 content::RecordAction(UserMetricsAction("EditSearchEngines")); 355 content::RecordAction(UserMetricsAction("EditSearchEngines"));
356 ShowSettingsSubPage(browser, kSearchEnginesSubPage); 356 ShowSettingsSubPage(browser, kSearchEnginesSubPage);
357 } 357 }
358 358
359 #if !defined(OS_ANDROID) && !defined(OS_IOS) 359 #if !defined(OS_ANDROID) && !defined(OS_IOS)
360 void ShowBrowserSignin(Browser* browser, signin_metrics::Source source) { 360 void ShowBrowserSignin(Browser* browser,
361 signin_metrics::AccessPoint access_point) {
361 Profile* original_profile = browser->profile()->GetOriginalProfile(); 362 Profile* original_profile = browser->profile()->GetOriginalProfile();
362 SigninManagerBase* manager = 363 SigninManagerBase* manager =
363 SigninManagerFactory::GetForProfile(original_profile); 364 SigninManagerFactory::GetForProfile(original_profile);
364 DCHECK(manager->IsSigninAllowed()); 365 DCHECK(manager->IsSigninAllowed());
365 // If the browser's profile is an incognito profile, make sure to use 366 // If the browser's profile is an incognito profile, make sure to use
366 // a browser window from the original profile. The user cannot sign in 367 // a browser window from the original profile. The user cannot sign in
367 // from an incognito window. 368 // from an incognito window.
368 bool switched_browser = false; 369 bool switched_browser = false;
369 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer; 370 scoped_ptr<ScopedTabbedBrowserDisplayer> displayer;
370 if (browser->profile()->IsOffTheRecord()) { 371 if (browser->profile()->IsOffTheRecord()) {
371 switched_browser = true; 372 switched_browser = true;
372 displayer.reset(new ScopedTabbedBrowserDisplayer( 373 displayer.reset(new ScopedTabbedBrowserDisplayer(
373 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE)); 374 original_profile, chrome::HOST_DESKTOP_TYPE_NATIVE));
374 browser = displayer->browser(); 375 browser = displayer->browser();
375 } 376 }
376 377
377 signin_metrics::LogSigninSource(source); 378 // Since the extension is a separate application, it might steal focus
378
379 // Since the app launcher is a separate application, it might steal focus
380 // away from Chrome, and accidentally close the avatar bubble. The same will 379 // away from Chrome, and accidentally close the avatar bubble. The same will
381 // happen if we had to switch browser windows to show the sign in page. In 380 // happen if we had to switch browser windows to show the sign in page. In
382 // this case, fallback to the full-tab signin page. 381 // this case, fallback to the full-tab signin page.
383 bool show_avatar_bubble = 382 bool show_avatar_bubble =
384 source != signin_metrics::SOURCE_APP_LAUNCHER && !switched_browser; 383 access_point != signin_metrics::AccessPoint::ACCESS_POINT_EXTENSIONS &&
384 !switched_browser;
385 #if defined(OS_CHROMEOS) 385 #if defined(OS_CHROMEOS)
386 // ChromeOS doesn't have the avatar bubble. 386 // ChromeOS doesn't have the avatar bubble.
387 show_avatar_bubble = false; 387 show_avatar_bubble = false;
388 #endif 388 #endif
389 389
390 if (show_avatar_bubble) { 390 if (show_avatar_bubble) {
391 browser->window()->ShowAvatarBubbleFromAvatarButton( 391 browser->window()->ShowAvatarBubbleFromAvatarButton(
392 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, 392 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN,
393 signin::ManageAccountsParams()); 393 signin::ManageAccountsParams(), access_point);
394 } else { 394 } else {
395 NavigateToSingletonTab(browser, GURL(signin::GetPromoURL(source, false))); 395 NavigateToSingletonTab(
396 browser,
397 signin::GetPromoURL(
398 access_point, signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT,
399 false));
396 DCHECK_GT(browser->tab_strip_model()->count(), 0); 400 DCHECK_GT(browser->tab_strip_model()->count(), 0);
397 } 401 }
398 } 402 }
399 403
400 void ShowBrowserSigninOrSettings( 404 void ShowBrowserSigninOrSettings(Browser* browser,
401 Browser* browser, 405 signin_metrics::AccessPoint access_point) {
402 signin_metrics::Source source) {
403 Profile* original_profile = browser->profile()->GetOriginalProfile(); 406 Profile* original_profile = browser->profile()->GetOriginalProfile();
404 SigninManagerBase* manager = 407 SigninManagerBase* manager =
405 SigninManagerFactory::GetForProfile(original_profile); 408 SigninManagerFactory::GetForProfile(original_profile);
406 DCHECK(manager->IsSigninAllowed()); 409 DCHECK(manager->IsSigninAllowed());
407 if (manager->IsAuthenticated()) 410 if (manager->IsAuthenticated())
408 ShowSettings(browser); 411 ShowSettings(browser);
409 else 412 else
410 ShowBrowserSignin(browser, source); 413 ShowBrowserSignin(browser, access_point);
411 } 414 }
412 #endif 415 #endif
413 416
414 } // namespace chrome 417 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/chrome_pages.h ('k') | chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698