| 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/tabs/tab_strip_model.h" | 5 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 // Unpin from the back so that the order is maintained (unpinning can | 978 // Unpin from the back so that the order is maintained (unpinning can |
| 979 // trigger moving a tab). | 979 // trigger moving a tab). |
| 980 for (size_t i = indices.size(); i > 0; --i) | 980 for (size_t i = indices.size(); i > 0; --i) |
| 981 SetTabPinned(indices[i - 1], false); | 981 SetTabPinned(indices[i - 1], false); |
| 982 } | 982 } |
| 983 break; | 983 break; |
| 984 } | 984 } |
| 985 | 985 |
| 986 case CommandToggleTabAudioMuted: { | 986 case CommandToggleTabAudioMuted: { |
| 987 const std::vector<int>& indices = GetIndicesForCommand(context_index); | 987 const std::vector<int>& indices = GetIndicesForCommand(context_index); |
| 988 const bool mute = !chrome::AreAllTabsMuted(*this, indices); | 988 const bool mute = WillContextMenuMute(context_index); |
| 989 if (mute) | 989 if (mute) |
| 990 base::RecordAction(UserMetricsAction("TabContextMenu_MuteTabs")); | 990 base::RecordAction(UserMetricsAction("TabContextMenu_MuteTabs")); |
| 991 else | 991 else |
| 992 base::RecordAction(UserMetricsAction("TabContextMenu_UnmuteTabs")); | 992 base::RecordAction(UserMetricsAction("TabContextMenu_UnmuteTabs")); |
| 993 for (std::vector<int>::const_iterator i = indices.begin(); | 993 for (std::vector<int>::const_iterator i = indices.begin(); |
| 994 i != indices.end(); ++i) { | 994 i != indices.end(); ++i) { |
| 995 chrome::SetTabAudioMuted(GetWebContentsAt(*i), mute, | 995 chrome::SetTabAudioMuted(GetWebContentsAt(*i), mute, |
| 996 TabMutedReason::CONTEXT_MENU, std::string()); | 996 TabMutedReason::CONTEXT_MENU, std::string()); |
| 997 } | 997 } |
| 998 break; | 998 break; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 | 1039 |
| 1040 // NOTE: callers expect the vector to be sorted in descending order. | 1040 // NOTE: callers expect the vector to be sorted in descending order. |
| 1041 std::vector<int> indices; | 1041 std::vector<int> indices; |
| 1042 for (int i = count() - 1; i > last_unclosed_tab; --i) { | 1042 for (int i = count() - 1; i > last_unclosed_tab; --i) { |
| 1043 if (i != index && !IsTabPinned(i) && (!is_selected || !IsTabSelected(i))) | 1043 if (i != index && !IsTabPinned(i) && (!is_selected || !IsTabSelected(i))) |
| 1044 indices.push_back(i); | 1044 indices.push_back(i); |
| 1045 } | 1045 } |
| 1046 return indices; | 1046 return indices; |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 bool TabStripModel::WillContextMenuMute(int index) { |
| 1050 std::vector<int> indices = GetIndicesForCommand(index); |
| 1051 return !chrome::AreAllTabsMuted(*this, indices); |
| 1052 } |
| 1053 |
| 1049 bool TabStripModel::WillContextMenuPin(int index) { | 1054 bool TabStripModel::WillContextMenuPin(int index) { |
| 1050 std::vector<int> indices = GetIndicesForCommand(index); | 1055 std::vector<int> indices = GetIndicesForCommand(index); |
| 1051 // If all tabs are pinned, then we unpin, otherwise we pin. | 1056 // If all tabs are pinned, then we unpin, otherwise we pin. |
| 1052 bool all_pinned = true; | 1057 bool all_pinned = true; |
| 1053 for (size_t i = 0; i < indices.size() && all_pinned; ++i) | 1058 for (size_t i = 0; i < indices.size() && all_pinned; ++i) |
| 1054 all_pinned = IsTabPinned(indices[i]); | 1059 all_pinned = IsTabPinned(indices[i]); |
| 1055 return !all_pinned; | 1060 return !all_pinned; |
| 1056 } | 1061 } |
| 1057 | 1062 |
| 1058 // static | 1063 // static |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 | 1372 |
| 1368 void TabStripModel::FixOpenersAndGroupsReferencing(int index) { | 1373 void TabStripModel::FixOpenersAndGroupsReferencing(int index) { |
| 1369 WebContents* old_contents = GetWebContentsAtImpl(index); | 1374 WebContents* old_contents = GetWebContentsAtImpl(index); |
| 1370 for (auto& data : contents_data_) { | 1375 for (auto& data : contents_data_) { |
| 1371 if (data->group() == old_contents) | 1376 if (data->group() == old_contents) |
| 1372 data->set_group(contents_data_[index]->group()); | 1377 data->set_group(contents_data_[index]->group()); |
| 1373 if (data->opener() == old_contents) | 1378 if (data->opener() == old_contents) |
| 1374 data->set_opener(contents_data_[index]->opener()); | 1379 data->set_opener(contents_data_[index]->opener()); |
| 1375 } | 1380 } |
| 1376 } | 1381 } |
| OLD | NEW |