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

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 8533013: SessionRestore: Store session cookies and restore them if chrome crashes or auto-restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_init.h" 5 #include "chrome/browser/ui/browser_init.h"
6 6
7 #include <algorithm> // For max(). 7 #include <algorithm> // For max().
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 bool SessionCrashedInfoBarDelegate::Accept() { 368 bool SessionCrashedInfoBarDelegate::Accept() {
369 uint32 behavior = 0; 369 uint32 behavior = 0;
370 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); 370 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
371 if (browser && browser->tab_count() == 1 371 if (browser && browser->tab_count() == 1
372 && browser->GetTabContentsAt(0)->GetURL() == 372 && browser->GetTabContentsAt(0)->GetURL() ==
373 GURL(chrome::kChromeUINewTabURL)) { 373 GURL(chrome::kChromeUINewTabURL)) {
374 // There is only one tab and its the new tab page, make session restore 374 // There is only one tab and its the new tab page, make session restore
375 // clobber it. 375 // clobber it.
376 behavior = SessionRestore::CLOBBER_CURRENT_TAB; 376 behavior = SessionRestore::CLOBBER_CURRENT_TAB;
377 } 377 }
378 behavior |= SessionRestore::RESTORE_SESSION_STATE;
378 SessionRestore::RestoreSession( 379 SessionRestore::RestoreSession(
379 profile_, browser, behavior, std::vector<GURL>()); 380 profile_, browser, behavior, std::vector<GURL>());
380 return true; 381 return true;
381 } 382 }
382 383
383 384
384 // Utility functions ---------------------------------------------------------- 385 // Utility functions ----------------------------------------------------------
385 386
386 bool IncognitoIsForced(const CommandLine& command_line, 387 bool IncognitoIsForced(const CommandLine& command_line,
387 const PrefService* prefs) { 388 const PrefService* prefs) {
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 !command_line_.HasSwitch(switches::kRestoreLastSession)) { 945 !command_line_.HasSwitch(switches::kRestoreLastSession)) {
945 // The last session crashed. It's possible automatically loading the 946 // The last session crashed. It's possible automatically loading the
946 // page will trigger another crash, locking the user out of chrome. 947 // page will trigger another crash, locking the user out of chrome.
947 // To avoid this, don't restore on startup but instead show the crashed 948 // To avoid this, don't restore on startup but instead show the crashed
948 // infobar. 949 // infobar.
949 return false; 950 return false;
950 } 951 }
951 952
952 uint32 restore_behavior = SessionRestore::SYNCHRONOUS | 953 uint32 restore_behavior = SessionRestore::SYNCHRONOUS |
953 SessionRestore::ALWAYS_CREATE_TABBED_BROWSER; 954 SessionRestore::ALWAYS_CREATE_TABBED_BROWSER;
955
956 if (!profile_->DidLastSessionExitCleanly() ||
957 CommandLine::ForCurrentProcess()->HasSwitch(
958 switches::kRestoreLastSession)) {
959 // Crash or auto-update. Restore the session state.
960 restore_behavior |= SessionRestore::RESTORE_SESSION_STATE;
961 }
962
954 #if defined(OS_MACOSX) 963 #if defined(OS_MACOSX)
955 // On Mac, when restoring a session with no windows, suppress the creation 964 // On Mac, when restoring a session with no windows, suppress the creation
956 // of a new window in the case where the system is launching Chrome via a 965 // of a new window in the case where the system is launching Chrome via a
957 // login item or Lion's resume feature. 966 // login item or Lion's resume feature.
958 if (base::mac::WasLaunchedAsLoginOrResumeItem()) { 967 if (base::mac::WasLaunchedAsLoginOrResumeItem()) {
959 restore_behavior = restore_behavior & 968 restore_behavior = restore_behavior &
960 ~SessionRestore::ALWAYS_CREATE_TABBED_BROWSER; 969 ~SessionRestore::ALWAYS_CREATE_TABBED_BROWSER;
961 } 970 }
962 #endif 971 #endif
963 972
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 if (!automation->InitializeChannel(channel_id)) 1562 if (!automation->InitializeChannel(channel_id))
1554 return false; 1563 return false;
1555 automation->SetExpectedTabCount(expected_tabs); 1564 automation->SetExpectedTabCount(expected_tabs);
1556 1565
1557 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); 1566 AutomationProviderList* list = g_browser_process->GetAutomationProviderList();
1558 DCHECK(list); 1567 DCHECK(list);
1559 list->AddProvider(automation); 1568 list->AddProvider(automation);
1560 1569
1561 return true; 1570 return true;
1562 } 1571 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698