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

Side by Side Diff: chrome/browser/ui/tabs/tab_utils.h

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.cc ('k') | chrome/browser/ui/tabs/tab_utils.cc » ('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 #ifndef CHROME_BROWSER_UI_TABS_TAB_UTILS_H_ 5 #ifndef CHROME_BROWSER_UI_TABS_TAB_UTILS_H_
6 #define CHROME_BROWSER_UI_TABS_TAB_UTILS_H_ 6 #define CHROME_BROWSER_UI_TABS_TAB_UTILS_H_
7 7
8 #include <vector>
9
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
10 12
13 class TabStripModel;
14
11 namespace content { 15 namespace content {
12 class WebContents; 16 class WebContents;
13 } // namespace content 17 } // namespace content
14 18
15 namespace gfx { 19 namespace gfx {
16 class Animation; 20 class Animation;
17 class Image; 21 class Image;
18 } // namespace gfx 22 } // namespace gfx
19 23
20 // Media state for a tab. In reality, more than one of these may apply. See 24 // Media state for a tab. In reality, more than one of these may apply. See
21 // comments for GetTabMediaStateForContents() below. 25 // comments for GetTabMediaStateForContents() below.
22 enum TabMediaState { 26 enum TabMediaState {
23 TAB_MEDIA_STATE_NONE, 27 TAB_MEDIA_STATE_NONE,
24 TAB_MEDIA_STATE_RECORDING, // Audio/Video being recorded, consumed by tab. 28 TAB_MEDIA_STATE_RECORDING, // Audio/Video being recorded, consumed by tab.
25 TAB_MEDIA_STATE_CAPTURING, // Tab contents being captured. 29 TAB_MEDIA_STATE_CAPTURING, // Tab contents being captured.
26 TAB_MEDIA_STATE_AUDIO_PLAYING // Audible audio is playing from the tab. 30 TAB_MEDIA_STATE_AUDIO_PLAYING, // Audible audio is playing from the tab.
31 TAB_MEDIA_STATE_AUDIO_MUTING, // Tab audio is being muted.
27 }; 32 };
28 33
29 namespace chrome { 34 namespace chrome {
30 35
31 // Logic to determine which components (i.e., close button, favicon, and media 36 // Logic to determine which components (i.e., close button, favicon, and media
32 // indicator) of a tab should be shown, given current state. |capacity| 37 // indicator) of a tab should be shown, given current state. |capacity|
33 // specifies how many components can be shown, given available tab width. 38 // specifies how many components can be shown, given available tab width.
34 // 39 //
35 // Precedence rules for deciding what to show when capacity is insufficient to 40 // Precedence rules for deciding what to show when capacity is insufficient to
36 // show everything: 41 // show everything:
(...skipping 23 matching lines...) Expand all
60 65
61 // Returns the media state to be shown by the tab's media indicator. When 66 // Returns the media state to be shown by the tab's media indicator. When
62 // multiple states apply (e.g., tab capture with audio playback), the one most 67 // multiple states apply (e.g., tab capture with audio playback), the one most
63 // relevant to user privacy concerns is selected. 68 // relevant to user privacy concerns is selected.
64 TabMediaState GetTabMediaStateForContents(content::WebContents* contents); 69 TabMediaState GetTabMediaStateForContents(content::WebContents* contents);
65 70
66 // Returns a cached image, to be shown by the media indicator for the given 71 // Returns a cached image, to be shown by the media indicator for the given
67 // |media_state|. Uses the global ui::ResourceBundle shared instance. 72 // |media_state|. Uses the global ui::ResourceBundle shared instance.
68 const gfx::Image& GetTabMediaIndicatorImage(TabMediaState media_state); 73 const gfx::Image& GetTabMediaIndicatorImage(TabMediaState media_state);
69 74
75 // Returns the cached image, to be shown by the media indicator button for mouse
76 // hover/pressed, when the indicator is in the given |media_state|. Uses the
77 // global ui::ResourceBundle shared instance.
78 const gfx::Image& GetTabMediaIndicatorAffordanceImage(
79 TabMediaState media_state);
80
70 // Returns a non-continuous Animation that performs a fade-in or fade-out 81 // Returns a non-continuous Animation that performs a fade-in or fade-out
71 // appropriate for the given |next_media_state|. This is used by the tab media 82 // appropriate for the given |next_media_state|. This is used by the tab media
72 // indicator to alert the user that recording, tab capture, or audio playback 83 // indicator to alert the user that recording, tab capture, or audio playback
73 // has started/stopped. 84 // has started/stopped.
74 scoped_ptr<gfx::Animation> CreateTabMediaIndicatorFadeAnimation( 85 scoped_ptr<gfx::Animation> CreateTabMediaIndicatorFadeAnimation(
75 TabMediaState next_media_state); 86 TabMediaState next_media_state);
76 87
77 // Returns the text to show in a tab's tooltip: The contents |title|, followed 88 // Returns the text to show in a tab's tooltip: The contents |title|, followed
78 // by a break, followed by a localized string describing the |media_state|. 89 // by a break, followed by a localized string describing the |media_state|.
79 base::string16 AssembleTabTooltipText(const base::string16& title, 90 base::string16 AssembleTabTooltipText(const base::string16& title,
80 TabMediaState media_state); 91 TabMediaState media_state);
81 92
93 // Returns true if the experimental tab audio mute feature is enabled.
94 bool IsTabAudioMutingFeatureEnabled();
95
96 // Returns true if audio mute can be activated/deactivated for the given
97 // |contents|.
98 bool CanToggleAudioMute(content::WebContents* contents);
99
100 // Indicates/Sets whether all audio output from |contents| is muted.
101 bool IsTabAudioMuted(content::WebContents* contents);
102 void SetTabAudioMuted(content::WebContents* contents, bool mute);
103
104 // Returns true if the tabs at the |indices| in |tab_strip| are all muted.
105 bool AreAllTabsMuted(const TabStripModel& tab_strip,
106 const std::vector<int>& indices);
107
82 } // namespace chrome 108 } // namespace chrome
83 109
84 #endif // CHROME_BROWSER_UI_TABS_TAB_UTILS_H_ 110 #endif // CHROME_BROWSER_UI_TABS_TAB_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model.cc ('k') | chrome/browser/ui/tabs/tab_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698