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

Side by Side 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, 6 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
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 #include "chrome/browser/extensions/api/tabs/tabs_api.h" 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted_memory.h" 14 #include "base/memory/ref_counted_memory.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "chrome/browser/apps/scoped_keep_alive.h" 23 #include "chrome/browser/apps/scoped_keep_alive.h"
23 #include "chrome/browser/chrome_notification_types.h" 24 #include "chrome/browser/chrome_notification_types.h"
24 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 25 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
25 #include "chrome/browser/extensions/api/tabs/windows_util.h" 26 #include "chrome/browser/extensions/api/tabs/windows_util.h"
26 #include "chrome/browser/extensions/extension_service.h" 27 #include "chrome/browser/extensions/extension_service.h"
27 #include "chrome/browser/extensions/extension_tab_util.h" 28 #include "chrome/browser/extensions/extension_tab_util.h"
28 #include "chrome/browser/extensions/tab_helper.h" 29 #include "chrome/browser/extensions/tab_helper.h"
29 #include "chrome/browser/extensions/window_controller.h" 30 #include "chrome/browser/extensions/window_controller.h"
30 #include "chrome/browser/extensions/window_controller_list.h" 31 #include "chrome/browser/extensions/window_controller_list.h"
31 #include "chrome/browser/prefs/incognito_mode_prefs.h" 32 #include "chrome/browser/prefs/incognito_mode_prefs.h"
32 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/sessions/session_tab_helper.h" 34 #include "chrome/browser/sessions/session_tab_helper.h"
34 #include "chrome/browser/translate/chrome_translate_client.h" 35 #include "chrome/browser/translate/chrome_translate_client.h"
35 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 36 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
36 #include "chrome/browser/ui/browser.h" 37 #include "chrome/browser/ui/browser.h"
37 #include "chrome/browser/ui/browser_commands.h" 38 #include "chrome/browser/ui/browser_commands.h"
38 #include "chrome/browser/ui/browser_finder.h" 39 #include "chrome/browser/ui/browser_finder.h"
39 #include "chrome/browser/ui/browser_iterator.h" 40 #include "chrome/browser/ui/browser_iterator.h"
40 #include "chrome/browser/ui/browser_navigator.h" 41 #include "chrome/browser/ui/browser_navigator.h"
41 #include "chrome/browser/ui/browser_tabstrip.h" 42 #include "chrome/browser/ui/browser_tabstrip.h"
42 #include "chrome/browser/ui/browser_window.h" 43 #include "chrome/browser/ui/browser_window.h"
43 #include "chrome/browser/ui/host_desktop.h" 44 #include "chrome/browser/ui/host_desktop.h"
44 #include "chrome/browser/ui/panels/panel_manager.h" 45 #include "chrome/browser/ui/panels/panel_manager.h"
45 #include "chrome/browser/ui/tabs/tab_strip_model.h" 46 #include "chrome/browser/ui/tabs/tab_strip_model.h"
47 #include "chrome/browser/ui/tabs/tab_utils.h"
46 #include "chrome/browser/ui/window_sizer/window_sizer.h" 48 #include "chrome/browser/ui/window_sizer/window_sizer.h"
47 #include "chrome/browser/web_applications/web_app.h" 49 #include "chrome/browser/web_applications/web_app.h"
48 #include "chrome/common/chrome_switches.h" 50 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/extensions/api/tabs.h" 51 #include "chrome/common/extensions/api/tabs.h"
50 #include "chrome/common/extensions/api/windows.h" 52 #include "chrome/common/extensions/api/windows.h"
51 #include "chrome/common/extensions/extension_constants.h" 53 #include "chrome/common/extensions/extension_constants.h"
52 #include "chrome/common/pref_names.h" 54 #include "chrome/common/pref_names.h"
53 #include "chrome/common/url_constants.h" 55 #include "chrome/common/url_constants.h"
54 #include "components/pref_registry/pref_registry_syncable.h" 56 #include "components/pref_registry/pref_registry_syncable.h"
55 #include "components/translate/core/browser/language_state.h" 57 #include "components/translate/core/browser/language_state.h"
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 if (!MatchesBool(params->query_info.active.get(), 903 if (!MatchesBool(params->query_info.active.get(),
902 i == tab_strip->active_index())) { 904 i == tab_strip->active_index())) {
903 continue; 905 continue;
904 } 906 }
905 907
906 if (!MatchesBool(params->query_info.pinned.get(), 908 if (!MatchesBool(params->query_info.pinned.get(),
907 tab_strip->IsTabPinned(i))) { 909 tab_strip->IsTabPinned(i))) {
908 continue; 910 continue;
909 } 911 }
910 912
913 if (!MatchesBool(params->query_info.audible.get(),
914 chrome::IsPlayingAudio(web_contents))) {
915 continue;
916 }
917
918 if (!MatchesBool(params->query_info.muted.get(),
919 chrome::IsTabAudioMuted(web_contents))) {
920 continue;
921 }
922
911 if (!title.empty() && !MatchPattern(web_contents->GetTitle(), 923 if (!title.empty() && !MatchPattern(web_contents->GetTitle(),
912 base::UTF8ToUTF16(title))) 924 base::UTF8ToUTF16(title)))
913 continue; 925 continue;
914 926
915 if (!url_patterns.is_empty() && 927 if (!url_patterns.is_empty() &&
916 !url_patterns.MatchesURL(web_contents->GetURL())) 928 !url_patterns.MatchesURL(web_contents->GetURL()))
917 continue; 929 continue;
918 930
919 if (loading_status_set && loading != web_contents->IsLoading()) 931 if (loading_status_set && loading != web_contents->IsLoading())
920 continue; 932 continue;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 } 1190 }
1179 1191
1180 if (params->update_properties.pinned.get()) { 1192 if (params->update_properties.pinned.get()) {
1181 bool pinned = *params->update_properties.pinned; 1193 bool pinned = *params->update_properties.pinned;
1182 tab_strip->SetTabPinned(tab_index, pinned); 1194 tab_strip->SetTabPinned(tab_index, pinned);
1183 1195
1184 // Update the tab index because it may move when being pinned. 1196 // Update the tab index because it may move when being pinned.
1185 tab_index = tab_strip->GetIndexOfWebContents(contents); 1197 tab_index = tab_strip->GetIndexOfWebContents(contents);
1186 } 1198 }
1187 1199
1200 if (params->update_properties.muted.get()) {
1201 const char* muteSwitch = switches::kEnableTabAudioMuting;
1202 if (base::CommandLine::ForCurrentProcess()->HasSwitch(muteSwitch)) {
not at google - send to devlin 2015/05/28 23:04:42 This check should actually be IsTabAudioMutingFeat
1203 if (!chrome::CanToggleAudioMute(contents)) {
1204 WriteToConsole(
1205 content::CONSOLE_MESSAGE_LEVEL_WARNING,
1206 base::StringPrintf(
1207 "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
1208 } else {
1209 chrome::SetTabAudioMuted(contents, *params->update_properties.muted,
1210 extension()->id());
1211 }
1212 } else {
1213 WriteToConsole(
1214 content::CONSOLE_MESSAGE_LEVEL_WARNING,
1215 base::StringPrintf(
1216 "Failed to update mute state, --%s must be enabled", muteSwitch));
1217 }
1218 }
1219
1188 if (params->update_properties.opener_tab_id.get()) { 1220 if (params->update_properties.opener_tab_id.get()) {
1189 int opener_id = *params->update_properties.opener_tab_id; 1221 int opener_id = *params->update_properties.opener_tab_id;
1190 1222
1191 WebContents* opener_contents = NULL; 1223 WebContents* opener_contents = NULL;
1192 if (!ExtensionTabUtil::GetTabById(opener_id, 1224 if (!ExtensionTabUtil::GetTabById(opener_id,
1193 GetProfile(), 1225 GetProfile(),
1194 include_incognito(), 1226 include_incognito(),
1195 NULL, 1227 NULL,
1196 NULL, 1228 NULL,
1197 &opener_contents, 1229 &opener_contents,
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); 1983 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode();
1952 api::tabs::ZoomSettings zoom_settings; 1984 api::tabs::ZoomSettings zoom_settings;
1953 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); 1985 ZoomModeToZoomSettings(zoom_mode, &zoom_settings);
1954 1986
1955 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 1987 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
1956 SendResponse(true); 1988 SendResponse(true);
1957 return true; 1989 return true;
1958 } 1990 }
1959 1991
1960 } // namespace extensions 1992 } // namespace extensions
OLDNEW
« 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