OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/views/tabs/tab_strip.h" |
6 | 6 |
7 #include "base/gfx/size.h" | 7 #include "base/gfx/size.h" |
8 #include "chrome/browser/metrics/user_metrics.h" | 8 #include "chrome/browser/metrics/user_metrics.h" |
9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 10 #include "chrome/browser/tab_contents/tab_contents.h" |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 TabContents* contents = model_->GetTabContentsAt(tab_index); | 897 TabContents* contents = model_->GetTabContentsAt(tab_index); |
898 if (contents) | 898 if (contents) |
899 UserMetrics::RecordAction(L"CloseTab_Mouse", contents->profile()); | 899 UserMetrics::RecordAction(L"CloseTab_Mouse", contents->profile()); |
900 Tab* last_tab = GetTabAt(GetTabCount() - 1); | 900 Tab* last_tab = GetTabAt(GetTabCount() - 1); |
901 // Limit the width available to the TabStrip for laying out Tabs, so that | 901 // Limit the width available to the TabStrip for laying out Tabs, so that |
902 // Tabs are not resized until a later time (when the mouse pointer leaves | 902 // Tabs are not resized until a later time (when the mouse pointer leaves |
903 // the TabStrip). | 903 // the TabStrip). |
904 available_width_for_tabs_ = GetAvailableWidthForTabs(last_tab); | 904 available_width_for_tabs_ = GetAvailableWidthForTabs(last_tab); |
905 resize_layout_scheduled_ = true; | 905 resize_layout_scheduled_ = true; |
906 AddMessageLoopObserver(); | 906 AddMessageLoopObserver(); |
| 907 // Note that the next call might not close the tab (because of unload |
| 908 // hanlders or if the delegate veto the close). |
907 model_->CloseTabContentsAt(tab_index); | 909 model_->CloseTabContentsAt(tab_index); |
908 } | 910 } |
909 } | 911 } |
910 | 912 |
911 bool TabStrip::IsCommandEnabledForTab( | 913 bool TabStrip::IsCommandEnabledForTab( |
912 TabStripModel::ContextMenuCommand command_id, const Tab* tab) const { | 914 TabStripModel::ContextMenuCommand command_id, const Tab* tab) const { |
913 int index = GetIndexOfTab(tab); | 915 int index = GetIndexOfTab(tab); |
914 if (model_->ContainsIndex(index)) | 916 if (model_->ContainsIndex(index)) |
915 return model_->IsContextMenuCommandEnabled(index, command_id); | 917 return model_->IsContextMenuCommandEnabled(index, command_id); |
916 return false; | 918 return false; |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 // If the TabContents being detached was removed as a result of a drag | 1521 // If the TabContents being detached was removed as a result of a drag |
1520 // gesture from its corresponding Tab, we don't want to remove the Tab from | 1522 // gesture from its corresponding Tab, we don't want to remove the Tab from |
1521 // the child list, because if we do so it'll stop receiving events and the | 1523 // the child list, because if we do so it'll stop receiving events and the |
1522 // drag will stall. So we only remove if a drag isn't active, or the Tab | 1524 // drag will stall. So we only remove if a drag isn't active, or the Tab |
1523 // was for some other TabContents. | 1525 // was for some other TabContents. |
1524 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { | 1526 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { |
1525 removed->GetParent()->RemoveChildView(removed); | 1527 removed->GetParent()->RemoveChildView(removed); |
1526 delete removed; | 1528 delete removed; |
1527 } | 1529 } |
1528 } | 1530 } |
OLD | NEW |