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 (index != std::string::npos && |
| 399 info_cache.ProfileIsSigninRequiredAtIndex(index)) { |
| 400 pref.type = SessionStartupPref::LAST; |
| 401 } |
| 402 } |
| 403 |
391 if (pref.type == SessionStartupPref::LAST && | 404 if (pref.type == SessionStartupPref::LAST && |
392 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { | 405 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { |
393 // We don't store session information when incognito. If the user has | 406 // We don't store session information when incognito. If the user has |
394 // chosen to restore last session and launched incognito, fallback to | 407 // chosen to restore last session and launched incognito, fallback to |
395 // default launch behavior. | 408 // default launch behavior. |
396 pref.type = SessionStartupPref::DEFAULT; | 409 pref.type = SessionStartupPref::DEFAULT; |
397 } | 410 } |
398 | 411 |
399 return pref; | 412 return pref; |
400 } | 413 } |
(...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 | 759 // If we are showing the app list then chrome isn't shown so load the app |
747 // list's profile rather than chrome's. | 760 // list's profile rather than chrome's. |
748 if (command_line.HasSwitch(switches::kShowAppList)) { | 761 if (command_line.HasSwitch(switches::kShowAppList)) { |
749 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 762 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
750 GetProfilePath(user_data_dir); | 763 GetProfilePath(user_data_dir); |
751 } | 764 } |
752 | 765 |
753 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 766 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
754 user_data_dir); | 767 user_data_dir); |
755 } | 768 } |
OLD | NEW |