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

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

Issue 1307093004: Remove references to IsNewAvatarMenu since the flag was removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback Created 5 years, 2 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
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // The file is overwritten if it exists. This function should only be called in 243 // The file is overwritten if it exists. This function should only be called in
244 // the blocking pool. 244 // the blocking pool.
245 void DumpBrowserHistograms(const base::FilePath& output_file) { 245 void DumpBrowserHistograms(const base::FilePath& output_file) {
246 base::ThreadRestrictions::AssertIOAllowed(); 246 base::ThreadRestrictions::AssertIOAllowed();
247 247
248 std::string output_string(base::StatisticsRecorder::ToJSON(std::string())); 248 std::string output_string(base::StatisticsRecorder::ToJSON(std::string()));
249 base::WriteFile(output_file, output_string.data(), 249 base::WriteFile(output_file, output_string.data(),
250 static_cast<int>(output_string.size())); 250 static_cast<int>(output_string.size()));
251 } 251 }
252 252
253 // Shows the User Manager on startup if the last used profile must sign in or
254 // if the last used profile was the guest or system profile.
255 // Returns true if the User Manager was shown, false otherwise.
256 bool ShowUserManagerOnStartupIfNeeded(
257 Profile* last_used_profile, const base::CommandLine& command_line) {
258 #if defined(OS_CHROMEOS)
259 // ChromeOS never shows the User Manager on startup.
260 return false;
261 #else
262 const ProfileInfoCache& profile_info =
263 g_browser_process->profile_manager()->GetProfileInfoCache();
264 size_t profile_index = profile_info.GetIndexOfProfileWithPath(
265 last_used_profile->GetPath());
266
267 if (profile_index == std::string::npos ||
268 !profile_info.ProfileIsSigninRequiredAtIndex(profile_index)) {
269 // Signin is not required. However, guest, system or locked profiles cannot
270 // be re-opened on startup. The only exception is if there's already a Guest
271 // window open in a separate process (for example, launching a new browser
272 // after clicking on a downloaded file in Guest mode).
273 if ((!last_used_profile->IsGuestSession() &&
274 !last_used_profile->IsSystemProfile()) ||
275 (chrome::GetTotalBrowserCountForProfile(
276 last_used_profile->GetOffTheRecordProfile()) > 0)) {
277 return false;
278 }
279 }
280
281 // Show the User Manager.
282 profiles::UserManagerProfileSelected action =
283 command_line.HasSwitch(switches::kShowAppList) ?
284 profiles::USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER :
285 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION;
286 UserManager::Show(
287 base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action);
288 return true;
289 #endif
290 }
291
253 } // namespace 292 } // namespace
254 293
255 StartupBrowserCreator::StartupBrowserCreator() 294 StartupBrowserCreator::StartupBrowserCreator()
256 : is_default_browser_dialog_suppressed_(false), 295 : is_default_browser_dialog_suppressed_(false),
257 show_main_browser_window_(true) { 296 show_main_browser_window_(true) {
258 } 297 }
259 298
260 StartupBrowserCreator::~StartupBrowserCreator() {} 299 StartupBrowserCreator::~StartupBrowserCreator() {}
261 300
262 // static 301 // static
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 703 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
665 // |last_opened_profiles| will be empty in the following circumstances: 704 // |last_opened_profiles| will be empty in the following circumstances:
666 // - This is the first launch. |last_used_profile| is the initial profile. 705 // - This is the first launch. |last_used_profile| is the initial profile.
667 // - The user exited the browser by closing all windows for all 706 // - The user exited the browser by closing all windows for all
668 // profiles. |last_used_profile| is the profile which owned the last open 707 // profiles. |last_used_profile| is the profile which owned the last open
669 // window. 708 // window.
670 // - Only incognito windows were open when the browser exited. 709 // - Only incognito windows were open when the browser exited.
671 // |last_used_profile| is the last used incognito profile. Restoring it will 710 // |last_used_profile| is the last used incognito profile. Restoring it will
672 // create a browser window for the corresponding original profile. 711 // create a browser window for the corresponding original profile.
673 if (last_opened_profiles.empty()) { 712 if (last_opened_profiles.empty()) {
674 // If the last used profile is locked or was a guest, show the user manager. 713 if (ShowUserManagerOnStartupIfNeeded(last_used_profile, command_line))
675 if (switches::IsNewAvatarMenu()) { 714 return true;
676 ProfileInfoCache& profile_info =
677 g_browser_process->profile_manager()->GetProfileInfoCache();
678 size_t profile_index = profile_info.GetIndexOfProfileWithPath(
679 last_used_profile->GetPath());
680 bool signin_required = profile_index != std::string::npos &&
681 profile_info.ProfileIsSigninRequiredAtIndex(profile_index);
682
683 // Guest, system or locked profiles cannot be re-opened on startup. The
684 // only exception is if there's already a Guest window open in a separate
685 // process (for example, launching a new browser after clicking on a
686 // downloaded file in Guest mode).
687 bool guest_or_system = last_used_profile->IsGuestSession() ||
688 last_used_profile->IsSystemProfile();
689 bool has_guest_browsers = guest_or_system &&
690 chrome::GetTotalBrowserCountForProfile(
691 last_used_profile->GetOffTheRecordProfile()) > 0;
692 if (signin_required || (guest_or_system && !has_guest_browsers)) {
693 profiles::UserManagerProfileSelected action =
694 command_line.HasSwitch(switches::kShowAppList) ?
695 profiles::USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER :
696 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION;
697 UserManager::Show(
698 base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action);
699 return true;
700 }
701 }
702 715
703 Profile* profile_to_open = last_used_profile->IsGuestSession() ? 716 Profile* profile_to_open = last_used_profile->IsGuestSession() ?
704 last_used_profile->GetOffTheRecordProfile() : last_used_profile; 717 last_used_profile->GetOffTheRecordProfile() : last_used_profile;
705 718
706 if (!browser_creator->LaunchBrowser(command_line, profile_to_open, 719 if (!browser_creator->LaunchBrowser(command_line, profile_to_open,
707 cur_dir, is_process_startup, 720 cur_dir, is_process_startup,
708 is_first_run)) { 721 is_first_run)) {
709 return false; 722 return false;
710 } 723 }
711 } else { 724 } else {
725 #if !defined(OS_CHROMEOS)
712 // Guest profiles should not be reopened on startup. This can happen if 726 // Guest profiles should not be reopened on startup. This can happen if
713 // the last used profile was a Guest, but other profiles were also open 727 // the last used profile was a Guest, but other profiles were also open
714 // when Chrome was closed. In this case, pick a different open profile 728 // when Chrome was closed. In this case, pick a different open profile
715 // to be the active one, since the Guest profile is never added to the list 729 // to be the active one, since the Guest profile is never added to the list
716 // of open profiles. 730 // of open profiles.
717 if (switches::IsNewAvatarMenu() && last_used_profile->IsGuestSession()) { 731 if (last_used_profile->IsGuestSession()) {
718 DCHECK(!last_opened_profiles[0]->IsGuestSession()); 732 DCHECK(!last_opened_profiles[0]->IsGuestSession());
719 last_used_profile = last_opened_profiles[0]; 733 last_used_profile = last_opened_profiles[0];
720 } 734 }
735 #endif
721 736
722 // Launch the last used profile with the full command line, and the other 737 // Launch the last used profile with the full command line, and the other
723 // opened profiles without the URLs to launch. 738 // opened profiles without the URLs to launch.
724 base::CommandLine command_line_without_urls(command_line.GetProgram()); 739 base::CommandLine command_line_without_urls(command_line.GetProgram());
725 const base::CommandLine::SwitchMap& switches = command_line.GetSwitches(); 740 const base::CommandLine::SwitchMap& switches = command_line.GetSwitches();
726 for (base::CommandLine::SwitchMap::const_iterator switch_it = 741 for (base::CommandLine::SwitchMap::const_iterator switch_it =
727 switches.begin(); 742 switches.begin();
728 switch_it != switches.end(); ++switch_it) { 743 switch_it != switches.end(); ++switch_it) {
729 command_line_without_urls.AppendSwitchNative(switch_it->first, 744 command_line_without_urls.AppendSwitchNative(switch_it->first,
730 switch_it->second); 745 switch_it->second);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 // If we are showing the app list then chrome isn't shown so load the app 857 // If we are showing the app list then chrome isn't shown so load the app
843 // list's profile rather than chrome's. 858 // list's profile rather than chrome's.
844 if (command_line.HasSwitch(switches::kShowAppList)) { 859 if (command_line.HasSwitch(switches::kShowAppList)) {
845 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> 860 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)->
846 GetProfilePath(user_data_dir); 861 GetProfilePath(user_data_dir);
847 } 862 }
848 863
849 return g_browser_process->profile_manager()->GetLastUsedProfileDir( 864 return g_browser_process->profile_manager()->GetLastUsedProfileDir(
850 user_data_dir); 865 user_data_dir);
851 } 866 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698