| OLD | NEW |
| 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 #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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "chrome/browser/defaults.h" | 15 #include "chrome/browser/defaults.h" |
| 16 #include "chrome/browser/sessions/base_session_service.h" | 16 #include "chrome/browser/sessions/base_session_service.h" |
| 17 #include "chrome/browser/sessions/session_id.h" | 17 #include "chrome/browser/sessions/session_id.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
| 20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 22 #include "ui/base/ui_base_types.h" | 22 #include "ui/base/ui_base_types.h" |
| 23 | 23 |
| 24 class Profile; | 24 class Profile; |
| 25 class SessionCommand; | 25 class SessionCommand; |
| 26 class TabContents; | 26 class TabContents; |
| 27 typedef TabContents TabContentsWrapper; | |
| 28 struct SessionTab; | 27 struct SessionTab; |
| 29 struct SessionWindow; | 28 struct SessionWindow; |
| 30 | 29 |
| 31 namespace content { | 30 namespace content { |
| 32 class NavigationEntry; | 31 class NavigationEntry; |
| 33 } | 32 } |
| 34 | 33 |
| 35 // SessionService ------------------------------------------------------------ | 34 // SessionService ------------------------------------------------------------ |
| 36 | 35 |
| 37 // SessionService is responsible for maintaining the state of open windows | 36 // SessionService is responsible for maintaining the state of open windows |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 int count); | 149 int count); |
| 151 | 150 |
| 152 // Updates the navigation entry for the specified tab. | 151 // Updates the navigation entry for the specified tab. |
| 153 void UpdateTabNavigation(const SessionID& window_id, | 152 void UpdateTabNavigation(const SessionID& window_id, |
| 154 const SessionID& tab_id, | 153 const SessionID& tab_id, |
| 155 int index, | 154 int index, |
| 156 const content::NavigationEntry& entry); | 155 const content::NavigationEntry& entry); |
| 157 | 156 |
| 158 // Notification that a tab has restored its entries or a closed tab is being | 157 // Notification that a tab has restored its entries or a closed tab is being |
| 159 // reused. | 158 // reused. |
| 160 void TabRestored(TabContentsWrapper* tab, bool pinned); | 159 void TabRestored(TabContents* tab, bool pinned); |
| 161 | 160 |
| 162 // Sets the index of the selected entry in the navigation controller for the | 161 // Sets the index of the selected entry in the navigation controller for the |
| 163 // specified tab. | 162 // specified tab. |
| 164 void SetSelectedNavigationIndex(const SessionID& window_id, | 163 void SetSelectedNavigationIndex(const SessionID& window_id, |
| 165 const SessionID& tab_id, | 164 const SessionID& tab_id, |
| 166 int index); | 165 int index); |
| 167 | 166 |
| 168 // Sets the index of the selected tab in the specified window. | 167 // Sets the index of the selected tab in the specified window. |
| 169 void SetSelectedTabInWindow(const SessionID& window_id, int index); | 168 void SetSelectedTabInWindow(const SessionID& window_id, int index); |
| 170 | 169 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 std::map<int, SessionTab*>* tabs, | 319 std::map<int, SessionTab*>* tabs, |
| 321 std::map<int, SessionWindow*>* windows); | 320 std::map<int, SessionWindow*>* windows); |
| 322 | 321 |
| 323 // Adds commands to commands that will recreate the state of the specified | 322 // Adds commands to commands that will recreate the state of the specified |
| 324 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each | 323 // tab. This adds at most kMaxNavigationCountToPersist navigations (in each |
| 325 // direction from the current navigation index). | 324 // direction from the current navigation index). |
| 326 // A pair is added to tab_to_available_range indicating the range of | 325 // A pair is added to tab_to_available_range indicating the range of |
| 327 // indices that were written. | 326 // indices that were written. |
| 328 void BuildCommandsForTab( | 327 void BuildCommandsForTab( |
| 329 const SessionID& window_id, | 328 const SessionID& window_id, |
| 330 TabContentsWrapper* tab, | 329 TabContents* tab, |
| 331 int index_in_window, | 330 int index_in_window, |
| 332 bool is_pinned, | 331 bool is_pinned, |
| 333 std::vector<SessionCommand*>* commands, | 332 std::vector<SessionCommand*>* commands, |
| 334 IdToRange* tab_to_available_range); | 333 IdToRange* tab_to_available_range); |
| 335 | 334 |
| 336 // Adds commands to create the specified browser, and invokes | 335 // Adds commands to create the specified browser, and invokes |
| 337 // BuildCommandsForTab for each of the tabs in the browser. This ignores | 336 // BuildCommandsForTab for each of the tabs in the browser. This ignores |
| 338 // any tabs not in the profile we were created with. | 337 // any tabs not in the profile we were created with. |
| 339 void BuildCommandsForBrowser( | 338 void BuildCommandsForBrowser( |
| 340 Browser* browser, | 339 Browser* browser, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 const base::TimeDelta save_delay_in_hrs_; | 470 const base::TimeDelta save_delay_in_hrs_; |
| 472 | 471 |
| 473 // For browser_tests, since we want to simulate the browser shutting down | 472 // For browser_tests, since we want to simulate the browser shutting down |
| 474 // without quitting. | 473 // without quitting. |
| 475 bool force_browser_not_alive_with_no_windows_; | 474 bool force_browser_not_alive_with_no_windows_; |
| 476 | 475 |
| 477 DISALLOW_COPY_AND_ASSIGN(SessionService); | 476 DISALLOW_COPY_AND_ASSIGN(SessionService); |
| 478 }; | 477 }; |
| 479 | 478 |
| 480 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 479 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| OLD | NEW |