| 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 #include "chrome/browser/ui/browser_tabrestore.h" | 5 #include "chrome/browser/ui/browser_tabrestore.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/tab_helper.h" | 7 #include "chrome/browser/extensions/tab_helper.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/sessions/session_service.h" | 9 #include "chrome/browser/sessions/session_service.h" |
| 10 #include "chrome/browser/sessions/session_service_factory.h" | 10 #include "chrome/browser/sessions/session_service_factory.h" |
| 11 #include "chrome/browser/tab_contents/tab_util.h" | 11 #include "chrome/browser/tab_contents/tab_util.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/ui/web_contents_sizer.h" | 15 #include "chrome/browser/ui/web_contents_sizer.h" |
| 16 #include "components/sessions/content/content_serialized_navigation_builder.h" | 16 #include "components/sessions/content/content_serialized_navigation_builder.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/session_storage_namespace.h" | 19 #include "content/public/browser/session_storage_namespace.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 | 21 |
| 22 using content::RestoreType; |
| 22 using content::WebContents; | 23 using content::WebContents; |
| 23 using content::NavigationController; | 24 using content::NavigationController; |
| 24 using content::NavigationEntry; | 25 using content::NavigationEntry; |
| 25 using sessions::ContentSerializedNavigationBuilder; | 26 using sessions::ContentSerializedNavigationBuilder; |
| 26 using sessions::SerializedNavigationEntry; | 27 using sessions::SerializedNavigationEntry; |
| 27 | 28 |
| 28 namespace chrome { | 29 namespace chrome { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 NavigationController::RestoreType GetRestoreType(Browser* browser, | 33 RestoreType GetRestoreType(Browser* browser, bool from_last_session) { |
| 33 bool from_last_session) { | |
| 34 if (!from_last_session) | 34 if (!from_last_session) |
| 35 return NavigationController::RESTORE_CURRENT_SESSION; | 35 return RestoreType::CURRENT_SESSION; |
| 36 return browser->profile()->GetLastSessionExitType() == Profile::EXIT_CRASHED ? | 36 return browser->profile()->GetLastSessionExitType() == Profile::EXIT_CRASHED |
| 37 NavigationController::RESTORE_LAST_SESSION_CRASHED : | 37 ? RestoreType::LAST_SESSION_CRASHED |
| 38 NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY; | 38 : RestoreType::LAST_SESSION_EXITED_CLEANLY; |
| 39 } | 39 } |
| 40 | 40 |
| 41 WebContents* CreateRestoredTab( | 41 WebContents* CreateRestoredTab( |
| 42 Browser* browser, | 42 Browser* browser, |
| 43 const std::vector<SerializedNavigationEntry>& navigations, | 43 const std::vector<SerializedNavigationEntry>& navigations, |
| 44 int selected_navigation, | 44 int selected_navigation, |
| 45 const std::string& extension_app_id, | 45 const std::string& extension_app_id, |
| 46 bool from_last_session, | 46 bool from_last_session, |
| 47 content::SessionStorageNamespace* session_storage_namespace, | 47 content::SessionStorageNamespace* session_storage_namespace, |
| 48 const std::string& user_agent_override, | 48 const std::string& user_agent_override, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 int insertion_index = tab_strip->active_index(); | 161 int insertion_index = tab_strip->active_index(); |
| 162 tab_strip->InsertWebContentsAt(insertion_index + 1, | 162 tab_strip->InsertWebContentsAt(insertion_index + 1, |
| 163 web_contents, | 163 web_contents, |
| 164 TabStripModel::ADD_ACTIVE | | 164 TabStripModel::ADD_ACTIVE | |
| 165 TabStripModel::ADD_INHERIT_GROUP); | 165 TabStripModel::ADD_INHERIT_GROUP); |
| 166 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); | 166 tab_strip->CloseWebContentsAt(insertion_index, TabStripModel::CLOSE_NONE); |
| 167 return web_contents; | 167 return web_contents; |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace chrome | 170 } // namespace chrome |
| OLD | NEW |