OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
12 #include "chrome/browser/defaults.h" | |
13 #include "chrome/browser/sessions/base_session_service.h" | 12 #include "chrome/browser/sessions/base_session_service.h" |
14 #include "chrome/browser/sessions/session_id.h" | 13 #include "chrome/browser/sessions/session_id.h" |
15 #include "chrome/common/notification_observer.h" | 14 #include "chrome/common/notification_observer.h" |
16 #include "chrome/common/notification_registrar.h" | 15 #include "chrome/common/notification_registrar.h" |
17 | 16 |
18 class Browser; | 17 class Browser; |
19 class NavigationController; | 18 class NavigationController; |
20 class NavigationEntry; | 19 class NavigationEntry; |
21 class Profile; | 20 class Profile; |
22 class SessionCommand; | 21 class SessionCommand; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // command. | 297 // command. |
299 void ScheduleCommand(SessionCommand* command); | 298 void ScheduleCommand(SessionCommand* command); |
300 | 299 |
301 // Converts all pending tab/window closes to commands and schedules them. | 300 // Converts all pending tab/window closes to commands and schedules them. |
302 void CommitPendingCloses(); | 301 void CommitPendingCloses(); |
303 | 302 |
304 // Returns true if there is only one window open with a single tab that shares | 303 // Returns true if there is only one window open with a single tab that shares |
305 // our profile. | 304 // our profile. |
306 bool IsOnlyOneTabLeft(); | 305 bool IsOnlyOneTabLeft(); |
307 | 306 |
308 // Returns true if there are open trackable browser windows whose ids do | 307 // Returns true if there are no open tabbed browser windows with our profile, |
309 // match |window_id| with our profile. A trackable window is a window from | 308 // or the only tabbed browser open has a session id of window_id. |
310 // which |should_track_changes_for_browser_type| returns true. See | 309 bool HasOpenTabbedBrowsers(const SessionID& window_id); |
311 // |should_track_changes_for_browser_type| for details. | |
312 bool HasOpenTrackableBrowsers(const SessionID& window_id); | |
313 | 310 |
314 // Returns true if changes to tabs in the specified window should be tracked. | 311 // Returns true if changes to tabs in the specified window should be tracked. |
315 bool ShouldTrackChangesToWindow(const SessionID& window_id); | 312 bool ShouldTrackChangesToWindow(const SessionID& window_id); |
316 | 313 |
317 // Returns true if we track changes to the specified browser type. | 314 // Returns true if we track changes to the specified browser type. |
318 static bool should_track_changes_for_browser_type(Browser::Type type) { | 315 static bool should_track_changes_for_browser_type(Browser::Type type) { |
319 return type == Browser::TYPE_NORMAL || | 316 return type == Browser::TYPE_NORMAL; |
320 (type == Browser::TYPE_POPUP && browser_defaults::kRestorePopups); | |
321 } | 317 } |
322 | 318 |
323 NotificationRegistrar registrar_; | 319 NotificationRegistrar registrar_; |
324 | 320 |
325 // Maps from session tab id to the range of navigation entries that has | 321 // Maps from session tab id to the range of navigation entries that has |
326 // been written to disk. | 322 // been written to disk. |
327 // | 323 // |
328 // This is only used if not all the navigation entries have been | 324 // This is only used if not all the navigation entries have been |
329 // written. | 325 // written. |
330 IdToRange tab_to_available_range_; | 326 IdToRange tab_to_available_range_; |
(...skipping 13 matching lines...) Expand all Loading... |
344 // When a window other than the last window (see description of | 340 // When a window other than the last window (see description of |
345 // pending_window_close_ids) is closed, the id is added to this set. | 341 // pending_window_close_ids) is closed, the id is added to this set. |
346 typedef std::set<SessionID::id_type> WindowClosingIDs; | 342 typedef std::set<SessionID::id_type> WindowClosingIDs; |
347 WindowClosingIDs window_closing_ids_; | 343 WindowClosingIDs window_closing_ids_; |
348 | 344 |
349 // Set of windows we're tracking changes to. This is only browsers that | 345 // Set of windows we're tracking changes to. This is only browsers that |
350 // return true from should_track_changes_for_browser_type. | 346 // return true from should_track_changes_for_browser_type. |
351 typedef std::set<SessionID::id_type> WindowsTracking; | 347 typedef std::set<SessionID::id_type> WindowsTracking; |
352 WindowsTracking windows_tracking_; | 348 WindowsTracking windows_tracking_; |
353 | 349 |
354 // Are there any open trackable browsers? | 350 // Are there any open open tabbed browsers? |
355 bool has_open_trackable_browsers_; | 351 bool has_open_tabbed_browsers_; |
356 | 352 |
357 // If true and a new tabbed browser is created and there are no opened tabbed | 353 // If true and a new tabbed browser is created and there are no opened tabbed |
358 // browser (has_open_trackable_browsers_ is false), then the current session | 354 // browser (has_open_tabbed_browsers_ is false), then the current session |
359 // is made the previous session. See description above class for details on | 355 // is made the previous session. See description above class for details on |
360 // current/previou session. | 356 // current/previou session. |
361 bool move_on_new_browser_; | 357 bool move_on_new_browser_; |
362 | 358 |
363 DISALLOW_COPY_AND_ASSIGN(SessionService); | 359 DISALLOW_COPY_AND_ASSIGN(SessionService); |
364 }; | 360 }; |
365 | 361 |
366 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 362 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
OLD | NEW |