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_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 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_list.h" | 13 #include "base/callback_list.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "chrome/browser/sessions/session_restore_observer.h" | 17 #include "chrome/browser/sessions/session_restore_observer.h" |
18 #include "components/history/core/browser/history_service.h" | 18 #include "components/history/core/browser/history_service.h" |
19 #include "components/sessions/core/session_types.h" | 19 #include "components/sessions/core/session_types.h" |
20 #include "content/public/browser/web_contents_user_data.h" | |
20 #include "ui/base/window_open_disposition.h" | 21 #include "ui/base/window_open_disposition.h" |
21 | 22 |
22 class Browser; | 23 class Browser; |
23 class Profile; | 24 class Profile; |
24 class SessionRestoreImpl; | 25 class SessionRestoreImpl; |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 class WebContents; | 28 class WebContents; |
28 } | 29 } |
29 | 30 |
31 // Indicate the origin of the restoration of web contents (e.g., session | |
32 // restore, reopening closed tab, and restore foreign tab). A tab | |
33 // holds a valid instance of this class only when the tab is loading during | |
34 // session restore. | |
35 class RestoreOrigin : public content::WebContentsUserData<RestoreOrigin> { | |
sky
2017/07/25 16:48:00
I think the enum makes sense if it's going to be a
chrisha
2017/07/25 19:00:50
+1 to this idea.
| |
36 public: | |
37 enum class Type { SESSION_RESTORE }; | |
38 | |
39 static void CreateForWebContents(content::WebContents* contents, | |
40 RestoreOrigin::Type type); | |
41 static void RemoveFromWebContents(content::WebContents* contents); | |
42 ~RestoreOrigin() override; | |
43 | |
44 Type type() const { return type_; } | |
45 | |
46 private: | |
47 friend class content::WebContentsUserData<RestoreOrigin>; | |
48 explicit RestoreOrigin(Type type); | |
49 | |
50 Type type_; | |
51 }; | |
52 | |
30 // SessionRestore handles restoring either the last or saved session. Session | 53 // SessionRestore handles restoring either the last or saved session. Session |
31 // restore come in two variants, asynchronous or synchronous. The synchronous | 54 // restore come in two variants, asynchronous or synchronous. The synchronous |
32 // variety is meant for startup and blocks until restore is complete. | 55 // variety is meant for startup and blocks until restore is complete. |
33 class SessionRestore { | 56 class SessionRestore { |
34 public: | 57 public: |
35 // Bitmask representing behaviors available when restoring a session. Populate | 58 // Bitmask representing behaviors available when restoring a session. Populate |
36 // using the values below. | 59 // using the values below. |
37 using BehaviorBitmask = uint32_t; | 60 using BehaviorBitmask = uint32_t; |
38 | 61 |
39 enum { | 62 enum { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 // Contains all registered observers for session restore events. | 178 // Contains all registered observers for session restore events. |
156 static SessionRestoreObserverList* observers_; | 179 static SessionRestoreObserverList* observers_; |
157 | 180 |
158 // Whether session restore started or not. | 181 // Whether session restore started or not. |
159 static bool session_restore_started_; | 182 static bool session_restore_started_; |
160 | 183 |
161 DISALLOW_COPY_AND_ASSIGN(SessionRestore); | 184 DISALLOW_COPY_AND_ASSIGN(SessionRestore); |
162 }; | 185 }; |
163 | 186 |
164 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ | 187 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
OLD | NEW |