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

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

Issue 1215713021: Reverted the code for the non-interactive audible tab notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification
Patch Set: Fixed indent Created 5 years, 3 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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 #include "ui/gfx/screen.h" 113 #include "ui/gfx/screen.h"
114 #include "ui/gl/gl_switches.h" 114 #include "ui/gl/gl_switches.h"
115 115
116 #if defined(ENABLE_BROWSER_CDMS) 116 #if defined(ENABLE_BROWSER_CDMS)
117 #include "content/browser/media/media_web_contents_observer.h" 117 #include "content/browser/media/media_web_contents_observer.h"
118 #endif 118 #endif
119 119
120 #if defined(OS_ANDROID) 120 #if defined(OS_ANDROID)
121 #include "content/browser/android/content_video_view.h" 121 #include "content/browser/android/content_video_view.h"
122 #include "content/browser/android/date_time_chooser_android.h" 122 #include "content/browser/android/date_time_chooser_android.h"
123 #include "content/browser/android/media_players_observer.h"
124 #include "content/browser/media/android/media_session.h" 123 #include "content/browser/media/android/media_session.h"
125 #include "content/browser/web_contents/web_contents_android.h" 124 #include "content/browser/web_contents/web_contents_android.h"
126 #endif 125 #endif
127 126
128 #if defined(OS_MACOSX) 127 #if defined(OS_MACOSX)
129 #include "base/mac/foundation_util.h" 128 #include "base/mac/foundation_util.h"
130 #endif 129 #endif
131 130
132 namespace content { 131 namespace content {
133 namespace { 132 namespace {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 render_view_message_source_(NULL), 395 render_view_message_source_(NULL),
397 render_frame_message_source_(NULL), 396 render_frame_message_source_(NULL),
398 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 397 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
399 fullscreen_widget_had_focus_at_shutdown_(false), 398 fullscreen_widget_had_focus_at_shutdown_(false),
400 is_subframe_(false), 399 is_subframe_(false),
401 force_disable_overscroll_content_(false), 400 force_disable_overscroll_content_(false),
402 last_dialog_suppressed_(false), 401 last_dialog_suppressed_(false),
403 geolocation_service_context_(new GeolocationServiceContext()), 402 geolocation_service_context_(new GeolocationServiceContext()),
404 accessibility_mode_( 403 accessibility_mode_(
405 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), 404 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
405 audio_stream_monitor_(this),
406 virtual_keyboard_requested_(false), 406 virtual_keyboard_requested_(false),
407 loading_weak_factory_(this) { 407 loading_weak_factory_(this) {
408 frame_tree_.SetFrameRemoveListener( 408 frame_tree_.SetFrameRemoveListener(
409 base::Bind(&WebContentsImpl::OnFrameRemoved, 409 base::Bind(&WebContentsImpl::OnFrameRemoved,
410 base::Unretained(this))); 410 base::Unretained(this)));
411 #if defined(ENABLE_BROWSER_CDMS) 411 #if defined(ENABLE_BROWSER_CDMS)
412 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); 412 media_web_contents_observer_.reset(new MediaWebContentsObserver(this));
413 #endif 413 #endif
414
415 #if defined(OS_ANDROID)
416 audio_state_provider_.reset(new MediaPlayersObserver(this));
417 #else
418 audio_state_provider_.reset(new AudioStreamMonitor(this));
419 #endif
420 } 414 }
421 415
422 WebContentsImpl::~WebContentsImpl() { 416 WebContentsImpl::~WebContentsImpl() {
423 is_being_destroyed_ = true; 417 is_being_destroyed_ = true;
424 418
425 // Delete all RFH pending shutdown, which will lead the corresponding RVH to 419 // Delete all RFH pending shutdown, which will lead the corresponding RVH to
426 // shutdown and be deleted as well. 420 // shutdown and be deleted as well.
427 frame_tree_.ForEach( 421 frame_tree_.ForEach(
428 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown)); 422 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown));
429 423
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 void WebContentsImpl::NotifyNavigationStateChanged( 1144 void WebContentsImpl::NotifyNavigationStateChanged(
1151 InvalidateTypes changed_flags) { 1145 InvalidateTypes changed_flags) {
1152 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285 1146 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466285
1153 // is fixed. 1147 // is fixed.
1154 tracked_objects::ScopedTracker tracking_profile( 1148 tracked_objects::ScopedTracker tracking_profile(
1155 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1149 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1156 "466285 WebContentsImpl::NotifyNavigationStateChanged")); 1150 "466285 WebContentsImpl::NotifyNavigationStateChanged"));
1157 // Create and release the audio power save blocker depending on whether the 1151 // Create and release the audio power save blocker depending on whether the
1158 // tab is actively producing audio or not. 1152 // tab is actively producing audio or not.
1159 if ((changed_flags & INVALIDATE_TYPE_TAB) && 1153 if ((changed_flags & INVALIDATE_TYPE_TAB) &&
1160 audio_state_provider_->IsAudioStateAvailable()) { 1154 AudioStreamMonitor::monitoring_available()) {
1161 if (WasRecentlyAudible()) { 1155 if (WasRecentlyAudible()) {
1162 if (!audio_power_save_blocker_) 1156 if (!audio_power_save_blocker_)
1163 CreateAudioPowerSaveBlocker(); 1157 CreateAudioPowerSaveBlocker();
1164 } else { 1158 } else {
1165 audio_power_save_blocker_.reset(); 1159 audio_power_save_blocker_.reset();
1166 } 1160 }
1167 } 1161 }
1168 1162
1169 if (delegate_) 1163 if (delegate_)
1170 delegate_->NavigationStateChanged(this, changed_flags); 1164 delegate_->NavigationStateChanged(this, changed_flags);
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 } 2721 }
2728 Send(new ViewMsg_StopFinding(GetRoutingID(), action)); 2722 Send(new ViewMsg_StopFinding(GetRoutingID(), action));
2729 } 2723 }
2730 2724
2731 void WebContentsImpl::InsertCSS(const std::string& css) { 2725 void WebContentsImpl::InsertCSS(const std::string& css) {
2732 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( 2726 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest(
2733 GetMainFrame()->GetRoutingID(), css)); 2727 GetMainFrame()->GetRoutingID(), css));
2734 } 2728 }
2735 2729
2736 bool WebContentsImpl::WasRecentlyAudible() { 2730 bool WebContentsImpl::WasRecentlyAudible() {
2737 return audio_state_provider_->WasRecentlyAudible(); 2731 return audio_stream_monitor_.WasRecentlyAudible();
2738 } 2732 }
2739 2733
2740 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) { 2734 void WebContentsImpl::GetManifest(const GetManifestCallback& callback) {
2741 manifest_manager_host_->GetManifest(GetMainFrame(), callback); 2735 manifest_manager_host_->GetManifest(GetMainFrame(), callback);
2742 } 2736 }
2743 2737
2744 void WebContentsImpl::ExitFullscreen() { 2738 void WebContentsImpl::ExitFullscreen() {
2745 // Clean up related state and initiate the fullscreen exit. 2739 // Clean up related state and initiate the fullscreen exit.
2746 GetRenderViewHost()->RejectMouseLockOrUnlockIfNecessary(); 2740 GetRenderViewHost()->RejectMouseLockOrUnlockIfNecessary();
2747 ExitFullscreenMode(); 2741 ExitFullscreenMode();
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) 3330 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get())
3337 ->InitDisplaySleepBlocker(this); 3331 ->InitDisplaySleepBlocker(this);
3338 #endif 3332 #endif
3339 } 3333 }
3340 3334
3341 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { 3335 void WebContentsImpl::MaybeReleasePowerSaveBlockers() {
3342 // If there are no more audio players and we don't have audio stream 3336 // If there are no more audio players and we don't have audio stream
3343 // monitoring, release the audio power save blocker here instead of during 3337 // monitoring, release the audio power save blocker here instead of during
3344 // NotifyNavigationStateChanged(). 3338 // NotifyNavigationStateChanged().
3345 if (active_audio_players_.empty() && 3339 if (active_audio_players_.empty() &&
3346 !audio_state_provider_->IsAudioStateAvailable()) { 3340 !AudioStreamMonitor::monitoring_available()) {
3347 audio_power_save_blocker_.reset(); 3341 audio_power_save_blocker_.reset();
3348 } 3342 }
3349 3343
3350 // If there are no more video players, clear the video power save blocker. 3344 // If there are no more video players, clear the video power save blocker.
3351 if (active_video_players_.empty()) 3345 if (active_video_players_.empty())
3352 video_power_save_blocker_.reset(); 3346 video_power_save_blocker_.reset();
3353 } 3347 }
3354 3348
3355 void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie, 3349 void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie,
3356 bool has_video, 3350 bool has_video,
3357 bool has_audio, 3351 bool has_audio,
3358 bool is_remote) { 3352 bool is_remote) {
3359 // Ignore the videos playing remotely and don't hold the wake lock for the 3353 // Ignore the videos playing remotely and don't hold the wake lock for the
3360 // screen. 3354 // screen.
3361 if (is_remote) return; 3355 if (is_remote) return;
3362 3356
3363 if (has_audio) { 3357 if (has_audio) {
3364 AddMediaPlayerEntry(player_cookie, &active_audio_players_); 3358 AddMediaPlayerEntry(player_cookie, &active_audio_players_);
3365 3359
3366 // If we don't have audio stream monitoring, allocate the audio power save 3360 // If we don't have audio stream monitoring, allocate the audio power save
3367 // blocker here instead of during NotifyNavigationStateChanged(). 3361 // blocker here instead of during NotifyNavigationStateChanged().
3368 if (!audio_power_save_blocker_ && 3362 if (!audio_power_save_blocker_ &&
3369 !audio_state_provider_->IsAudioStateAvailable()) { 3363 !AudioStreamMonitor::monitoring_available()) {
3370 CreateAudioPowerSaveBlocker(); 3364 CreateAudioPowerSaveBlocker();
3371 } 3365 }
3372 } 3366 }
3373 3367
3374 if (has_video) { 3368 if (has_video) {
3375 AddMediaPlayerEntry(player_cookie, &active_video_players_); 3369 AddMediaPlayerEntry(player_cookie, &active_video_players_);
3376 3370
3377 // If we're not hidden and have just created a player, create a blocker. 3371 // If we're not hidden and have just created a player, create a blocker.
3378 if (!video_power_save_blocker_ && !IsHidden()) 3372 if (!video_power_save_blocker_ && !IsHidden())
3379 CreateVideoPowerSaveBlocker(); 3373 CreateVideoPowerSaveBlocker();
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
4615 player_map->erase(it); 4609 player_map->erase(it);
4616 } 4610 }
4617 4611
4618 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4612 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4619 force_disable_overscroll_content_ = force_disable; 4613 force_disable_overscroll_content_ = force_disable;
4620 if (view_) 4614 if (view_)
4621 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4615 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4622 } 4616 }
4623 4617
4624 } // namespace content 4618 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698