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

Side by Side Diff: chrome/browser/sessions/session_service.cc

Issue 2345763002: Fix tabs duplication when restoring last closed window. (Closed)
Patch Set: Fix comments. Created 4 years, 3 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 | « no previous file | chrome/browser/sessions/tab_restore_browsertest.cc » ('j') | 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/sessions/session_service.h" 5 #include "chrome/browser/sessions/session_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/prefs/session_startup_pref.h" 27 #include "chrome/browser/prefs/session_startup_pref.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/browser/profiles/profile_attributes_entry.h" 29 #include "chrome/browser/profiles/profile_attributes_entry.h"
30 #include "chrome/browser/profiles/profile_attributes_storage.h" 30 #include "chrome/browser/profiles/profile_attributes_storage.h"
31 #include "chrome/browser/profiles/profile_manager.h" 31 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/browser/sessions/session_common_utils.h" 32 #include "chrome/browser/sessions/session_common_utils.h"
33 #include "chrome/browser/sessions/session_data_deleter.h" 33 #include "chrome/browser/sessions/session_data_deleter.h"
34 #include "chrome/browser/sessions/session_restore.h" 34 #include "chrome/browser/sessions/session_restore.h"
35 #include "chrome/browser/sessions/session_service_utils.h" 35 #include "chrome/browser/sessions/session_service_utils.h"
36 #include "chrome/browser/sessions/session_tab_helper.h" 36 #include "chrome/browser/sessions/session_tab_helper.h"
37 #include "chrome/browser/sessions/tab_restore_service_factory.h"
37 #include "chrome/browser/ui/browser_list.h" 38 #include "chrome/browser/ui/browser_list.h"
38 #include "chrome/browser/ui/browser_tabstrip.h" 39 #include "chrome/browser/ui/browser_tabstrip.h"
39 #include "chrome/browser/ui/browser_window.h" 40 #include "chrome/browser/ui/browser_window.h"
40 #include "chrome/browser/ui/startup/startup_browser_creator.h" 41 #include "chrome/browser/ui/startup/startup_browser_creator.h"
41 #include "chrome/browser/ui/tabs/tab_strip_model.h" 42 #include "chrome/browser/ui/tabs/tab_strip_model.h"
42 #include "components/sessions/content/content_serialized_navigation_builder.h" 43 #include "components/sessions/content/content_serialized_navigation_builder.h"
43 #include "components/sessions/core/session_command.h" 44 #include "components/sessions/core/session_command.h"
44 #include "components/sessions/core/session_constants.h" 45 #include "components/sessions/core/session_constants.h"
45 #include "components/sessions/core/session_types.h" 46 #include "components/sessions/core/session_types.h"
47 #include "components/sessions/core/tab_restore_service.h"
46 #include "content/public/browser/navigation_details.h" 48 #include "content/public/browser/navigation_details.h"
47 #include "content/public/browser/navigation_entry.h" 49 #include "content/public/browser/navigation_entry.h"
48 #include "content/public/browser/notification_details.h" 50 #include "content/public/browser/notification_details.h"
49 #include "content/public/browser/notification_service.h" 51 #include "content/public/browser/notification_service.h"
50 #include "content/public/browser/session_storage_namespace.h" 52 #include "content/public/browser/session_storage_namespace.h"
51 #include "content/public/browser/web_contents.h" 53 #include "content/public/browser/web_contents.h"
52 #include "extensions/common/extension.h" 54 #include "extensions/common/extension.h"
53 55
54 #if defined(OS_MACOSX) 56 #if defined(OS_MACOSX)
55 #include "chrome/browser/app_controller_mac.h" 57 #include "chrome/browser/app_controller_mac.h"
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (ShouldNewWindowStartSession()) { 583 if (ShouldNewWindowStartSession()) {
582 // We're going from no tabbed browsers to a tabbed browser (and not in 584 // We're going from no tabbed browsers to a tabbed browser (and not in
583 // process startup), restore the last session. 585 // process startup), restore the last session.
584 if (move_on_new_browser_) { 586 if (move_on_new_browser_) {
585 // Make the current session the last. 587 // Make the current session the last.
586 MoveCurrentSessionToLastSession(); 588 MoveCurrentSessionToLastSession();
587 move_on_new_browser_ = false; 589 move_on_new_browser_ = false;
588 } 590 }
589 SessionStartupPref pref = StartupBrowserCreator::GetSessionStartupPref( 591 SessionStartupPref pref = StartupBrowserCreator::GetSessionStartupPref(
590 *base::CommandLine::ForCurrentProcess(), profile()); 592 *base::CommandLine::ForCurrentProcess(), profile());
591 if (pref.type == SessionStartupPref::LAST) { 593 sessions::TabRestoreService* tab_restore_service =
594 TabRestoreServiceFactory::GetForProfileIfExisting(profile());
595 if (pref.type == SessionStartupPref::LAST &&
596 (!tab_restore_service || !tab_restore_service->IsRestoring())) {
592 SessionRestore::RestoreSession( 597 SessionRestore::RestoreSession(
593 profile(), browser, 598 profile(), browser,
594 browser ? 0 : SessionRestore::ALWAYS_CREATE_TABBED_BROWSER, 599 browser ? 0 : SessionRestore::ALWAYS_CREATE_TABBED_BROWSER,
595 urls_to_open); 600 urls_to_open);
596 return true; 601 return true;
597 } 602 }
598 } 603 }
599 return false; 604 return false;
600 } 605 }
601 606
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 for (auto* browser : *BrowserList::GetInstance()) { 1101 for (auto* browser : *BrowserList::GetInstance()) {
1097 if (browser->profile() == profile()) 1102 if (browser->profile() == profile())
1098 return; 1103 return;
1099 } 1104 }
1100 DeleteSessionOnlyData(profile()); 1105 DeleteSessionOnlyData(profile());
1101 } 1106 }
1102 1107
1103 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() { 1108 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() {
1104 return base_session_service_.get(); 1109 return base_session_service_.get();
1105 } 1110 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/tab_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698