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

Side by Side Diff: content/browser/web_contents/web_contents_impl.h

Issue 896673003: Propagate audible state from player to the containing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed implementation of nativeIsPlayingAudio() Created 5 years, 9 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 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/containers/scoped_ptr_hash_map.h" 13 #include "base/containers/scoped_ptr_hash_map.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/process/process.h" 17 #include "base/process/process.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "content/browser/frame_host/frame_tree.h" 19 #include "content/browser/frame_host/frame_tree.h"
20 #include "content/browser/frame_host/navigation_controller_delegate.h" 20 #include "content/browser/frame_host/navigation_controller_delegate.h"
21 #include "content/browser/frame_host/navigation_controller_impl.h" 21 #include "content/browser/frame_host/navigation_controller_impl.h"
22 #include "content/browser/frame_host/navigator_delegate.h" 22 #include "content/browser/frame_host/navigator_delegate.h"
23 #include "content/browser/frame_host/render_frame_host_delegate.h" 23 #include "content/browser/frame_host/render_frame_host_delegate.h"
24 #include "content/browser/frame_host/render_frame_host_manager.h" 24 #include "content/browser/frame_host/render_frame_host_manager.h"
25 #include "content/browser/media/audio_stream_monitor.h" 25 #include "content/browser/media/audio_state_provider.h"
26 #include "content/browser/renderer_host/render_view_host_delegate.h" 26 #include "content/browser/renderer_host/render_view_host_delegate.h"
27 #include "content/browser/renderer_host/render_widget_host_delegate.h" 27 #include "content/browser/renderer_host/render_widget_host_delegate.h"
28 #include "content/common/accessibility_mode_enums.h" 28 #include "content/common/accessibility_mode_enums.h"
29 #include "content/common/content_export.h" 29 #include "content/common/content_export.h"
30 #include "content/public/browser/color_chooser.h" 30 #include "content/public/browser/color_chooser.h"
31 #include "content/public/browser/notification_observer.h" 31 #include "content/public/browser/notification_observer.h"
32 #include "content/public/browser/notification_registrar.h" 32 #include "content/public/browser/notification_registrar.h"
33 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
34 #include "content/public/common/renderer_preferences.h" 34 #include "content/public/common/renderer_preferences.h"
35 #include "content/public/common/resource_type.h" 35 #include "content/public/common/resource_type.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // javascript: URLs that load into the DOMWindow before the first page 133 // javascript: URLs that load into the DOMWindow before the first page
134 // load. This is not safe to do in any context that a web page could get a 134 // load. This is not safe to do in any context that a web page could get a
135 // reference to the DOMWindow before the first page load. 135 // reference to the DOMWindow before the first page load.
136 bool CreateRenderViewForInitialEmptyDocument(); 136 bool CreateRenderViewForInitialEmptyDocument();
137 #endif 137 #endif
138 138
139 // Expose the render manager for testing. 139 // Expose the render manager for testing.
140 // TODO(creis): Remove this now that we can get to it via FrameTreeNode. 140 // TODO(creis): Remove this now that we can get to it via FrameTreeNode.
141 RenderFrameHostManager* GetRenderManagerForTesting(); 141 RenderFrameHostManager* GetRenderManagerForTesting();
142 142
143 // Lets the test replace the audio state provider. Takes ownership over
144 // provider. This is used to test AudioStreamMonitor on Android where
145 // we normaly don't do monitoring.
146 void SetAudioStateProviderForTesting(AudioStateProvider* provider);
no sievers 2015/03/02 20:21:24 If you pass a scoped_ptr<> you don't need to comme
Tima Vaisburd 2015/03/02 21:03:03 Yes, I will happily disable AudioStreamMonitor tes
Tima Vaisburd 2015/03/02 22:16:10 Excluded in .gypi
147
143 // Returns guest browser plugin object, or NULL if this WebContents is not a 148 // Returns guest browser plugin object, or NULL if this WebContents is not a
144 // guest. 149 // guest.
145 BrowserPluginGuest* GetBrowserPluginGuest() const; 150 BrowserPluginGuest* GetBrowserPluginGuest() const;
146 151
147 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents 152 // Sets a BrowserPluginGuest object for this WebContents. If this WebContents
148 // has a BrowserPluginGuest then that implies that it is being hosted by 153 // has a BrowserPluginGuest then that implies that it is being hosted by
149 // a BrowserPlugin object in an embedder renderer process. 154 // a BrowserPlugin object in an embedder renderer process.
150 void SetBrowserPluginGuest(BrowserPluginGuest* guest); 155 void SetBrowserPluginGuest(BrowserPluginGuest* guest);
151 156
152 // Returns embedder browser plugin object, or NULL if this WebContents is not 157 // Returns embedder browser plugin object, or NULL if this WebContents is not
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // currently focused frame. 664 // currently focused frame.
660 void SelectRange(const gfx::Point& base, const gfx::Point& extent); 665 void SelectRange(const gfx::Point& base, const gfx::Point& extent);
661 666
662 // Notifies the main frame that it can continue navigation (if it was deferred 667 // Notifies the main frame that it can continue navigation (if it was deferred
663 // immediately at first response). 668 // immediately at first response).
664 void ResumeResponseDeferredAtStart(); 669 void ResumeResponseDeferredAtStart();
665 670
666 // Forces overscroll to be disabled (used by touch emulation). 671 // Forces overscroll to be disabled (used by touch emulation).
667 void SetForceDisableOverscrollContent(bool force_disable); 672 void SetForceDisableOverscrollContent(bool force_disable);
668 673
669 AudioStreamMonitor* audio_stream_monitor() { 674 AudioStateProvider* audio_state_provider() {
670 return &audio_stream_monitor_; 675 return audio_state_provider_.get();
671 } 676 }
672 677
673 bool has_audio_power_save_blocker_for_testing() const { 678 bool has_audio_power_save_blocker_for_testing() const {
674 return audio_power_save_blocker_; 679 return audio_power_save_blocker_;
675 } 680 }
676 681
677 bool has_video_power_save_blocker_for_testing() const { 682 bool has_video_power_save_blocker_for_testing() const {
678 return video_power_save_blocker_; 683 return video_power_save_blocker_;
679 } 684 }
680 685
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 #endif 1020 #endif
1016 1021
1017 // Helper classes ------------------------------------------------------------ 1022 // Helper classes ------------------------------------------------------------
1018 1023
1019 // Tracking variables and associated power save blockers for media playback. 1024 // Tracking variables and associated power save blockers for media playback.
1020 ActiveMediaPlayerMap active_audio_players_; 1025 ActiveMediaPlayerMap active_audio_players_;
1021 ActiveMediaPlayerMap active_video_players_; 1026 ActiveMediaPlayerMap active_video_players_;
1022 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; 1027 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_;
1023 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; 1028 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_;
1024 1029
1030 // Tells whether this WebContents is actively producing sound.
1031 // Order is important: the |frame_tree_| destruction uses
1032 // |audio_state_provider_|.
1033 scoped_ptr<AudioStateProvider> audio_state_provider_;
1034
1025 // Manages the frame tree of the page and process swaps in each node. 1035 // Manages the frame tree of the page and process swaps in each node.
1026 FrameTree frame_tree_; 1036 FrameTree frame_tree_;
1027 1037
1028 // SavePackage, lazily created. 1038 // SavePackage, lazily created.
1029 scoped_refptr<SavePackage> save_package_; 1039 scoped_refptr<SavePackage> save_package_;
1030 1040
1031 // Data for loading state ---------------------------------------------------- 1041 // Data for loading state ----------------------------------------------------
1032 1042
1033 // Indicates whether we're currently loading a resource. 1043 // Indicates whether we're currently loading a resource.
1034 bool is_loading_; 1044 bool is_loading_;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1239
1230 scoped_ptr<ScreenOrientationDispatcherHost> 1240 scoped_ptr<ScreenOrientationDispatcherHost>
1231 screen_orientation_dispatcher_host_; 1241 screen_orientation_dispatcher_host_;
1232 1242
1233 scoped_ptr<ManifestManagerHost> manifest_manager_host_; 1243 scoped_ptr<ManifestManagerHost> manifest_manager_host_;
1234 1244
1235 // The accessibility mode for all frames. This is queried when each frame 1245 // The accessibility mode for all frames. This is queried when each frame
1236 // is created, and broadcast to all frames when it changes. 1246 // is created, and broadcast to all frames when it changes.
1237 AccessibilityMode accessibility_mode_; 1247 AccessibilityMode accessibility_mode_;
1238 1248
1239 // Monitors power levels for audio streams associated with this WebContents.
1240 AudioStreamMonitor audio_stream_monitor_;
1241
1242 // Created on-demand to mute all audio output from this WebContents. 1249 // Created on-demand to mute all audio output from this WebContents.
1243 scoped_ptr<WebContentsAudioMuter> audio_muter_; 1250 scoped_ptr<WebContentsAudioMuter> audio_muter_;
1244 1251
1245 bool virtual_keyboard_requested_; 1252 bool virtual_keyboard_requested_;
1246 1253
1247 #if defined(ENABLE_BROWSER_CDMS) 1254 #if defined(ENABLE_BROWSER_CDMS)
1248 // Manages all the media player and CDM managers and forwards IPCs to them. 1255 // Manages all the media player and CDM managers and forwards IPCs to them.
1249 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_; 1256 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_;
1250 #endif 1257 #endif
1251 1258
(...skipping 15 matching lines...) Expand all
1267 // Adds/removes a callback called on creation of each new WebContents. 1274 // Adds/removes a callback called on creation of each new WebContents.
1268 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); 1275 static void AddCreatedCallbackForTesting(const CreatedCallback& callback);
1269 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); 1276 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback);
1270 1277
1271 DISALLOW_COPY_AND_ASSIGN(FriendZone); 1278 DISALLOW_COPY_AND_ASSIGN(FriendZone);
1272 }; 1279 };
1273 1280
1274 } // namespace content 1281 } // namespace content
1275 1282
1276 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ 1283 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698