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