Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / tabs / tab_utils.h
blob2ca81514a81b2d0486e6534def812969cb610cd2
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_TABS_TAB_UTILS_H_
6 #define CHROME_BROWSER_UI_TABS_TAB_UTILS_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "content/public/browser/web_contents_user_data.h"
15 class TabStripModel;
17 namespace content {
18 class WebContents;
19 } // namespace content
21 namespace gfx {
22 class Animation;
23 class Image;
24 } // namespace gfx
26 // Media state for a tab. In reality, more than one of these may apply. See
27 // comments for GetTabMediaStateForContents() below.
28 enum TabMediaState {
29 TAB_MEDIA_STATE_NONE,
30 TAB_MEDIA_STATE_RECORDING, // Audio/Video being recorded, consumed by tab.
31 TAB_MEDIA_STATE_CAPTURING, // Tab contents being captured.
32 TAB_MEDIA_STATE_AUDIO_PLAYING, // Audible audio is playing from the tab.
33 TAB_MEDIA_STATE_AUDIO_MUTING, // Tab audio is being muted.
36 namespace chrome {
38 // String to indicate reason for muted state change (user, capture, extension
39 // id, or empty string)
40 extern const char kMutedToggleCauseUser[];
41 extern const char kMutedToggleCauseCapture[];
43 // Logic to determine which components (i.e., close button, favicon, and media
44 // indicator) of a tab should be shown, given current state. |capacity|
45 // specifies how many components can be shown, given available tab width.
47 // Precedence rules for deciding what to show when capacity is insufficient to
48 // show everything:
50 // Active tab: Always show the close button, then the media indicator, then
51 // the favicon.
52 // Inactive tab: Media indicator, then the favicon, then the close button.
53 // Pinned tab: Show only the media indicator, or only the favicon
54 // (TAB_MEDIA_STATE_NONE). Never show the close button.
55 bool ShouldTabShowFavicon(int capacity,
56 bool is_pinned_tab,
57 bool is_active_tab,
58 bool has_favicon,
59 TabMediaState media_state);
60 bool ShouldTabShowMediaIndicator(int capacity,
61 bool is_pinned_tab,
62 bool is_active_tab,
63 bool has_favicon,
64 TabMediaState media_state);
65 bool ShouldTabShowCloseButton(int capacity,
66 bool is_pinned_tab,
67 bool is_active_tab);
69 // Returns whether the given |contents| is playing audio. We might choose to
70 // show an audio favicon indicator for this tab.
71 bool IsPlayingAudio(content::WebContents* contents);
73 // Returns the media state to be shown by the tab's media indicator. When
74 // multiple states apply (e.g., tab capture with audio playback), the one most
75 // relevant to user privacy concerns is selected.
76 TabMediaState GetTabMediaStateForContents(content::WebContents* contents);
78 // Returns a cached image, to be shown by the media indicator for the given
79 // |media_state|. Uses the global ui::ResourceBundle shared instance.
80 const gfx::Image& GetTabMediaIndicatorImage(TabMediaState media_state);
82 // Returns the cached image, to be shown by the media indicator button for mouse
83 // hover/pressed, when the indicator is in the given |media_state|. Uses the
84 // global ui::ResourceBundle shared instance.
85 const gfx::Image& GetTabMediaIndicatorAffordanceImage(
86 TabMediaState media_state);
88 // Returns a non-continuous Animation that performs a fade-in or fade-out
89 // appropriate for the given |next_media_state|. This is used by the tab media
90 // indicator to alert the user that recording, tab capture, or audio playback
91 // has started/stopped.
92 scoped_ptr<gfx::Animation> CreateTabMediaIndicatorFadeAnimation(
93 TabMediaState next_media_state);
95 // Returns the text to show in a tab's tooltip: The contents |title|, followed
96 // by a break, followed by a localized string describing the |media_state|.
97 base::string16 AssembleTabTooltipText(const base::string16& title,
98 TabMediaState media_state);
100 // Returns true if the experimental tab audio mute feature is enabled.
101 bool IsTabAudioMutingFeatureEnabled();
103 // Returns true if audio mute can be activated/deactivated for the given
104 // |contents|.
105 bool CanToggleAudioMute(content::WebContents* contents);
107 // Indicates whether all audio output from |contents| is muted.
108 bool IsTabAudioMuted(content::WebContents* contents);
110 // Sets whether all audio output from |contents| is muted.
111 // Cause is extensionid, kMutedToggleCause constant, or empty string
112 void SetTabAudioMuted(content::WebContents* contents,
113 bool mute,
114 const std::string& cause);
116 // Get cause of mute (extensionid, kMutedToggleCause constant, or empty string)
117 const std::string& GetTabAudioMutedCause(content::WebContents* contents);
119 // Returns true if the tabs at the |indices| in |tab_strip| are all muted.
120 bool AreAllTabsMuted(const TabStripModel& tab_strip,
121 const std::vector<int>& indices);
123 } // namespace chrome
125 #endif // CHROME_BROWSER_UI_TABS_TAB_UTILS_H_