| 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 <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback_list.h" | 12 #include "base/callback_list.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/ui/host_desktop.h" | |
| 15 #include "components/history/core/browser/history_service.h" | 14 #include "components/history/core/browser/history_service.h" |
| 16 #include "components/sessions/core/session_types.h" | 15 #include "components/sessions/core/session_types.h" |
| 17 #include "ui/base/window_open_disposition.h" | 16 #include "ui/base/window_open_disposition.h" |
| 18 | 17 |
| 19 class Browser; | 18 class Browser; |
| 20 class Profile; | 19 class Profile; |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 class WebContents; | 22 class WebContents; |
| 24 } | 23 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 using CallbackList = base::CallbackList<void(int)>; | 44 using CallbackList = base::CallbackList<void(int)>; |
| 46 | 45 |
| 47 // Used by objects calling RegisterOnSessionRestoredCallback() to de-register | 46 // Used by objects calling RegisterOnSessionRestoredCallback() to de-register |
| 48 // themselves when they are destroyed. | 47 // themselves when they are destroyed. |
| 49 using CallbackSubscription = | 48 using CallbackSubscription = |
| 50 scoped_ptr<base::CallbackList<void(int)>::Subscription>; | 49 scoped_ptr<base::CallbackList<void(int)>::Subscription>; |
| 51 | 50 |
| 52 // Restores the last session. |behavior| is a bitmask of Behaviors, see it | 51 // Restores the last session. |behavior| is a bitmask of Behaviors, see it |
| 53 // for details. If |browser| is non-null the tabs for the first window are | 52 // for details. If |browser| is non-null the tabs for the first window are |
| 54 // added to it. Returns the last active browser. | 53 // added to it. Returns the last active browser. |
| 55 // Every additional browser created will be created on the desktop specified | |
| 56 // by |host_desktop_type|, if |browser| is non-null it should have the same | |
| 57 // desktop type. | |
| 58 // | 54 // |
| 59 // If |urls_to_open| is non-empty, a tab is added for each of the URLs. | 55 // If |urls_to_open| is non-empty, a tab is added for each of the URLs. |
| 60 static Browser* RestoreSession(Profile* profile, | 56 static Browser* RestoreSession(Profile* profile, |
| 61 Browser* browser, | 57 Browser* browser, |
| 62 chrome::HostDesktopType host_desktop_type, | |
| 63 uint32_t behavior, | 58 uint32_t behavior, |
| 64 const std::vector<GURL>& urls_to_open); | 59 const std::vector<GURL>& urls_to_open); |
| 65 | 60 |
| 66 // Restores the last session when the last session crashed. It's a wrapper | 61 // Restores the last session when the last session crashed. It's a wrapper |
| 67 // of function RestoreSession. | 62 // of function RestoreSession. |
| 68 static void RestoreSessionAfterCrash(Browser* browser); | 63 static void RestoreSessionAfterCrash(Browser* browser); |
| 69 | 64 |
| 70 // Specifically used in the restoration of a foreign session. This function | 65 // Specifically used in the restoration of a foreign session. This function |
| 71 // restores the given session windows to multiple browsers all of which | 66 // restores the given session windows to multiple browsers. Returns the |
| 72 // will be created on the desktop specified by |host_desktop_type|. Returns | 67 // created Browsers. |
| 73 // the created Browsers. | |
| 74 static std::vector<Browser*> RestoreForeignSessionWindows( | 68 static std::vector<Browser*> RestoreForeignSessionWindows( |
| 75 Profile* profile, | 69 Profile* profile, |
| 76 chrome::HostDesktopType host_desktop_type, | |
| 77 std::vector<const sessions::SessionWindow*>::const_iterator begin, | 70 std::vector<const sessions::SessionWindow*>::const_iterator begin, |
| 78 std::vector<const sessions::SessionWindow*>::const_iterator end); | 71 std::vector<const sessions::SessionWindow*>::const_iterator end); |
| 79 | 72 |
| 80 // Specifically used in the restoration of a foreign session. This method | 73 // Specifically used in the restoration of a foreign session. This method |
| 81 // restores the given session tab to the browser of |source_web_contents| if | 74 // restores the given session tab to the browser of |source_web_contents| if |
| 82 // the disposition is not NEW_WINDOW. Returns the WebContents corresponding | 75 // the disposition is not NEW_WINDOW. Returns the WebContents corresponding |
| 83 // to the restored tab. If |disposition| is CURRENT_TAB, |source_web_contents| | 76 // to the restored tab. If |disposition| is CURRENT_TAB, |source_web_contents| |
| 84 // may be destroyed. | 77 // may be destroyed. |
| 85 static content::WebContents* RestoreForeignSessionTab( | 78 static content::WebContents* RestoreForeignSessionTab( |
| 86 content::WebContents* source_web_contents, | 79 content::WebContents* source_web_contents, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 111 return on_session_restored_callbacks_; | 104 return on_session_restored_callbacks_; |
| 112 } | 105 } |
| 113 | 106 |
| 114 // Contains all registered callbacks for session restore notifications. | 107 // Contains all registered callbacks for session restore notifications. |
| 115 static CallbackList* on_session_restored_callbacks_; | 108 static CallbackList* on_session_restored_callbacks_; |
| 116 | 109 |
| 117 DISALLOW_COPY_AND_ASSIGN(SessionRestore); | 110 DISALLOW_COPY_AND_ASSIGN(SessionRestore); |
| 118 }; | 111 }; |
| 119 | 112 |
| 120 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ | 113 #endif // CHROME_BROWSER_SESSIONS_SESSION_RESTORE_H_ |
| OLD | NEW |