| Index: chrome/browser/ui/tabs/tab_strip_model.cc
|
| diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc
|
| index b7c60fbf90b974ee96176bae87dab73caad7e934..5d8e60dced924cd6c0857676644f8006d18c93b0 100644
|
| --- a/chrome/browser/ui/tabs/tab_strip_model.cc
|
| +++ b/chrome/browser/ui/tabs/tab_strip_model.cc
|
| @@ -19,6 +19,7 @@
|
| #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h"
|
| +#include "chrome/browser/ui/tabs/tab_utils.h"
|
| #include "chrome/browser/ui/web_contents_sizer.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "components/web_modal/popup_manager.h"
|
| @@ -701,6 +702,18 @@ bool TabStripModel::IsTabPinned(int index) const {
|
| return contents_data_[index]->pinned();
|
| }
|
|
|
| +void TabStripModel::SetTabAudioMuted(int index, bool mute) {
|
| + content::WebContents* const contents = GetWebContentsAt(index);
|
| + if (!contents || !chrome::CanToggleAudioMute(contents))
|
| + return;
|
| + contents->SetAudioMuted(mute);
|
| +}
|
| +
|
| +bool TabStripModel::IsTabAudioMuted(int index) const {
|
| + content::WebContents* const contents = GetWebContentsAt(index);
|
| + return contents && contents->IsAudioMuted();
|
| +}
|
| +
|
| bool TabStripModel::IsMiniTab(int index) const {
|
| return IsTabPinned(index) || IsAppTab(index);
|
| }
|
| @@ -919,6 +932,18 @@ bool TabStripModel::IsContextMenuCommandEnabled(
|
| return false;
|
| }
|
|
|
| + case CommandToggleTabAudioMuted: {
|
| + if (!chrome::IsTabAudioMutingFeatureEnabled())
|
| + return false;
|
| + std::vector<int> indices = GetIndicesForCommand(context_index);
|
| + for (size_t i = 0; i < indices.size(); ++i) {
|
| + WebContents* const tab = GetWebContentsAt(indices[i]);
|
| + if (!tab || !chrome::CanToggleAudioMute(tab))
|
| + return false;
|
| + }
|
| + return true;
|
| + }
|
| +
|
| case CommandBookmarkAllTabs:
|
| return browser_defaults::bookmarks_enabled &&
|
| delegate_->CanBookmarkAllTabs();
|
| @@ -1026,6 +1051,18 @@ void TabStripModel::ExecuteContextMenuCommand(
|
| break;
|
| }
|
|
|
| + case CommandToggleTabAudioMuted: {
|
| + const bool mute = WillContextMenuMute(context_index);
|
| + if (mute)
|
| + content::RecordAction(UserMetricsAction("TabContextMenu_MuteTabs"));
|
| + else
|
| + content::RecordAction(UserMetricsAction("TabContextMenu_UnmuteTabs"));
|
| + std::vector<int> indices = GetIndicesForCommand(context_index);
|
| + for (size_t i = 0; i < indices.size(); ++i)
|
| + SetTabAudioMuted(indices[i], mute);
|
| + break;
|
| + }
|
| +
|
| case CommandBookmarkAllTabs: {
|
| content::RecordAction(
|
| UserMetricsAction("TabContextMenu_BookmarkAllTabs"));
|
| @@ -1091,6 +1128,16 @@ bool TabStripModel::WillContextMenuPin(int index) {
|
| return !all_pinned;
|
| }
|
|
|
| +bool TabStripModel::WillContextMenuMute(int index) {
|
| + std::vector<int> indices = GetIndicesForCommand(index);
|
| + // If all tabs are muted, then we unmute, otherwise we mute.
|
| + for (size_t i = 0; i < indices.size(); ++i) {
|
| + if (!IsTabAudioMuted(indices[i]))
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| // static
|
| bool TabStripModel::ContextMenuCommandToBrowserCommand(int cmd_id,
|
| int* browser_cmd) {
|
|
|