Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/startup/startup_browser_creator.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "apps/app_load_service.h" | 10 #include "apps/app_load_service.h" |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 if (last_opened_profiles.empty()) { | 626 if (last_opened_profiles.empty()) { |
| 627 // If the last used profile is locked or was a guest, show the user manager. | 627 // If the last used profile is locked or was a guest, show the user manager. |
| 628 if (switches::IsNewAvatarMenu()) { | 628 if (switches::IsNewAvatarMenu()) { |
| 629 ProfileInfoCache& profile_info = | 629 ProfileInfoCache& profile_info = |
| 630 g_browser_process->profile_manager()->GetProfileInfoCache(); | 630 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 631 size_t profile_index = profile_info.GetIndexOfProfileWithPath( | 631 size_t profile_index = profile_info.GetIndexOfProfileWithPath( |
| 632 last_used_profile->GetPath()); | 632 last_used_profile->GetPath()); |
| 633 bool signin_required = profile_index != std::string::npos && | 633 bool signin_required = profile_index != std::string::npos && |
| 634 profile_info.ProfileIsSigninRequiredAtIndex(profile_index); | 634 profile_info.ProfileIsSigninRequiredAtIndex(profile_index); |
| 635 | 635 |
| 636 // Guest or locked profiles cannot be re-opened on startup. | 636 // Guest or locked profiles cannot be re-opened on startup. The only |
| 637 if (signin_required || last_used_profile->IsGuestSession()) { | 637 // exception is if there's already a Guest window open in a separate |
| 638 // process (for example, launching a new browser after clicking on a | |
| 639 // downloaded file in Guest mode). | |
| 640 size_t guest_browsers = last_used_profile->IsGuestSession() ? | |
| 641 chrome::GetTotalBrowserCountForProfile( | |
| 642 last_used_profile->GetOffTheRecordProfile()) : -1; | |
|
sky
2014/10/30 21:17:51
I suspect the -1 to a size_t is going to cause war
noms (inactive)
2014/10/31 19:52:10
Done. Also fixed the logic a bit (there needs to b
| |
| 643 if (signin_required || (guest_browsers == 0)) { | |
| 638 UserManager::Show(base::FilePath(), | 644 UserManager::Show(base::FilePath(), |
| 639 profiles::USER_MANAGER_NO_TUTORIAL, | 645 profiles::USER_MANAGER_NO_TUTORIAL, |
| 640 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 646 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 641 return true; | 647 return true; |
| 642 } | 648 } |
| 643 } | 649 } |
| 644 if (!browser_creator->LaunchBrowser(command_line, last_used_profile, | 650 |
| 651 Profile* profile_to_open = last_used_profile->IsGuestSession() ? | |
| 652 last_used_profile->GetOffTheRecordProfile() : last_used_profile; | |
| 653 | |
| 654 if (!browser_creator->LaunchBrowser(command_line, profile_to_open, | |
| 645 cur_dir, is_process_startup, | 655 cur_dir, is_process_startup, |
| 646 is_first_run, return_code)) { | 656 is_first_run, return_code)) { |
| 647 return false; | 657 return false; |
| 648 } | 658 } |
| 649 } else { | 659 } else { |
| 650 // Guest profiles should not be reopened on startup. This can happen if | 660 // Guest profiles should not be reopened on startup. This can happen if |
| 651 // the last used profile was a Guest, but other profiles were also open | 661 // the last used profile was a Guest, but other profiles were also open |
| 652 // when Chrome was closed. In this case, pick a different open profile | 662 // when Chrome was closed. In this case, pick a different open profile |
| 653 // to be the active one, since the Guest profile is never added to the list | 663 // to be the active one, since the Guest profile is never added to the list |
| 654 // of open profiles. | 664 // of open profiles. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 // If we are showing the app list then chrome isn't shown so load the app | 756 // If we are showing the app list then chrome isn't shown so load the app |
| 747 // list's profile rather than chrome's. | 757 // list's profile rather than chrome's. |
| 748 if (command_line.HasSwitch(switches::kShowAppList)) { | 758 if (command_line.HasSwitch(switches::kShowAppList)) { |
| 749 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 759 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
| 750 GetProfilePath(user_data_dir); | 760 GetProfilePath(user_data_dir); |
| 751 } | 761 } |
| 752 | 762 |
| 753 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 763 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 754 user_data_dir); | 764 user_data_dir); |
| 755 } | 765 } |
| OLD | NEW |