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

Side by Side Diff: chrome/browser/profiles/profile_window.cc

Issue 1120013003: Add right-click user switching tutorial bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 7 months 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/profiles/profile_window.h ('k') | chrome/browser/profiles/profiles_state.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/profiles/profile_window.h" 5 #include "chrome/browser/profiles/profile_window.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/about_flags.h" 12 #include "chrome/browser/about_flags.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/lifetime/application_lifetime.h" 14 #include "chrome/browser/lifetime/application_lifetime.h"
15 #include "chrome/browser/pref_service_flags_storage.h" 15 #include "chrome/browser/pref_service_flags_storage.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
18 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/signin/account_reconcilor_factory.h" 19 #include "chrome/browser/signin/account_reconcilor_factory.h"
20 #include "chrome/browser/signin/account_tracker_service_factory.h" 20 #include "chrome/browser/signin/account_tracker_service_factory.h"
21 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
22 #include "chrome/browser/signin/signin_ui_util.h"
22 #include "chrome/browser/sync/profile_sync_service.h" 23 #include "chrome/browser/sync/profile_sync_service.h"
23 #include "chrome/browser/sync/profile_sync_service_factory.h" 24 #include "chrome/browser/sync/profile_sync_service_factory.h"
24 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_dialogs.h" 26 #include "chrome/browser/ui/browser_dialogs.h"
26 #include "chrome/browser/ui/profile_chooser_constants.h" 27 #include "chrome/browser/ui/profile_chooser_constants.h"
27 #include "chrome/browser/ui/user_manager.h" 28 #include "chrome/browser/ui/user_manager.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "components/signin/core/browser/account_reconcilor.h" 32 #include "components/signin/core/browser/account_reconcilor.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 desktop_type), 306 desktop_type),
306 base::string16(), 307 base::string16(),
307 base::string16(), 308 base::string16(),
308 std::string()); 309 std::string());
309 } 310 }
310 311
311 bool HasProfileSwitchTargets(Profile* profile) { 312 bool HasProfileSwitchTargets(Profile* profile) {
312 size_t min_profiles = profile->IsGuestSession() ? 1 : 2; 313 size_t min_profiles = profile->IsGuestSession() ? 1 : 2;
313 size_t number_of_profiles = 314 size_t number_of_profiles =
314 g_browser_process->profile_manager()->GetNumberOfProfiles(); 315 g_browser_process->profile_manager()->GetNumberOfProfiles();
315 return number_of_profiles < min_profiles; 316 return number_of_profiles >= min_profiles;
316 } 317 }
317 318
318 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, 319 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type,
319 ProfileManager::CreateCallback callback, 320 ProfileManager::CreateCallback callback,
320 ProfileMetrics::ProfileAdd metric) { 321 ProfileMetrics::ProfileAdd metric) {
321 ProfileInfoCache& cache = 322 ProfileInfoCache& cache =
322 g_browser_process->profile_manager()->GetProfileInfoCache(); 323 g_browser_process->profile_manager()->GetProfileInfoCache();
323 324
324 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); 325 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex();
325 ProfileManager::CreateMultiProfileAsync( 326 ProfileManager::CreateMultiProfileAsync(
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR; 519 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR;
519 return; 520 return;
520 case BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH: 521 case BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH:
521 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; 522 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER;
522 return; 523 return;
523 default: 524 default:
524 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; 525 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER;
525 } 526 }
526 } 527 }
527 528
529 bool ShouldShowWelcomeUpgradeTutorial(
530 Profile* profile, TutorialMode tutorial_mode) {
531 const int show_count = profile->GetPrefs()->GetInteger(
532 prefs::kProfileAvatarTutorialShown);
533 // Do not show the tutorial if user has dismissed it.
534 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax)
535 return false;
536
537 return tutorial_mode == TUTORIAL_MODE_WELCOME_UPGRADE ||
538 show_count != signin_ui_util::kUpgradeWelcomeTutorialShowMax;
539 }
540
541 bool ShouldShowRightClickTutorial(Profile* profile) {
542 PrefService* local_state = g_browser_process->local_state();
543 const bool dismissed = local_state->GetBoolean(
544 prefs::kProfileAvatarRightClickTutorialDismissed);
545
546 // Don't show the tutorial if it's already been dismissed or if right-clicking
547 // wouldn't show any targets.
548 return !dismissed && HasProfileSwitchTargets(profile);
549 }
550
528 } // namespace profiles 551 } // namespace profiles
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_window.h ('k') | chrome/browser/profiles/profiles_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698