| 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/browser_list.h" |
| 12 #include "chrome/browser/defaults.h" | 13 #include "chrome/browser/defaults.h" |
| 13 #include "chrome/browser/sessions/base_session_service.h" | 14 #include "chrome/browser/sessions/base_session_service.h" |
| 14 #include "chrome/browser/sessions/session_id.h" | 15 #include "chrome/browser/sessions/session_id.h" |
| 15 #include "chrome/common/notification_observer.h" | 16 #include "chrome/common/notification_observer.h" |
| 16 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
| 17 | 18 |
| 18 class Browser; | 19 class Browser; |
| 19 class NavigationController; | 20 class NavigationController; |
| 20 class NavigationEntry; | 21 class NavigationEntry; |
| 21 class Profile; | 22 class Profile; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 324 |
| 324 // Returns true if changes to tabs in the specified window should be tracked. | 325 // Returns true if changes to tabs in the specified window should be tracked. |
| 325 bool ShouldTrackChangesToWindow(const SessionID& window_id); | 326 bool ShouldTrackChangesToWindow(const SessionID& window_id); |
| 326 | 327 |
| 327 // Returns true if we track changes to the specified browser type. | 328 // Returns true if we track changes to the specified browser type. |
| 328 static bool should_track_changes_for_browser_type(Browser::Type type) { | 329 static bool should_track_changes_for_browser_type(Browser::Type type) { |
| 329 return type == Browser::TYPE_NORMAL || | 330 return type == Browser::TYPE_NORMAL || |
| 330 (type == Browser::TYPE_POPUP && browser_defaults::kRestorePopups); | 331 (type == Browser::TYPE_POPUP && browser_defaults::kRestorePopups); |
| 331 } | 332 } |
| 332 | 333 |
| 334 // Returns true if we should record a window close as pending. |
| 335 // |has_open_trackable_browsers_| must be up-to-date before calling this. |
| 336 bool should_record_close_as_pending() const { |
| 337 // When this is called, the browser window being closed is still open, hence |
| 338 // still in the browser list. If there is a browser window other than the |
| 339 // one being closed but no trackable windows, then the others must be App |
| 340 // windows or similar. In this case, we record the close as pending. |
| 341 return !has_open_trackable_browsers_ && |
| 342 (!browser_defaults::kBrowserAliveWithNoWindows || |
| 343 BrowserList::size() > 1); |
| 344 } |
| 345 |
| 333 // Convert back/forward between the Browser and SessionService DB window | 346 // Convert back/forward between the Browser and SessionService DB window |
| 334 // types. | 347 // types. |
| 335 static WindowType WindowTypeForBrowserType(Browser::Type type); | 348 static WindowType WindowTypeForBrowserType(Browser::Type type); |
| 336 static Browser::Type BrowserTypeForWindowType(WindowType type); | 349 static Browser::Type BrowserTypeForWindowType(WindowType type); |
| 337 | 350 |
| 338 NotificationRegistrar registrar_; | 351 NotificationRegistrar registrar_; |
| 339 | 352 |
| 340 // Maps from session tab id to the range of navigation entries that has | 353 // Maps from session tab id to the range of navigation entries that has |
| 341 // been written to disk. | 354 // been written to disk. |
| 342 // | 355 // |
| (...skipping 29 matching lines...) Expand all Loading... |
| 372 // If true and a new tabbed browser is created and there are no opened tabbed | 385 // If true and a new tabbed browser is created and there are no opened tabbed |
| 373 // browser (has_open_trackable_browsers_ is false), then the current session | 386 // browser (has_open_trackable_browsers_ is false), then the current session |
| 374 // is made the previous session. See description above class for details on | 387 // is made the previous session. See description above class for details on |
| 375 // current/previou session. | 388 // current/previou session. |
| 376 bool move_on_new_browser_; | 389 bool move_on_new_browser_; |
| 377 | 390 |
| 378 DISALLOW_COPY_AND_ASSIGN(SessionService); | 391 DISALLOW_COPY_AND_ASSIGN(SessionService); |
| 379 }; | 392 }; |
| 380 | 393 |
| 381 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 394 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| OLD | NEW |