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

Unified Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 987583004: Add audible, muted to Tab, c.t.query, c.t.update, and c.t.onUpdated where relevant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch1
Patch Set: header file order fixed Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/tabs/tabs_api.cc
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 4816da7e0687d8ce20a9b3f0af4717c47edc2252..746ff17647570c987ff199daa49d8958a175f8b6 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -18,6 +18,7 @@
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/apps/scoped_keep_alive.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -43,6 +44,7 @@
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/tabs/tab_utils.h"
#include "chrome/browser/ui/window_sizer/window_sizer.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
@@ -908,6 +910,16 @@ bool TabsQueryFunction::RunSync() {
continue;
}
+ if (!MatchesBool(params->query_info.audible.get(),
+ chrome::IsPlayingAudio(web_contents))) {
+ continue;
+ }
+
+ if (!MatchesBool(params->query_info.muted.get(),
+ chrome::IsTabAudioMuted(web_contents))) {
+ continue;
+ }
+
if (!title.empty() && !MatchPattern(web_contents->GetTitle(),
base::UTF8ToUTF16(title)))
continue;
@@ -1185,6 +1197,26 @@ bool TabsUpdateFunction::RunAsync() {
tab_index = tab_strip->GetIndexOfWebContents(contents);
}
+ if (params->update_properties.muted.get()) {
+ const char* muteSwitch = switches::kEnableTabAudioMuting;
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(muteSwitch)) {
not at google - send to devlin 2015/05/28 23:04:42 This check should actually be IsTabAudioMutingFeat
+ if (!chrome::CanToggleAudioMute(contents)) {
+ WriteToConsole(
+ content::CONSOLE_MESSAGE_LEVEL_WARNING,
+ base::StringPrintf(
+ "Cannot update mute state for tab being captured"));
not at google - send to devlin 2015/05/28 23:04:42 It's polite to mention the tab ID, also, better de
+ } else {
+ chrome::SetTabAudioMuted(contents, *params->update_properties.muted,
+ extension()->id());
+ }
+ } else {
+ WriteToConsole(
+ content::CONSOLE_MESSAGE_LEVEL_WARNING,
+ base::StringPrintf(
+ "Failed to update mute state, --%s must be enabled", muteSwitch));
+ }
+ }
+
if (params->update_properties.opener_tab_id.get()) {
int opener_id = *params->update_properties.opener_tab_id;
« no previous file with comments | « chrome/browser/extensions/api/tab_capture/tab_capture_apitest.cc ('k') | chrome/browser/extensions/api/tabs/tabs_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698