| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tabs/tab_strip_model.h" | 5 #include "chrome/browser/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model.h" | 15 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 16 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
| 17 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/extension_tab_helper.h" | 19 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/sessions/tab_restore_service.h" | 21 #include "chrome/browser/sessions/tab_restore_service.h" |
| 22 #include "chrome/browser/tabs/tab_strip_model_delegate.h" | 22 #include "chrome/browser/tabs/tab_strip_model_delegate.h" |
| 23 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" | 23 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "content/browser/renderer_host/render_process_host.h" | |
| 29 #include "content/browser/tab_contents/navigation_controller.h" | 28 #include "content/browser/tab_contents/navigation_controller.h" |
| 30 #include "content/browser/tab_contents/tab_contents.h" | 29 #include "content/browser/tab_contents/tab_contents.h" |
| 31 #include "content/browser/tab_contents/tab_contents_delegate.h" | 30 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 32 #include "content/browser/tab_contents/tab_contents_view.h" | 31 #include "content/browser/tab_contents/tab_contents_view.h" |
| 33 #include "content/browser/user_metrics.h" | 32 #include "content/browser/user_metrics.h" |
| 34 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/render_process_host.h" |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // Returns true if the specified transition is one of the types that cause the | 38 // Returns true if the specified transition is one of the types that cause the |
| 39 // opener relationships for the tab in which the transition occured to be | 39 // opener relationships for the tab in which the transition occured to be |
| 40 // forgotten. This is generally any navigation that isn't a link click (i.e. | 40 // forgotten. This is generally any navigation that isn't a link click (i.e. |
| 41 // any navigation that can be considered to be the start of a new task distinct | 41 // any navigation that can be considered to be the start of a new task distinct |
| 42 // from what had previously occurred in that tab). | 42 // from what had previously occurred in that tab). |
| 43 bool ShouldForgetOpenersForTransition(content::PageTransition transition) { | 43 bool ShouldForgetOpenersForTransition(content::PageTransition transition) { |
| 44 return transition == content::PAGE_TRANSITION_TYPED || | 44 return transition == content::PAGE_TRANSITION_TYPED || |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 std::vector<TabContentsWrapper*> tabs; | 1132 std::vector<TabContentsWrapper*> tabs; |
| 1133 for (size_t i = 0; i < indices.size(); ++i) | 1133 for (size_t i = 0; i < indices.size(); ++i) |
| 1134 tabs.push_back(GetContentsAt(indices[i])); | 1134 tabs.push_back(GetContentsAt(indices[i])); |
| 1135 | 1135 |
| 1136 // We only try the fast shutdown path if the whole browser process is *not* | 1136 // We only try the fast shutdown path if the whole browser process is *not* |
| 1137 // shutting down. Fast shutdown during browser termination is handled in | 1137 // shutting down. Fast shutdown during browser termination is handled in |
| 1138 // BrowserShutdown. | 1138 // BrowserShutdown. |
| 1139 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) { | 1139 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) { |
| 1140 // Construct a map of processes to the number of associated tabs that are | 1140 // Construct a map of processes to the number of associated tabs that are |
| 1141 // closing. | 1141 // closing. |
| 1142 std::map<RenderProcessHost*, size_t> processes; | 1142 std::map<content::RenderProcessHost*, size_t> processes; |
| 1143 for (size_t i = 0; i < indices.size(); ++i) { | 1143 for (size_t i = 0; i < indices.size(); ++i) { |
| 1144 TabContentsWrapper* detached_contents = GetContentsAt(indices[i]); | 1144 TabContentsWrapper* detached_contents = GetContentsAt(indices[i]); |
| 1145 RenderProcessHost* process = | 1145 content::RenderProcessHost* process = |
| 1146 detached_contents->tab_contents()->GetRenderProcessHost(); | 1146 detached_contents->tab_contents()->GetRenderProcessHost(); |
| 1147 std::map<RenderProcessHost*, size_t>::iterator iter = | 1147 std::map<content::RenderProcessHost*, size_t>::iterator iter = |
| 1148 processes.find(process); | 1148 processes.find(process); |
| 1149 if (iter == processes.end()) { | 1149 if (iter == processes.end()) { |
| 1150 processes[process] = 1; | 1150 processes[process] = 1; |
| 1151 } else { | 1151 } else { |
| 1152 iter->second++; | 1152 iter->second++; |
| 1153 } | 1153 } |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 // Try to fast shutdown the tabs that can close. | 1156 // Try to fast shutdown the tabs that can close. |
| 1157 for (std::map<RenderProcessHost*, size_t>::iterator iter = | 1157 for (std::map<content::RenderProcessHost*, size_t>::iterator iter = |
| 1158 processes.begin(); | 1158 processes.begin(); |
| 1159 iter != processes.end(); ++iter) { | 1159 iter != processes.end(); ++iter) { |
| 1160 iter->first->FastShutdownForPageCount(iter->second); | 1160 iter->first->FastShutdownForPageCount(iter->second); |
| 1161 } | 1161 } |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 // We now return to our regularly scheduled shutdown procedure. | 1164 // We now return to our regularly scheduled shutdown procedure. |
| 1165 for (size_t i = 0; i < tabs.size(); ++i) { | 1165 for (size_t i = 0; i < tabs.size(); ++i) { |
| 1166 TabContentsWrapper* detached_contents = tabs[i]; | 1166 TabContentsWrapper* detached_contents = tabs[i]; |
| 1167 int index = GetIndexOfTabContents(detached_contents); | 1167 int index = GetIndexOfTabContents(detached_contents); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1318 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1319 const NavigationController* tab) { | 1319 const NavigationController* tab) { |
| 1320 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1320 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1321 i != contents_data_.end(); ++i) { | 1321 i != contents_data_.end(); ++i) { |
| 1322 if ((*i)->group == tab) | 1322 if ((*i)->group == tab) |
| 1323 (*i)->group = NULL; | 1323 (*i)->group = NULL; |
| 1324 if ((*i)->opener == tab) | 1324 if ((*i)->opener == tab) |
| 1325 (*i)->opener = NULL; | 1325 (*i)->opener = NULL; |
| 1326 } | 1326 } |
| 1327 } | 1327 } |
| OLD | NEW |