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 "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h"
13 } // namespace content
20 // Media state for a tab. In reality, more than one of these may apply. See
21 // comments for GetTabMediaStateForContents() below.
24 TAB_MEDIA_STATE_RECORDING
, // Audio/Video being recorded, consumed by tab.
25 TAB_MEDIA_STATE_CAPTURING
, // Tab contents being captured.
26 TAB_MEDIA_STATE_AUDIO_PLAYING
// Audible audio is playing from the tab.
31 // Logic to determine which components (i.e., close button, favicon, and media
32 // indicator) of a tab should be shown, given current state. |capacity|
33 // specifies how many components can be shown, given available tab width.
35 // Precedence rules for deciding what to show when capacity is insufficient to
38 // Active tab: Always show the close button, then the media indicator, then
40 // Inactive tab: Media indicator, then the favicon, then the close button.
41 // Pinned tab: Show only the media indicator, or only the favicon
42 // (TAB_MEDIA_STATE_NONE). Never show the close button.
43 bool ShouldTabShowFavicon(int capacity
,
47 TabMediaState media_state
);
48 bool ShouldTabShowMediaIndicator(int capacity
,
52 TabMediaState media_state
);
53 bool ShouldTabShowCloseButton(int capacity
,
57 // Returns whether the given |contents| is playing audio. We might choose to
58 // show an audio favicon indicator for this tab.
59 bool IsPlayingAudio(content::WebContents
* contents
);
61 // 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
63 // relevant to user privacy concerns is selected.
64 TabMediaState
GetTabMediaStateForContents(content::WebContents
* contents
);
66 // Returns a cached image, to be shown by the media indicator for the given
67 // |media_state|. Uses the global ui::ResourceBundle shared instance.
68 const gfx::Image
& GetTabMediaIndicatorImage(TabMediaState media_state
);
70 // 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
72 // indicator to alert the user that recording, tab capture, or audio playback
73 // has started/stopped.
74 scoped_ptr
<gfx::Animation
> CreateTabMediaIndicatorFadeAnimation(
75 TabMediaState next_media_state
);
77 // 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|.
79 base::string16
AssembleTabTooltipText(const base::string16
& title
,
80 TabMediaState media_state
);
84 #endif // CHROME_BROWSER_UI_TABS_TAB_UTILS_H_