| 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 if (info_cache.ProfileIsSigninRequiredAtIndex(index)) |
| 398 pref.type = SessionStartupPref::LAST; |
| 399 } |
| 400 |
| 391 if (pref.type == SessionStartupPref::LAST && | 401 if (pref.type == SessionStartupPref::LAST && |
| 392 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { | 402 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { |
| 393 // We don't store session information when incognito. If the user has | 403 // We don't store session information when incognito. If the user has |
| 394 // chosen to restore last session and launched incognito, fallback to | 404 // chosen to restore last session and launched incognito, fallback to |
| 395 // default launch behavior. | 405 // default launch behavior. |
| 396 pref.type = SessionStartupPref::DEFAULT; | 406 pref.type = SessionStartupPref::DEFAULT; |
| 397 } | 407 } |
| 398 | 408 |
| 399 return pref; | 409 return pref; |
| 400 } | 410 } |
| (...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 | 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 |