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

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

Issue 2832503002: Fix double session-restore bug. (Closed)
Patch Set: Fix unittest. Created 3 years, 8 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
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_impl.h" 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 // Return immediately if we start an async restore, since the remainder of 641 // Return immediately if we start an async restore, since the remainder of
642 // that process is self-contained. 642 // that process is self-contained.
643 if (MaybeAsyncRestore(tabs, process_startup, is_post_crash_launch)) 643 if (MaybeAsyncRestore(tabs, process_startup, is_post_crash_launch))
644 return; 644 return;
645 645
646 BrowserOpenBehaviorOptions behavior_options = 0; 646 BrowserOpenBehaviorOptions behavior_options = 0;
647 if (process_startup) 647 if (process_startup)
648 behavior_options |= PROCESS_STARTUP; 648 behavior_options |= PROCESS_STARTUP;
649 if (is_post_crash_launch) 649 if (is_post_crash_launch)
650 behavior_options |= IS_POST_CRASH_LAUNCH; 650 behavior_options |= IS_POST_CRASH_LAUNCH;
651 if (command_line_.HasSwitch(switches::kRestoreLastSession))
652 behavior_options |= HAS_RESTORE_SWITCH;
653 if (command_line_.HasSwitch(switches::kOpenInNewWindow)) 651 if (command_line_.HasSwitch(switches::kOpenInNewWindow))
654 behavior_options |= HAS_NEW_WINDOW_SWITCH; 652 behavior_options |= HAS_NEW_WINDOW_SWITCH;
655 if (!cmd_line_tabs.empty()) 653 if (!cmd_line_tabs.empty())
656 behavior_options |= HAS_CMD_LINE_TABS; 654 behavior_options |= HAS_CMD_LINE_TABS;
657 655
658 BrowserOpenBehavior behavior = DetermineBrowserOpenBehavior( 656 BrowserOpenBehavior behavior = DetermineBrowserOpenBehavior(
659 StartupBrowserCreator::GetSessionStartupPref(command_line_, profile_), 657 StartupBrowserCreator::GetSessionStartupPref(command_line_, profile_),
660 behavior_options); 658 behavior_options);
661 659
662 SessionRestore::BehaviorBitmask restore_options = 0; 660 SessionRestore::BehaviorBitmask restore_options = 0;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // function. If Chrome was launched with passed URLs, assume these should 874 // function. If Chrome was launched with passed URLs, assume these should
877 // be appended to an existing window if possible, unless overridden by a 875 // be appended to an existing window if possible, unless overridden by a
878 // switch. 876 // switch.
879 return ((options & HAS_CMD_LINE_TABS) && !(options & HAS_NEW_WINDOW_SWITCH)) 877 return ((options & HAS_CMD_LINE_TABS) && !(options & HAS_NEW_WINDOW_SWITCH))
880 ? BrowserOpenBehavior::USE_EXISTING 878 ? BrowserOpenBehavior::USE_EXISTING
881 : BrowserOpenBehavior::NEW; 879 : BrowserOpenBehavior::NEW;
882 } 880 }
883 881
884 if (pref.type == SessionStartupPref::LAST) { 882 if (pref.type == SessionStartupPref::LAST) {
885 // Don't perform a session restore on a post-crash launch, as this could 883 // Don't perform a session restore on a post-crash launch, as this could
886 // cause a crash loop. These checks can be overridden by a switch. 884 // cause a crash loop.
887 if (!(options & IS_POST_CRASH_LAUNCH) || (options & HAS_RESTORE_SWITCH)) 885 if (!(options & IS_POST_CRASH_LAUNCH))
888 return BrowserOpenBehavior::SYNCHRONOUS_RESTORE; 886 return BrowserOpenBehavior::SYNCHRONOUS_RESTORE;
889 } 887 }
890 888
891 return BrowserOpenBehavior::NEW; 889 return BrowserOpenBehavior::NEW;
892 } 890 }
893 891
894 // static 892 // static
895 SessionRestore::BehaviorBitmask 893 SessionRestore::BehaviorBitmask
896 StartupBrowserCreatorImpl::DetermineSynchronousRestoreOptions( 894 StartupBrowserCreatorImpl::DetermineSynchronousRestoreOptions(
897 bool has_create_browser_default, 895 bool has_create_browser_default,
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 #if defined(OS_WIN) 1255 #if defined(OS_WIN)
1258 TriggeredProfileResetter* triggered_profile_resetter = 1256 TriggeredProfileResetter* triggered_profile_resetter =
1259 TriggeredProfileResetterFactory::GetForBrowserContext(profile_); 1257 TriggeredProfileResetterFactory::GetForBrowserContext(profile_);
1260 // TriggeredProfileResetter instance will be nullptr for incognito profiles. 1258 // TriggeredProfileResetter instance will be nullptr for incognito profiles.
1261 if (triggered_profile_resetter) { 1259 if (triggered_profile_resetter) {
1262 has_reset_trigger = triggered_profile_resetter->HasResetTrigger(); 1260 has_reset_trigger = triggered_profile_resetter->HasResetTrigger();
1263 } 1261 }
1264 #endif // defined(OS_WIN) 1262 #endif // defined(OS_WIN)
1265 return has_reset_trigger; 1263 return has_reset_trigger;
1266 } 1264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698