| 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-inl.h" | 11 #include "base/stl_util-inl.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/browser/ui/webui/web_ui_util.h" |
| 25 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 27 #include "content/browser/renderer_host/render_process_host.h" | 28 #include "content/browser/renderer_host/render_process_host.h" |
| 28 #include "content/browser/tab_contents/navigation_controller.h" | 29 #include "content/browser/tab_contents/navigation_controller.h" |
| 29 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
| 30 #include "content/browser/tab_contents/tab_contents_delegate.h" | 31 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 31 #include "content/browser/tab_contents/tab_contents_view.h" | 32 #include "content/browser/tab_contents/tab_contents_view.h" |
| 32 #include "content/browser/user_metrics.h" | 33 #include "content/browser/user_metrics.h" |
| 33 #include "content/common/notification_service.h" | 34 #include "content/common/notification_service.h" |
| 34 | 35 |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 std::vector<int> indices; | 1097 std::vector<int> indices; |
| 1097 indices.push_back(index); | 1098 indices.push_back(index); |
| 1098 return indices; | 1099 return indices; |
| 1099 } | 1100 } |
| 1100 return selection_model_.selected_indices(); | 1101 return selection_model_.selected_indices(); |
| 1101 } | 1102 } |
| 1102 | 1103 |
| 1103 bool TabStripModel::IsNewTabAtEndOfTabStrip( | 1104 bool TabStripModel::IsNewTabAtEndOfTabStrip( |
| 1104 TabContentsWrapper* contents) const { | 1105 TabContentsWrapper* contents) const { |
| 1105 const GURL& url = contents->tab_contents()->GetURL(); | 1106 const GURL& url = contents->tab_contents()->GetURL(); |
| 1106 return url.SchemeIs(chrome::kChromeUIScheme) && | 1107 return web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost) && |
| 1107 url.host() == chrome::kChromeUINewTabHost && | 1108 contents == GetContentsAt(count() - 1) && |
| 1108 contents == GetContentsAt(count() - 1) && | 1109 contents->controller().entry_count() == 1; |
| 1109 contents->controller().entry_count() == 1; | |
| 1110 } | 1110 } |
| 1111 | 1111 |
| 1112 bool TabStripModel::InternalCloseTabs(const std::vector<int>& in_indices, | 1112 bool TabStripModel::InternalCloseTabs(const std::vector<int>& in_indices, |
| 1113 uint32 close_types) { | 1113 uint32 close_types) { |
| 1114 if (in_indices.empty()) | 1114 if (in_indices.empty()) |
| 1115 return true; | 1115 return true; |
| 1116 | 1116 |
| 1117 std::vector<int> indices(in_indices); | 1117 std::vector<int> indices(in_indices); |
| 1118 bool retval = delegate_->CanCloseContents(&indices); | 1118 bool retval = delegate_->CanCloseContents(&indices); |
| 1119 if (indices.empty()) | 1119 if (indices.empty()) |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1311 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1312 const NavigationController* tab) { | 1312 const NavigationController* tab) { |
| 1313 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1313 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1314 i != contents_data_.end(); ++i) { | 1314 i != contents_data_.end(); ++i) { |
| 1315 if ((*i)->group == tab) | 1315 if ((*i)->group == tab) |
| 1316 (*i)->group = NULL; | 1316 (*i)->group = NULL; |
| 1317 if ((*i)->opener == tab) | 1317 if ((*i)->opener == tab) |
| 1318 (*i)->opener = NULL; | 1318 (*i)->opener = NULL; |
| 1319 } | 1319 } |
| 1320 } | 1320 } |
| OLD | NEW |