Chromium Code Reviews| Index: chrome/browser/ui/tabs/tab_utils.h |
| diff --git a/chrome/browser/ui/tabs/tab_utils.h b/chrome/browser/ui/tabs/tab_utils.h |
| index 2ca81514a81b2d0486e6534def812969cb610cd2..99cb42f1690d570b6f63154895ef1f58948a898d 100644 |
| --- a/chrome/browser/ui/tabs/tab_utils.h |
| +++ b/chrome/browser/ui/tabs/tab_utils.h |
| @@ -7,7 +7,7 @@ |
| #include <string> |
| #include <vector> |
| - |
| +#include "base/containers/hash_tables.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/strings/string16.h" |
| #include "content/public/browser/web_contents_user_data.h" |
| @@ -33,6 +33,13 @@ enum TabMediaState { |
| TAB_MEDIA_STATE_AUDIO_MUTING, // Tab audio is being muted. |
| }; |
| +enum TabMutedResult { |
| + TAB_MUTED_RESULT_SUCCESS, |
| + TAB_MUTED_RESULT_FAIL_NOT_ENABLED, |
| + TAB_MUTED_RESULT_FAIL_TABCAPTURE, |
| + TAB_MUTED_RESULT_FAIL_RATE_LIMITED, |
| +}; |
| + |
| namespace chrome { |
| // String to indicate reason for muted state change (user, capture, extension |
| @@ -40,6 +47,11 @@ namespace chrome { |
| extern const char kMutedToggleCauseUser[]; |
| extern const char kMutedToggleCauseCapture[]; |
| +// Constants for rate limiting mute updating by extensions |
| +extern const int kMuteTokenBucketCostSeconds = 15; |
|
miu
2015/07/16 00:28:26
style nit: Assignment of the constant needs to be
|
| +extern const int kMuteTokenBucketCapacitySeconds = |
| + 3 * kMuteTokenBucketCostSeconds; |
| + |
| // Logic to determine which components (i.e., close button, favicon, and media |
| // indicator) of a tab should be shown, given current state. |capacity| |
| // specifies how many components can be shown, given available tab width. |
| @@ -104,18 +116,24 @@ bool IsTabAudioMutingFeatureEnabled(); |
| // |contents|. |
| bool CanToggleAudioMute(content::WebContents* contents); |
| +// Returns true if extension-driven muting is rate limited for a tab |
| +bool IsTabAudioMutedRateLimited(content::WebContents* contents); |
| + |
| // Indicates whether all audio output from |contents| is muted. |
| bool IsTabAudioMuted(content::WebContents* contents); |
| // Sets whether all audio output from |contents| is muted. |
| // Cause is extensionid, kMutedToggleCause constant, or empty string |
| -void SetTabAudioMuted(content::WebContents* contents, |
| - bool mute, |
| - const std::string& cause); |
| +TabMutedResult SetTabAudioMuted(content::WebContents* contents, |
| + bool mute, |
| + const std::string& cause); |
| // Get cause of mute (extensionid, kMutedToggleCause constant, or empty string) |
| const std::string& GetTabAudioMutedCause(content::WebContents* contents); |
| +// Update token buckets for rate limiting muting using elapsed time |
| +void updateTokenBuckets(content::WebContents* contents); |
|
miu
2015/07/16 00:28:26
Also, don't declare this function in the header fi
miu
2015/07/16 00:28:26
style: The "u" in updateTokenBuckets needs to be c
|
| + |
| // Returns true if the tabs at the |indices| in |tab_strip| are all muted. |
| bool AreAllTabsMuted(const TabStripModel& tab_strip, |
| const std::vector<int>& indices); |