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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 962 |
963 const ui::ListSelectionModel& TabStrip::GetSelectionModel() { | 963 const ui::ListSelectionModel& TabStrip::GetSelectionModel() { |
964 return controller_->GetSelectionModel(); | 964 return controller_->GetSelectionModel(); |
965 } | 965 } |
966 | 966 |
967 bool TabStrip::SupportsMultipleSelection() { | 967 bool TabStrip::SupportsMultipleSelection() { |
968 // TODO: currently only allow single selection in touch layout mode. | 968 // TODO: currently only allow single selection in touch layout mode. |
969 return touch_layout_ == NULL; | 969 return touch_layout_ == NULL; |
970 } | 970 } |
971 | 971 |
972 // TODO(tdanderson): Modify this logic and clean up related code once a | |
973 // decision has been made on the experimental | |
974 // flag --tab-close-buttons-hidden-with-touch. | |
975 bool TabStrip::ShouldHideCloseButtonForInactiveTab(const Tab* tab) { | 972 bool TabStrip::ShouldHideCloseButtonForInactiveTab(const Tab* tab) { |
976 DCHECK(!tab->IsActive()); | 973 DCHECK(!tab->IsActive()); |
977 | 974 |
978 // Do not force the close button to hide if mouse was used as | 975 // Do not force the close button to hide if mouse was used as |
979 // the last input type to interact with the tab strip. | 976 // the last input type to interact with the tab strip or if |
980 if (!stacked_layout_) | 977 // the tabs are wider than the width used for stacked tabs. |
| 978 if (!stacked_layout_ || tab->width() > Tab::GetTouchWidth()) |
981 return false; | 979 return false; |
982 | 980 |
983 std::string switch_value = | 981 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
984 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 982 switches::kDisableHideInactiveStackedTabCloseButtons); |
985 switches::kTabCloseButtonsHiddenWithTouch); | |
986 int width = tab->width(); | |
987 if (switch_value == "always" || | |
988 (switch_value == "narrow" && width < Tab::GetStandardSize().width()) || | |
989 (switch_value == "stacked" && width <= Tab::GetTouchWidth())) { | |
990 return true; | |
991 } | |
992 | |
993 return false; | |
994 } | 983 } |
995 | 984 |
996 void TabStrip::SelectTab(Tab* tab) { | 985 void TabStrip::SelectTab(Tab* tab) { |
997 int model_index = GetModelIndexOfTab(tab); | 986 int model_index = GetModelIndexOfTab(tab); |
998 if (IsValidModelIndex(model_index)) | 987 if (IsValidModelIndex(model_index)) |
999 controller_->SelectTab(model_index); | 988 controller_->SelectTab(model_index); |
1000 } | 989 } |
1001 | 990 |
1002 void TabStrip::ExtendSelectionTo(Tab* tab) { | 991 void TabStrip::ExtendSelectionTo(Tab* tab) { |
1003 int model_index = GetModelIndexOfTab(tab); | 992 int model_index = GetModelIndexOfTab(tab); |
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2755 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
2767 if (view) | 2756 if (view) |
2768 return view; | 2757 return view; |
2769 } | 2758 } |
2770 Tab* tab = FindTabForEvent(point); | 2759 Tab* tab = FindTabForEvent(point); |
2771 if (tab) | 2760 if (tab) |
2772 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2761 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
2773 } | 2762 } |
2774 return this; | 2763 return this; |
2775 } | 2764 } |
OLD | NEW |