Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model.cc

Issue 591963002: Tab audio mute control (views UI), behind a switch (off by default). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + add about:flags experiment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model.h ('k') | chrome/browser/ui/tabs/tab_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 9 #include <string>
10 10
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/browser_shutdown.h" 14 #include "chrome/browser/browser_shutdown.h"
15 #include "chrome/browser/defaults.h" 15 #include "chrome/browser/defaults.h"
16 #include "chrome/browser/extensions/tab_helper.h" 16 #include "chrome/browser/extensions/tab_helper.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 18 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
19 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" 19 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h"
22 #include "chrome/browser/ui/tabs/tab_utils.h"
22 #include "chrome/browser/ui/web_contents_sizer.h" 23 #include "chrome/browser/ui/web_contents_sizer.h"
23 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
24 #include "components/web_modal/popup_manager.h" 25 #include "components/web_modal/popup_manager.h"
25 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/user_metrics.h" 27 #include "content/public/browser/user_metrics.h"
27 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_contents_observer.h" 29 #include "content/public/browser/web_contents_observer.h"
29 using base::UserMetricsAction; 30 using base::UserMetricsAction;
30 using content::WebContents; 31 using content::WebContents;
31 32
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 913
913 case CommandTogglePinned: { 914 case CommandTogglePinned: {
914 std::vector<int> indices = GetIndicesForCommand(context_index); 915 std::vector<int> indices = GetIndicesForCommand(context_index);
915 for (size_t i = 0; i < indices.size(); ++i) { 916 for (size_t i = 0; i < indices.size(); ++i) {
916 if (!IsAppTab(indices[i])) 917 if (!IsAppTab(indices[i]))
917 return true; 918 return true;
918 } 919 }
919 return false; 920 return false;
920 } 921 }
921 922
923 case CommandToggleTabAudioMuted: {
924 std::vector<int> indices = GetIndicesForCommand(context_index);
925 for (size_t i = 0; i < indices.size(); ++i) {
926 if (!chrome::CanToggleAudioMute(GetWebContentsAt(indices[i])))
927 return false;
928 }
929 return true;
930 }
931
922 case CommandBookmarkAllTabs: 932 case CommandBookmarkAllTabs:
923 return browser_defaults::bookmarks_enabled && 933 return browser_defaults::bookmarks_enabled &&
924 delegate_->CanBookmarkAllTabs(); 934 delegate_->CanBookmarkAllTabs();
925 935
926 case CommandSelectByDomain: 936 case CommandSelectByDomain:
927 case CommandSelectByOpener: 937 case CommandSelectByOpener:
928 return true; 938 return true;
929 939
930 default: 940 default:
931 NOTREACHED(); 941 NOTREACHED();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 // Unpin from the back so that the order is maintained (unpinning can 1029 // Unpin from the back so that the order is maintained (unpinning can
1020 // trigger moving a tab). 1030 // trigger moving a tab).
1021 for (size_t i = indices.size(); i > 0; --i) { 1031 for (size_t i = indices.size(); i > 0; --i) {
1022 if (!IsAppTab(indices[i - 1])) 1032 if (!IsAppTab(indices[i - 1]))
1023 SetTabPinned(indices[i - 1], false); 1033 SetTabPinned(indices[i - 1], false);
1024 } 1034 }
1025 } 1035 }
1026 break; 1036 break;
1027 } 1037 }
1028 1038
1039 case CommandToggleTabAudioMuted: {
1040 const std::vector<int>& indices = GetIndicesForCommand(context_index);
1041 const bool mute = !chrome::AreAllTabsMuted(*this, indices);
1042 if (mute)
1043 content::RecordAction(UserMetricsAction("TabContextMenu_MuteTabs"));
1044 else
1045 content::RecordAction(UserMetricsAction("TabContextMenu_UnmuteTabs"));
1046 for (std::vector<int>::const_iterator i = indices.begin();
1047 i != indices.end(); ++i) {
1048 chrome::SetTabAudioMuted(GetWebContentsAt(*i), mute);
1049 }
1050 break;
1051 }
1052
1029 case CommandBookmarkAllTabs: { 1053 case CommandBookmarkAllTabs: {
1030 content::RecordAction( 1054 content::RecordAction(
1031 UserMetricsAction("TabContextMenu_BookmarkAllTabs")); 1055 UserMetricsAction("TabContextMenu_BookmarkAllTabs"));
1032 1056
1033 delegate_->BookmarkAllTabs(); 1057 delegate_->BookmarkAllTabs();
1034 break; 1058 break;
1035 } 1059 }
1036 1060
1037 case CommandSelectByDomain: 1061 case CommandSelectByDomain:
1038 case CommandSelectByOpener: { 1062 case CommandSelectByOpener: {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1429 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1406 const WebContents* tab) { 1430 const WebContents* tab) {
1407 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); 1431 for (WebContentsDataVector::const_iterator i = contents_data_.begin();
1408 i != contents_data_.end(); ++i) { 1432 i != contents_data_.end(); ++i) {
1409 if ((*i)->group() == tab) 1433 if ((*i)->group() == tab)
1410 (*i)->set_group(NULL); 1434 (*i)->set_group(NULL);
1411 if ((*i)->opener() == tab) 1435 if ((*i)->opener() == tab)
1412 (*i)->set_opener(NULL); 1436 (*i)->set_opener(NULL);
1413 } 1437 }
1414 } 1438 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model.h ('k') | chrome/browser/ui/tabs/tab_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698