blob: 365d43343d9b08e8e8ea45ebf89629d2e2035b0a [file] [log] [blame]
[email protected]a636d8e52012-02-28 15:40:411// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]169627b2008-12-06 19:30:195#ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_
6#define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_
initial.commit09911bf2008-07-26 23:55:297
8#include <map>
[email protected]23da84e152010-07-14 01:29:059#include <string>
Shivani Sharmab9c46de82019-02-08 16:54:5010#include <utility>
initial.commit09911bf2008-07-26 23:55:2911
[email protected]f9ffb892011-11-28 18:57:3112#include "base/callback.h"
thestiga0e18cd2015-09-25 04:58:3613#include "base/gtest_prod_util.h"
avib896c712015-12-26 02:10:4314#include "base/macros.h"
sky1a14f492014-08-26 21:44:2615#include "base/memory/weak_ptr.h"
Collin Baker81999fd2019-06-05 23:12:2716#include "base/optional.h"
Collin Bakerd61e2fe2019-08-07 19:19:5317#include "base/strings/string16.h"
[email protected]e95b717f2014-02-06 13:47:1318#include "base/task/cancelable_task_tracker.h"
[email protected]cc86ccfe2013-06-28 00:10:5019#include "base/time/time.h"
Collin Baker81999fd2019-06-05 23:12:2720#include "base/token.h"
[email protected]982921f12009-10-27 21:43:5321#include "chrome/browser/defaults.h"
blundell6d34c342015-09-11 09:09:1022#include "chrome/browser/sessions/session_common_utils.h"
skuhnec3aa8cf2014-10-30 06:02:4523#include "chrome/browser/sessions/session_service_utils.h"
[email protected]2ad4a902010-11-17 06:05:1324#include "chrome/browser/ui/browser.h"
[email protected]0665ebe2013-02-13 09:53:1925#include "chrome/browser/ui/browser_finder.h"
[email protected]bf219e9eb2012-10-10 15:20:3826#include "chrome/browser/ui/browser_list_observer.h"
[email protected]540380fc2014-03-14 10:10:3427#include "components/keyed_service/core/keyed_service.h"
Scott Violet13d44fd2020-01-14 20:38:3328#include "components/sessions/content/session_tab_helper_delegate.h"
Scott Violetcae997b52020-01-17 16:47:4429#include "components/sessions/core/command_storage_manager_delegate.h"
blundell47c6d8a2015-09-24 11:06:4030#include "components/sessions/core/session_service_commands.h"
blundell56789fe2015-09-10 05:11:1631#include "components/sessions/core/tab_restore_service_client.h"
Connie Wan866179b2019-12-18 21:39:3332#include "components/tab_groups/tab_group_id.h"
33#include "components/tab_groups/tab_group_visual_data.h"
Collin Bakerd61e2fe2019-08-07 19:19:5334#include "third_party/skia/include/core/SkColor.h"
[email protected]400eaf82011-08-22 15:47:3935#include "ui/base/ui_base_types.h"
initial.commit09911bf2008-07-26 23:55:2936
initial.commit09911bf2008-07-26 23:55:2937class Profile;
[email protected]ad23a092011-12-28 07:02:0438
39namespace content {
[email protected]40600152012-09-26 10:04:3140class WebContents;
skuhneb7409dcf2014-11-14 04:06:5541} // namespace content
42
43namespace sessions {
44class SessionCommand;
45struct SessionTab;
46struct SessionWindow;
Scott Violet8e3a335d2020-01-17 20:37:3847class SnapshottingCommandStorageManager;
skuhneb7409dcf2014-11-14 04:06:5548} // namespace sessions
initial.commit09911bf2008-07-26 23:55:2949
50// SessionService ------------------------------------------------------------
51
52// SessionService is responsible for maintaining the state of open windows
[email protected]6ea265a2008-10-30 02:58:3653// and tabs so that they can be restored at a later date. The state of the
54// currently open browsers is referred to as the current session.
initial.commit09911bf2008-07-26 23:55:2955//
[email protected]668cd422011-04-06 21:00:0156// SessionService supports restoring from the last session. The last session
57// typically corresponds to the last run of the browser, but not always. For
58// example, if the user has a tabbed browser and app window running, closes the
59// tabbed browser, then creates a new tabbed browser the current session is made
60// the last session and the current session reset. This is done to provide the
61// illusion that app windows run in separate processes. Similar behavior occurs
62// with incognito windows.
initial.commit09911bf2008-07-26 23:55:2963//
skuhnec3aa8cf2014-10-30 06:02:4564// SessionService itself uses functions from session_service_commands to store
65// commands which can rebuild the open state of the browser (as |SessionWindow|,
66// |SessionTab| and |SerializedNavigationEntry|). The commands are periodically
Scott Violetebfa63c2020-01-17 21:17:2867// flushed to |CommandStorageBackend| and written to a file. Every so often
skuhnec3aa8cf2014-10-30 06:02:4568// |SessionService| rebuilds the contents of the file from the open state of the
[email protected]40a7e412013-04-29 18:13:0169// browser.
Scott Violetcae997b52020-01-17 16:47:4470class SessionService : public sessions::CommandStorageManagerDelegate,
Scott Violet13d44fd2020-01-14 20:38:3371 public sessions::SessionTabHelperDelegate,
[email protected]540380fc2014-03-14 10:10:3472 public KeyedService,
cm.sanchia0d6add2017-12-13 04:59:3373 public BrowserListObserver {
[email protected]86ef6a392012-05-11 22:03:1174 friend class SessionServiceTestHelper;
initial.commit09911bf2008-07-26 23:55:2975 public:
initial.commit09911bf2008-07-26 23:55:2976 // Creates a SessionService for the specified profile.
77 explicit SessionService(Profile* profile);
78 // For testing.
[email protected]650b2d52013-02-10 03:41:4579 explicit SessionService(const base::FilePath& save_path);
initial.commit09911bf2008-07-26 23:55:2980
Daniel Chenga542fca2014-10-21 09:51:2981 ~SessionService() override;
[email protected]f0a58a382011-04-26 16:09:2982
skuhned58ab122014-10-22 20:23:0283 // This may be NULL during testing.
84 Profile* profile() const { return profile_; }
85
[email protected]8ddbb642011-09-01 02:52:2086 // Returns true if a new window opening should really be treated like the
87 // start of a session (with potential session restore, startup URLs, etc.).
88 // In particular, this is true if there are no tabbed browsers running
89 // currently (eg. because only background or other app pages are running).
90 bool ShouldNewWindowStartSession();
91
[email protected]c9b19942010-03-26 15:58:0892 // Invoke at a point when you think session restore might occur. For example,
93 // during startup and window creation this is invoked to see if a session
94 // needs to be restored. If a session needs to be restored it is done so
95 // asynchronously and true is returned. If false is returned the session was
Findit046795722018-10-03 11:44:4896 // not restored and the caller needs to create a new window.
97 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open);
[email protected]c9b19942010-03-26 15:58:0898
initial.commit09911bf2008-07-26 23:55:2999 // Resets the contents of the file from the current state of all open
100 // browsers whose profile matches our profile.
101 void ResetFromCurrentBrowsers();
102
103 // Moves the current session to the last session. This is useful when a
104 // checkpoint occurs, such as when the user launches the app and no tabbed
105 // browsers are running.
106 void MoveCurrentSessionToLastSession();
107
skuhned1e250b2014-11-05 15:26:50108 // Deletes the last session.
109 void DeleteLastSession();
110
initial.commit09911bf2008-07-26 23:55:29111 // Associates a tab with a window.
112 void SetTabWindow(const SessionID& window_id,
113 const SessionID& tab_id);
114
115 // Sets the bounds of a window.
116 void SetWindowBounds(const SessionID& window_id,
117 const gfx::Rect& bounds,
[email protected]400eaf82011-08-22 15:47:39118 ui::WindowShowState show_state);
initial.commit09911bf2008-07-26 23:55:29119
thomasanderson06405c52016-05-03 22:52:22120 // Sets the workspace the window resides in.
121 void SetWindowWorkspace(const SessionID& window_id,
122 const std::string& workspace);
123
initial.commit09911bf2008-07-26 23:55:29124 // Sets the visual index of the tab in its parent window.
125 void SetTabIndexInWindow(const SessionID& window_id,
126 const SessionID& tab_id,
127 int new_index);
128
Collin Bakerd61e2fe2019-08-07 19:19:53129 // Sets a tab's group ID, if any. Note that a group can't be split between
130 // multiple windows.
Collin Baker81999fd2019-06-05 23:12:27131 void SetTabGroup(const SessionID& window_id,
132 const SessionID& tab_id,
Connie Wan866179b2019-12-18 21:39:33133 base::Optional<tab_groups::TabGroupId> group);
Collin Baker81999fd2019-06-05 23:12:27134
Collin Bakerd61e2fe2019-08-07 19:19:53135 // Updates the metadata associated with a tab group. |window_id| should be the
136 // window where the group currently resides. Note that a group can't be split
137 // between multiple windows.
138 void SetTabGroupMetadata(const SessionID& window_id,
Connie Wan866179b2019-12-18 21:39:33139 const tab_groups::TabGroupId& group_id,
140 const tab_groups::TabGroupVisualData* visual_data);
Collin Bakerd61e2fe2019-08-07 19:19:53141
[email protected]5c0e6482009-07-14 20:20:09142 // Sets the pinned state of the tab.
143 void SetPinnedState(const SessionID& window_id,
144 const SessionID& tab_id,
145 bool is_pinned);
146
initial.commit09911bf2008-07-26 23:55:29147 // Note: this is invoked from the NavigationController's destructor, which is
148 // after the actual tab has been removed.
Cliff Smolinskyb48062612020-04-14 20:07:34149 void TabClosed(const SessionID& window_id, const SessionID& tab_id);
initial.commit09911bf2008-07-26 23:55:29150
[email protected]7d52ea4c62013-11-13 03:52:14151 // Notification a window has opened.
152 void WindowOpened(Browser* browser);
153
initial.commit09911bf2008-07-26 23:55:29154 // Notification the window is about to close.
155 void WindowClosing(const SessionID& window_id);
156
157 // Notification a window has finished closing.
158 void WindowClosed(const SessionID& window_id);
159
[email protected]40600152012-09-26 10:04:31160 // Called when a tab is inserted.
161 void TabInserted(content::WebContents* contents);
162
163 // Called when a tab is closing.
164 void TabClosing(content::WebContents* contents);
165
initial.commit09911bf2008-07-26 23:55:29166 // Sets the type of window. In order for the contents of a window to be
167 // tracked SetWindowType must be invoked with a type we track
skuhnec3aa8cf2014-10-30 06:02:45168 // (ShouldRestoreOfWindowType returns true).
Joel Hockey7132db62019-08-20 23:03:31169 void SetWindowType(const SessionID& window_id, Browser::Type type);
[email protected]a636d8e52012-02-28 15:40:41170
[email protected]18ab5152013-03-28 23:14:05171 // Sets the application name of the specified window.
172 void SetWindowAppName(const SessionID& window_id,
173 const std::string& app_name);
initial.commit09911bf2008-07-26 23:55:29174
initial.commit09911bf2008-07-26 23:55:29175 // Notification that a tab has restored its entries or a closed tab is being
176 // reused.
[email protected]b624ddc2012-11-15 18:04:13177 void TabRestored(content::WebContents* tab, bool pinned);
initial.commit09911bf2008-07-26 23:55:29178
initial.commit09911bf2008-07-26 23:55:29179 // Sets the index of the selected tab in the specified window.
180 void SetSelectedTabInWindow(const SessionID& window_id, int index);
181
skuhnec3aa8cf2014-10-30 06:02:45182 // Sets the application extension id of the specified tab.
183 void SetTabExtensionAppID(const SessionID& window_id,
184 const SessionID& tab_id,
185 const std::string& extension_app_id);
186
georgesak5582cbe2015-05-22 22:08:07187 // Sets the last active time of the tab.
188 void SetLastActiveTime(const SessionID& window_id,
189 const SessionID& tab_id,
190 base::TimeTicks last_active_time);
191
initial.commit09911bf2008-07-26 23:55:29192 // Fetches the contents of the last session, notifying the callback when
193 // done. If the callback is supplied an empty vector of SessionWindows
194 // it means the session could not be restored.
[email protected]e95b717f2014-02-06 13:47:13195 base::CancelableTaskTracker::TaskId GetLastSession(
Yuzu Saijo543f8e042020-01-08 07:00:14196 sessions::GetLastSessionCallback callback,
[email protected]e95b717f2014-02-06 13:47:13197 base::CancelableTaskTracker* tracker);
[email protected]3acb70ef2010-03-01 18:44:38198
Scott Violetcae997b52020-01-17 16:47:44199 // CommandStorageManagerDelegate:
blundell6d34c342015-09-11 09:09:10200 bool ShouldUseDelayedSave() override;
Christian Dullweberb13ffda2018-02-23 11:42:14201 void OnWillSaveCommands() override;
[email protected]70eb8ed92010-06-10 18:13:12202
Scott Violet13d44fd2020-01-14 20:38:33203 // sessions::SessionTabHelperDelegate:
204 void SetTabUserAgentOverride(const SessionID& window_id,
205 const SessionID& tab_id,
Maks Orlovich303126962020-04-06 21:34:25206 const sessions::SerializedUserAgentOverride&
207 user_agent_override) override;
Scott Violet13d44fd2020-01-14 20:38:33208 void SetSelectedNavigationIndex(const SessionID& window_id,
209 const SessionID& tab_id,
210 int index) override;
211 void UpdateTabNavigation(
212 const SessionID& window_id,
213 const SessionID& tab_id,
214 const sessions::SerializedNavigationEntry& navigation) override;
215 void TabNavigationPathPruned(const SessionID& window_id,
216 const SessionID& tab_id,
217 int index,
218 int count) override;
219 void TabNavigationPathEntriesDeleted(const SessionID& window_id,
220 const SessionID& tab_id) override;
221
initial.commit09911bf2008-07-26 23:55:29222 private:
[email protected]bf219e9eb2012-10-10 15:20:38223 // Allow tests to access our innards for testing purposes.
skuhned1e250b2014-11-05 15:26:50224 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, SavedSessionNotification);
[email protected]bf219e9eb2012-10-10 15:20:38225 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation1);
226 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RestoreActivation2);
aseren748ab62e2015-01-12 13:33:02227 FRIEND_TEST_ALL_PREFIXES(SessionServiceTest, RemoveUnusedRestoreWindowsTest);
[email protected]51e5bdc2012-12-06 06:12:56228 FRIEND_TEST_ALL_PREFIXES(NoStartupWindowTest, DontInitSessionServiceForApps);
[email protected]bf219e9eb2012-10-10 15:20:38229
Mikel Astiz69a75882018-03-29 19:00:09230 typedef std::map<SessionID, std::pair<int, int>> IdToRange;
[email protected]97d2c1e2009-11-05 03:55:05231
[email protected]169627b2008-12-06 19:30:19232 void Init();
initial.commit09911bf2008-07-26 23:55:29233
Joel Hockey7132db62019-08-20 23:03:31234 // Returns true if a window of given |window_type| should get
skuhnec3aa8cf2014-10-30 06:02:45235 // restored upon session restore.
Joel Hockey7132db62019-08-20 23:03:31236 bool ShouldRestoreWindowOfType(
237 sessions::SessionWindow::WindowType type) const;
skuhnec3aa8cf2014-10-30 06:02:45238
239 // Removes unrestorable windows from the previous windows list.
skuhneb7409dcf2014-11-14 04:06:55240 void RemoveUnusedRestoreWindows(
avi498cabca2016-09-21 19:03:50241 std::vector<std::unique_ptr<sessions::SessionWindow>>* window_list);
skuhnec3aa8cf2014-10-30 06:02:45242
[email protected]c9b19942010-03-26 15:58:08243 // Implementation of RestoreIfNecessary. If |browser| is non-null and we need
244 // to restore, the tabs are added to it, otherwise a new browser is created.
Findit046795722018-10-03 11:44:48245 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open,
[email protected]c9b19942010-03-26 15:58:08246 Browser* browser);
247
cm.sanchia0d6add2017-12-13 04:59:33248 // BrowserListObserver
Daniel Chenga542fca2014-10-21 09:51:29249 void OnBrowserAdded(Browser* browser) override {}
250 void OnBrowserRemoved(Browser* browser) override {}
251 void OnBrowserSetLastActive(Browser* browser) override;
[email protected]bf219e9eb2012-10-10 15:20:38252
[email protected]4c7f9c52012-12-11 21:51:30253 // Converts |commands| to SessionWindows and notifies the callback.
avi51f1cd92017-01-03 18:23:38254 void OnGotSessionCommands(
Yuzu Saijo543f8e042020-01-08 07:00:14255 sessions::GetLastSessionCallback callback,
avi51f1cd92017-01-03 18:23:38256 std::vector<std::unique_ptr<sessions::SessionCommand>> commands);
initial.commit09911bf2008-07-26 23:55:29257
initial.commit09911bf2008-07-26 23:55:29258 // Adds commands to commands that will recreate the state of the specified
[email protected]81898992011-06-14 22:15:00259 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each
260 // direction from the current navigation index).
initial.commit09911bf2008-07-26 23:55:29261 // A pair is added to tab_to_available_range indicating the range of
262 // indices that were written.
Collin Baker81999fd2019-06-05 23:12:27263 void BuildCommandsForTab(const SessionID& window_id,
264 content::WebContents* tab,
265 int index_in_window,
Connie Wan866179b2019-12-18 21:39:33266 base::Optional<tab_groups::TabGroupId> group,
Collin Baker81999fd2019-06-05 23:12:27267 bool is_pinned,
268 IdToRange* tab_to_available_range);
initial.commit09911bf2008-07-26 23:55:29269
270 // Adds commands to create the specified browser, and invokes
271 // BuildCommandsForTab for each of the tabs in the browser. This ignores
272 // any tabs not in the profile we were created with.
Mikel Astiz69a75882018-03-29 19:00:09273 void BuildCommandsForBrowser(Browser* browser,
274 IdToRange* tab_to_available_range,
275 std::set<SessionID>* windows_to_track);
initial.commit09911bf2008-07-26 23:55:29276
277 // Iterates over all the known browsers invoking BuildCommandsForBrowser.
skuhnec3aa8cf2014-10-30 06:02:45278 // This only adds browsers that should be tracked (|ShouldRestoreWindowOfType|
279 // returns true). All browsers that are tracked are added to windows_to_track
280 // (as long as it is non-null).
Mikel Astiz69a75882018-03-29 19:00:09281 void BuildCommandsFromBrowsers(IdToRange* tab_to_available_range,
282 std::set<SessionID>* windows_to_track);
initial.commit09911bf2008-07-26 23:55:29283
skuhnec3aa8cf2014-10-30 06:02:45284 // Schedules a reset of the existing commands. A reset means the contents
285 // of the file are recreated from the state of the browser.
286 void ScheduleResetCommands();
initial.commit09911bf2008-07-26 23:55:29287
skuhne57b5b03f2014-10-31 03:59:55288 // Schedules the specified command.
dcheng4af48582016-04-19 00:29:35289 void ScheduleCommand(std::unique_ptr<sessions::SessionCommand> command);
initial.commit09911bf2008-07-26 23:55:29290
291 // Converts all pending tab/window closes to commands and schedules them.
292 void CommitPendingCloses();
293
initial.commit09911bf2008-07-26 23:55:29294 // Returns true if there is only one window open with a single tab that shares
295 // our profile.
[email protected]bf219e9eb2012-10-10 15:20:38296 bool IsOnlyOneTabLeft() const;
initial.commit09911bf2008-07-26 23:55:29297
[email protected]982921f12009-10-27 21:43:53298 // Returns true if there are open trackable browser windows whose ids do
299 // match |window_id| with our profile. A trackable window is a window from
skuhnec3aa8cf2014-10-30 06:02:45300 // which |ShouldRestoreWindowOfType| returns true. See
301 // |ShouldRestoreWindowOfType| for details.
[email protected]bf219e9eb2012-10-10 15:20:38302 bool HasOpenTrackableBrowsers(const SessionID& window_id) const;
initial.commit09911bf2008-07-26 23:55:29303
304 // Returns true if changes to tabs in the specified window should be tracked.
[email protected]bf219e9eb2012-10-10 15:20:38305 bool ShouldTrackChangesToWindow(const SessionID& window_id) const;
306
307 // Returns true if we track changes to the specified browser.
308 bool ShouldTrackBrowser(Browser* browser) const;
initial.commit09911bf2008-07-26 23:55:29309
Christian Dullweberb13ffda2018-02-23 11:42:14310 // Will rebuild session commands if rebuild_on_next_save_ is true.
311 void RebuildCommandsIfRequired();
312
[email protected]23da84e152010-07-14 01:29:05313 // Call when certain session relevant notifications
314 // (tab_closed, nav_list_pruned) occur. In addition, this is
315 // currently called when Save() is called to compare how often the
316 // session data is currently saved verses when we may want to save it.
317 // It records the data in UMA stats.
[email protected]432115822011-07-10 15:52:27318 void RecordSessionUpdateHistogramData(int type,
[email protected]23da84e152010-07-14 01:29:05319 base::TimeTicks* last_updated_time);
320
[email protected]3efee4172014-01-23 13:53:36321 // Deletes session data if no windows are open for the current profile.
322 void MaybeDeleteSessionOnlyData();
323
skuhned1e250b2014-11-05 15:26:50324 // Unit test accessors.
Scott Violetcae997b52020-01-17 16:47:44325 sessions::CommandStorageManager* GetCommandStorageManagerForTest();
skuhned1e250b2014-11-05 15:26:50326
Shivani Sharmab9c46de82019-02-08 16:54:50327 void SetAvailableRangeForTest(const SessionID& tab_id,
Shivani Sharma07074592019-02-12 16:36:28328 const std::pair<int, int>& range);
Shivani Sharmab9c46de82019-02-08 16:54:50329 bool GetAvailableRangeForTest(const SessionID& tab_id,
Shivani Sharma07074592019-02-12 16:36:28330 std::pair<int, int>* range);
Shivani Sharmab9c46de82019-02-08 16:54:50331
skuhned58ab122014-10-22 20:23:02332 // The profile. This may be null during testing.
333 Profile* profile_;
334
blundell6d34c342015-09-11 09:09:10335 // Whether to use delayed save. Set to false when constructed with a FilePath
336 // (which should only be used for testing).
337 bool should_use_delayed_save_;
338
Scott Violet8e3a335d2020-01-17 20:37:38339 std::unique_ptr<sessions::SnapshottingCommandStorageManager>
340 command_storage_manager_;
skuhned1e250b2014-11-05 15:26:50341
initial.commit09911bf2008-07-26 23:55:29342 // Maps from session tab id to the range of navigation entries that has
343 // been written to disk.
344 //
345 // This is only used if not all the navigation entries have been
346 // written.
347 IdToRange tab_to_available_range_;
348
[email protected]6ea265a2008-10-30 02:58:36349 // When the user closes the last window, where the last window is the
initial.commit09911bf2008-07-26 23:55:29350 // last tabbed browser and no more tabbed browsers are open with the same
351 // profile, the window ID is added here. These IDs are only committed (which
352 // marks them as closed) if the user creates a new tabbed browser.
Mikel Astiz69a75882018-03-29 19:00:09353 typedef std::set<SessionID> PendingWindowCloseIDs;
initial.commit09911bf2008-07-26 23:55:29354 PendingWindowCloseIDs pending_window_close_ids_;
355
356 // Set of tabs that have been closed by way of the last window or last tab
357 // closing, but not yet committed.
Mikel Astiz69a75882018-03-29 19:00:09358 typedef std::set<SessionID> PendingTabCloseIDs;
initial.commit09911bf2008-07-26 23:55:29359 PendingTabCloseIDs pending_tab_close_ids_;
360
361 // When a window other than the last window (see description of
362 // pending_window_close_ids) is closed, the id is added to this set.
Mikel Astiz69a75882018-03-29 19:00:09363 typedef std::set<SessionID> WindowClosingIDs;
initial.commit09911bf2008-07-26 23:55:29364 WindowClosingIDs window_closing_ids_;
365
366 // Set of windows we're tracking changes to. This is only browsers that
skuhnec3aa8cf2014-10-30 06:02:45367 // return true from |ShouldRestoreWindowOfType|.
Mikel Astiz69a75882018-03-29 19:00:09368 typedef std::set<SessionID> WindowsTracking;
initial.commit09911bf2008-07-26 23:55:29369 WindowsTracking windows_tracking_;
370
[email protected]982921f12009-10-27 21:43:53371 // Are there any open trackable browsers?
372 bool has_open_trackable_browsers_;
initial.commit09911bf2008-07-26 23:55:29373
Cliff Smolinskyb48062612020-04-14 20:07:34374 // Used to override HasOpenTrackableBrowsers()
375 bool has_open_trackable_browser_for_test_ = true;
376
377 // Use to override IsOnlyOneTableft()
378 bool is_only_one_tab_left_for_test_ = false;
379
[email protected]6ea265a2008-10-30 02:58:36380 // If true and a new tabbed browser is created and there are no opened tabbed
[email protected]982921f12009-10-27 21:43:53381 // browser (has_open_trackable_browsers_ is false), then the current session
[email protected]668cd422011-04-06 21:00:01382 // is made the last session. See description above class for details on
383 // current/last session.
[email protected]6ea265a2008-10-30 02:58:36384 bool move_on_new_browser_;
[email protected]169627b2008-12-06 19:30:19385
[email protected]c4340bc02012-04-25 02:49:38386 // For browser_tests, since we want to simulate the browser shutting down
387 // without quitting.
388 bool force_browser_not_alive_with_no_windows_;
389
Christian Dullweberb13ffda2018-02-23 11:42:14390 // Force session commands to be rebuild before next save event.
391 bool rebuild_on_next_save_;
392
erikchenf64c33d62018-05-14 23:39:33393 // Don't send duplicate SetSelectedTabInWindow commands when the selected
394 // tab's index hasn't changed.
395 std::map<SessionID, int> last_selected_tab_in_window_;
396
Jeremy Roman495db682019-07-12 16:03:24397 base::WeakPtrFactory<SessionService> weak_factory_{this};
sky1a14f492014-08-26 21:44:26398
[email protected]169627b2008-12-06 19:30:19399 DISALLOW_COPY_AND_ASSIGN(SessionService);
initial.commit09911bf2008-07-26 23:55:29400};
401
[email protected]169627b2008-12-06 19:30:19402#endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_