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

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

Issue 653773003: Fixing problem where a session restore gets performed even though users don't want it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest_chromeos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // A controlled restart on ChromeOS should respect the session restore state.
366 const bool did_restart = false;
sky 2014/10/15 23:57:20 Won't this mean if you change an about:flag and cl
sky 2014/10/16 20:35:27 This comment is confusing. I think you mean someth
Mr4D (OOO till 08-26) 2014/10/16 20:58:43 Done.
365 #else 367 #else
366 const bool is_first_run = first_run::IsChromeFirstRun(); 368 const bool is_first_run = first_run::IsChromeFirstRun();
369 const bool did_restart = StartupBrowserCreator::WasRestarted();
367 #endif 370 #endif
368 371
369 // The pref has an OS-dependent default value. For the first run only, this 372 // 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 373 // default is overridden with SessionStartupPref::DEFAULT so that first run
371 // behavior (sync promo, welcome page) is consistently invoked. 374 // behavior (sync promo, welcome page) is consistently invoked.
372 // This applies only if the pref is still at its default and has not been 375 // This applies only if the pref is still at its default and has not been
373 // set by the user, managed prefs or policy. 376 // set by the user, managed prefs or policy.
374 if (is_first_run && SessionStartupPref::TypeIsDefault(prefs)) 377 if (is_first_run && SessionStartupPref::TypeIsDefault(prefs))
375 pref.type = SessionStartupPref::DEFAULT; 378 pref.type = SessionStartupPref::DEFAULT;
376 379
377 // The switches::kRestoreLastSession command line switch is used to restore 380 // The switches::kRestoreLastSession command line switch is used to restore
378 // sessions after a browser self restart (e.g. after a Chrome upgrade). 381 // 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 382 // 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 383 // switch so do not set the session pref to SessionStartupPref::LAST for
381 // those as there is nothing to restore. 384 // those as there is nothing to restore.
382 if ((command_line.HasSwitch(switches::kRestoreLastSession) || 385 if ((command_line.HasSwitch(switches::kRestoreLastSession) || did_restart) &&
383 StartupBrowserCreator::WasRestarted()) &&
384 !profile->IsNewProfile()) { 386 !profile->IsNewProfile()) {
385 pref.type = SessionStartupPref::LAST; 387 pref.type = SessionStartupPref::LAST;
386 } 388 }
387 if (pref.type == SessionStartupPref::LAST && 389 if (pref.type == SessionStartupPref::LAST &&
388 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) { 390 IncognitoModePrefs::ShouldLaunchIncognito(command_line, prefs)) {
389 // We don't store session information when incognito. If the user has 391 // We don't store session information when incognito. If the user has
390 // chosen to restore last session and launched incognito, fallback to 392 // chosen to restore last session and launched incognito, fallback to
391 // default launch behavior. 393 // default launch behavior.
392 pref.type = SessionStartupPref::DEFAULT; 394 pref.type = SessionStartupPref::DEFAULT;
393 } 395 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 // If we are showing the app list then chrome isn't shown so load the app 741 // If we are showing the app list then chrome isn't shown so load the app
740 // list's profile rather than chrome's. 742 // list's profile rather than chrome's.
741 if (command_line.HasSwitch(switches::kShowAppList)) { 743 if (command_line.HasSwitch(switches::kShowAppList)) {
742 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)-> 744 return AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE)->
743 GetProfilePath(user_data_dir); 745 GetProfilePath(user_data_dir);
744 } 746 }
745 747
746 return g_browser_process->profile_manager()->GetLastUsedProfileDir( 748 return g_browser_process->profile_manager()->GetLastUsedProfileDir(
747 user_data_dir); 749 user_data_dir);
748 } 750 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_browsertest_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698