| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 PrefService* prefs = profile->GetPrefs(); | 355 PrefService* prefs = profile->GetPrefs(); |
| 356 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); | 356 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); |
| 357 | 357 |
| 358 // IsChromeFirstRun() looks for a sentinel file to determine whether the user | 358 // IsChromeFirstRun() looks for a sentinel file to determine whether the user |
| 359 // is starting Chrome for the first time. On Chrome OS, the sentinel is stored | 359 // is starting Chrome for the first time. On Chrome OS, the sentinel is stored |
| 360 // in a location shared by all users and the check is meaningless. Query the | 360 // in a location shared by all users and the check is meaningless. Query the |
| 361 // UserManager instead to determine whether the user is new. | 361 // UserManager instead to determine whether the user is new. |
| 362 #if defined(OS_CHROMEOS) | 362 #if defined(OS_CHROMEOS) |
| 363 const bool is_first_run = | 363 const bool is_first_run = |
| 364 user_manager::UserManager::Get()->IsCurrentUserNew(); | 364 user_manager::UserManager::Get()->IsCurrentUserNew(); |
| 365 // On ChromeOS restarts force the user to login again. The expectation is that |
| 366 // after a login the user gets clean state. For this reason we ignore |
| 367 // StartupBrowserCreator::WasRestarted(). |
| 368 const bool did_restart = false; |
| 365 #else | 369 #else |
| 366 const bool is_first_run = first_run::IsChromeFirstRun(); | 370 const bool is_first_run = first_run::IsChromeFirstRun(); |
| 371 const bool did_restart = StartupBrowserCreator::WasRestarted(); |
| 367 #endif | 372 #endif |
| 368 | 373 |
| 369 // The pref has an OS-dependent default value. For the first run only, this | 374 // The pref has an OS-dependent default value. For the first run only, this |
| 370 // default is overridden with SessionStartupPref::DEFAULT so that first run | 375 // default is overridden with SessionStartupPref::DEFAULT so that first run |
| 371 // behavior (sync promo, welcome page) is consistently invoked. | 376 // behavior (sync promo, welcome page) is consistently invoked. |
| 372 // This applies only if the pref is still at its default and has not been | 377 // This applies only if the pref is still at its default and has not been |
| 373 // set by the user, managed prefs or policy. | 378 // set by the user, managed prefs or policy. |
| 374 if (is_first_run && SessionStartupPref::TypeIsDefault(prefs)) | 379 if (is_first_run && SessionStartupPref::TypeIsDefault(prefs)) |
| 375 pref.type = SessionStartupPref::DEFAULT; | 380 pref.type = SessionStartupPref::DEFAULT; |
| 376 | 381 |
| 377 // The switches::kRestoreLastSession command line switch is used to restore | 382 // The switches::kRestoreLastSession command line switch is used to restore |
| 378 // 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). |
| 379 // 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 |
| 380 // 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 |
| 381 // those as there is nothing to restore. | 386 // those as there is nothing to restore. |
| 382 if ((command_line.HasSwitch(switches::kRestoreLastSession) || | 387 if ((command_line.HasSwitch(switches::kRestoreLastSession) || did_restart) && |
| 383 StartupBrowserCreator::WasRestarted()) && | |
| 384 !profile->IsNewProfile()) { | 388 !profile->IsNewProfile()) { |
| 385 pref.type = SessionStartupPref::LAST; | 389 pref.type = SessionStartupPref::LAST; |
| 386 } | 390 } |
| 387 if (pref.type == SessionStartupPref::LAST && | 391 if (pref.type == SessionStartupPref::LAST && |
| 388 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { | 392 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { |
| 389 // We don't store session information when incognito. If the user has | 393 // We don't store session information when incognito. If the user has |
| 390 // chosen to restore last session and launched incognito, fallback to | 394 // chosen to restore last session and launched incognito, fallback to |
| 391 // default launch behavior. | 395 // default launch behavior. |
| 392 pref.type = SessionStartupPref::DEFAULT; | 396 pref.type = SessionStartupPref::DEFAULT; |
| 393 } | 397 } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 // If we are showing the app list then chrome isn't shown so load the app | 743 // If we are showing the app list then chrome isn't shown so load the app |
| 740 // list's profile rather than chrome's. | 744 // list's profile rather than chrome's. |
| 741 if (command_line.HasSwitch(switches::kShowAppList)) { | 745 if (command_line.HasSwitch(switches::kShowAppList)) { |
| 742 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> | 746 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> |
| 743 GetProfilePath(user_data_dir); | 747 GetProfilePath(user_data_dir); |
| 744 } | 748 } |
| 745 | 749 |
| 746 return g_browser_process->profile_manager()->GetLastUsedProfileDir( | 750 return g_browser_process->profile_manager()->GetLastUsedProfileDir( |
| 747 user_data_dir); | 751 user_data_dir); |
| 748 } | 752 } |
| OLD | NEW |