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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator.cc

Issue 691063002: Reopen a Guest browser and not the User Manager if another Guest browser is already open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: boolean nit Created 6 years, 1 month 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 | « no previous file | no next file » | 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/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
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 bool has_guest_browsers = last_used_profile->IsGuestSession() &&
641 chrome::GetTotalBrowserCountForProfile(
642 last_used_profile->GetOffTheRecordProfile()) > 0;
643 if (signin_required ||
644 (last_used_profile->IsGuestSession() && !has_guest_browsers)) {
638 UserManager::Show(base::FilePath(), 645 UserManager::Show(base::FilePath(),
639 profiles::USER_MANAGER_NO_TUTORIAL, 646 profiles::USER_MANAGER_NO_TUTORIAL,
640 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 647 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
641 return true; 648 return true;
642 } 649 }
643 } 650 }
644 if (!browser_creator->LaunchBrowser(command_line, last_used_profile, 651
652 Profile* profile_to_open = last_used_profile->IsGuestSession() ?
653 last_used_profile->GetOffTheRecordProfile() : last_used_profile;
654
655 if (!browser_creator->LaunchBrowser(command_line, profile_to_open,
645 cur_dir, is_process_startup, 656 cur_dir, is_process_startup,
646 is_first_run, return_code)) { 657 is_first_run, return_code)) {
647 return false; 658 return false;
648 } 659 }
649 } else { 660 } else {
650 // Guest profiles should not be reopened on startup. This can happen if 661 // 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 662 // 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 663 // 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 664 // to be the active one, since the Guest profile is never added to the list
654 // of open profiles. 665 // of open profiles.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 // If we are showing the app list then chrome isn't shown so load the app 757 // If we are showing the app list then chrome isn't shown so load the app
747 // list's profile rather than chrome's. 758 // list's profile rather than chrome's.
748 if (command_line.HasSwitch(switches::kShowAppList)) { 759 if (command_line.HasSwitch(switches::kShowAppList)) {
749 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> 760 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)->
750 GetProfilePath(user_data_dir); 761 GetProfilePath(user_data_dir);
751 } 762 }
752 763
753 return g_browser_process->profile_manager()->GetLastUsedProfileDir( 764 return g_browser_process->profile_manager()->GetLastUsedProfileDir(
754 user_data_dir); 765 user_data_dir);
755 } 766 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698