| OLD | NEW |
| 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_ui_util.h" |
| 21 #include "chrome/browser/sync/profile_sync_service.h" | 22 #include "chrome/browser/sync/profile_sync_service.h" |
| 22 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_dialogs.h" | 25 #include "chrome/browser/ui/browser_dialogs.h" |
| 25 #include "chrome/browser/ui/profile_chooser_constants.h" | 26 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 26 #include "chrome/browser/ui/user_manager.h" | 27 #include "chrome/browser/ui/user_manager.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "components/signin/core/browser/account_reconcilor.h" | 31 #include "components/signin/core/browser/account_reconcilor.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 desktop_type), | 304 desktop_type), |
| 304 base::string16(), | 305 base::string16(), |
| 305 base::string16(), | 306 base::string16(), |
| 306 std::string()); | 307 std::string()); |
| 307 } | 308 } |
| 308 | 309 |
| 309 bool HasProfileSwitchTargets(Profile* profile) { | 310 bool HasProfileSwitchTargets(Profile* profile) { |
| 310 size_t min_profiles = profile->IsGuestSession() ? 1 : 2; | 311 size_t min_profiles = profile->IsGuestSession() ? 1 : 2; |
| 311 size_t number_of_profiles = | 312 size_t number_of_profiles = |
| 312 g_browser_process->profile_manager()->GetNumberOfProfiles(); | 313 g_browser_process->profile_manager()->GetNumberOfProfiles(); |
| 313 return number_of_profiles < min_profiles; | 314 return number_of_profiles >= min_profiles; |
| 314 } | 315 } |
| 315 | 316 |
| 316 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, | 317 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, |
| 317 ProfileManager::CreateCallback callback, | 318 ProfileManager::CreateCallback callback, |
| 318 ProfileMetrics::ProfileAdd metric) { | 319 ProfileMetrics::ProfileAdd metric) { |
| 319 ProfileInfoCache& cache = | 320 ProfileInfoCache& cache = |
| 320 g_browser_process->profile_manager()->GetProfileInfoCache(); | 321 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 321 | 322 |
| 322 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); | 323 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 323 ProfileManager::CreateMultiProfileAsync( | 324 ProfileManager::CreateMultiProfileAsync( |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR; | 517 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR; |
| 517 return; | 518 return; |
| 518 case BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH: | 519 case BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH: |
| 519 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 520 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
| 520 return; | 521 return; |
| 521 default: | 522 default: |
| 522 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; | 523 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
| 523 } | 524 } |
| 524 } | 525 } |
| 525 | 526 |
| 527 bool ShouldShowWelcomeUpgradeTutorial( |
| 528 Profile* profile, TutorialMode tutorial_mode) { |
| 529 const int show_count = profile->GetPrefs()->GetInteger( |
| 530 prefs::kProfileAvatarTutorialShown); |
| 531 // Do not show the tutorial if user has dismissed it. |
| 532 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
| 533 return false; |
| 534 |
| 535 return tutorial_mode == TUTORIAL_MODE_WELCOME_UPGRADE || |
| 536 show_count != signin_ui_util::kUpgradeWelcomeTutorialShowMax; |
| 537 } |
| 538 |
| 539 bool ShouldShowRightClickTutorial(Profile* profile) { |
| 540 PrefService* local_state = g_browser_process->local_state(); |
| 541 const bool dismissed = local_state->GetBoolean( |
| 542 prefs::kProfileAvatarRightClickTutorialDismissed); |
| 543 |
| 544 // Don't show the tutorial if it's already been dismissed or if right-clicking |
| 545 // wouldn't show any targets. |
| 546 return !dismissed && HasProfileSwitchTargets(profile); |
| 547 } |
| 548 |
| 526 } // namespace profiles | 549 } // namespace profiles |
| OLD | NEW |