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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 | 381 |
382 // The switches::kRestoreLastSession command line switch is used to restore | 382 // The switches::kRestoreLastSession command line switch is used to restore |
383 // sessions after a browser self restart (e.g. after a Chrome upgrade). | 383 // sessions after a browser self restart (e.g. after a Chrome upgrade). |
384 // However, new profiles can be created from a browser process that has this | 384 // However, new profiles can be created from a browser process that has this |
385 // switch so do not set the session pref to SessionStartupPref::LAST for | 385 // switch so do not set the session pref to SessionStartupPref::LAST for |
386 // those as there is nothing to restore. | 386 // those as there is nothing to restore. |
387 if ((command_line.HasSwitch(switches::kRestoreLastSession) || did_restart) && | 387 if ((command_line.HasSwitch(switches::kRestoreLastSession) || did_restart) && |
388 !profile->IsNewProfile()) { | 388 !profile->IsNewProfile()) { |
389 pref.type = SessionStartupPref::LAST; | 389 pref.type = SessionStartupPref::LAST; |
390 } | 390 } |
391 | |
392 // A browser starting for a profile being unlocked should always restore. | |
393 if (!profile->IsGuestSession()) { | |
394 ProfileInfoCache& info_cache = | |
395 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
396 size_t index = info_cache.GetIndexOfProfileWithPath(profile->GetPath()); | |
397 | |
398 // If called during CreatePrimaryProfile on startup, |profile| has not yet | |
msw
2014/10/30 22:29:49
nit: not sure the comment is entirely necessary.
| |
399 // been added to the ProfileInfoCache; other code checks IsSigninRequired | |
400 // and launches the UserManager if set. Thus here, only handle Profiles | |
401 // that are in the ProfileInfoCache and have the bit set. | |
402 if (index != std::string::npos && | |
403 info_cache.ProfileIsSigninRequiredAtIndex(index)) { | |
404 pref.type = SessionStartupPref::LAST; | |
msw
2014/10/30 22:29:50
nit: fix indent
| |
405 } | |
406 } | |
407 | |
391 if (pref.type == SessionStartupPref::LAST && | 408 if (pref.type == SessionStartupPref::LAST && |
392 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { | 409 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { |
393 // We don't store session information when incognito. If the user has | 410 // We don't store session information when incognito. If the user has |
394 // chosen to restore last session and launched incognito, fallback to | 411 // chosen to restore last session and launched incognito, fallback to |
395 // default launch behavior. | 412 // default launch behavior. |
396 pref.type = SessionStartupPref::DEFAULT; | 413 pref.type = SessionStartupPref::DEFAULT; |
397 } | 414 } |
398 | 415 |
399 return pref; | 416 return pref; |
400 } | 417 } |
(...skipping 345 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 | 763 // If we are showing the app list then chrome isn't shown so load the app |
747 // list's profile rather than chrome's. | 764 // list's profile rather than chrome's. |
748 if (command_line.HasSwitch(switches::kShowAppList)) { | 765 if (command_line.HasSwitch(switches::kShowAppList)) { |
749 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 766 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
750 GetProfilePath(user_data_dir); | 767 GetProfilePath(user_data_dir); |
751 } | 768 } |
752 | 769 |
753 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 770 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
754 user_data_dir); | 771 user_data_dir); |
755 } | 772 } |
OLD | NEW |