OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_RESTORE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/history/history.h" | 11 #include "chrome/browser/history/history.h" |
12 #include "chrome/browser/sessions/session_types.h" | |
13 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
14 | 13 |
15 class Browser; | 14 class Browser; |
16 class Profile; | 15 class Profile; |
17 | 16 |
18 // SessionRestore handles restoring either the last or saved session. Session | 17 // SessionRestore handles restoring either the last or saved session. Session |
19 // restore come in two variants, asynchronous or synchronous. The synchronous | 18 // restore come in two variants, asynchronous or synchronous. The synchronous |
20 // variety is meant for startup, and blocks until restore is complete. | 19 // variety is meant for startup, and blocks until restore is complete. |
21 class SessionRestore { | 20 class SessionRestore { |
22 public: | 21 public: |
23 // Asnchronously restores the specified session. | 22 // Asnchronously restores the specified session. |
24 // If |browser| is non-null the tabs for the first window are added to it. | 23 // If |browser| is non-null the tabs for the first window are added to it. |
25 // If clobber_existing_window is true and there is an open browser window, | 24 // If clobber_existing_window is true and there is an open browser window, |
26 // it is closed after restoring. | 25 // it is closed after restoring. |
27 // If always_create_tabbed_browser is true at least one tabbed browser is | 26 // If always_create_tabbed_browser is true at least one tabbed browser is |
28 // created. For example, if there is an error restoring, or the last session | 27 // created. For example, if there is an error restoring, or the last session |
29 // session is empty and always_create_tabbed_browser is true, a new empty | 28 // session is empty and always_create_tabbed_browser is true, a new empty |
30 // tabbed browser is created. | 29 // tabbed browser is created. |
31 // | 30 // |
32 // If urls_to_open is non-empty, a tab is added for each of the URLs. | 31 // If urls_to_open is non-empty, a tab is added for each of the URLs. |
33 static void RestoreSession(Profile* profile, | 32 static void RestoreSession(Profile* profile, |
34 Browser* browser, | 33 Browser* browser, |
35 bool clobber_existing_window, | 34 bool clobber_existing_window, |
36 bool always_create_tabbed_browser, | 35 bool always_create_tabbed_browser, |
37 const std::vector<GURL>& urls_to_open); | 36 const std::vector<GURL>& urls_to_open); |
38 | 37 |
39 // Specifically used in the restoration of a foreign session. This method | |
40 // restores the given session windows to a browser. | |
41 static void RestoreForeignSessionWindows(Profile* profile, | |
42 std::vector<SessionWindow*>* windows); | |
43 | |
44 // Synchronously restores the last session. At least one tabbed browser is | 38 // Synchronously restores the last session. At least one tabbed browser is |
45 // created, even if there is an error in restoring. | 39 // created, even if there is an error in restoring. |
46 // | 40 // |
47 // If urls_to_open is non-empty, a tab is added for each of the URLs. | 41 // If urls_to_open is non-empty, a tab is added for each of the URLs. |
48 static void RestoreSessionSynchronously( | 42 static void RestoreSessionSynchronously( |
49 Profile* profile, | 43 Profile* profile, |
50 const std::vector<GURL>& urls_to_open); | 44 const std::vector<GURL>& urls_to_open); |
51 | 45 |
52 // Returns true if we're in the process of restoring. | 46 // Returns true if we're in the process of restoring. |
53 static bool IsRestoring(); | 47 static bool IsRestoring(); |
54 | 48 |
55 // The max number of non-selected tabs SessionRestore loads when restoring | 49 // The max number of non-selected tabs SessionRestore loads when restoring |
56 // a session. A value of 0 indicates all tabs are loaded at once. | 50 // a session. A value of 0 indicates all tabs are loaded at once. |
57 static size_t num_tabs_to_load_; | 51 static size_t num_tabs_to_load_; |
58 | 52 |
59 private: | 53 private: |
60 SessionRestore(); | 54 SessionRestore(); |
61 | 55 |
62 DISALLOW_COPY_AND_ASSIGN(SessionRestore); | 56 DISALLOW_COPY_AND_ASSIGN(SessionRestore); |
63 }; | 57 }; |
64 | 58 |
65 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ | 59 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
OLD | NEW |