OLD | NEW |
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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "content/browser/download/save_package.h" | 31 #include "content/browser/download/save_package.h" |
32 #include "content/browser/frame_host/cross_process_frame_connector.h" | 32 #include "content/browser/frame_host/cross_process_frame_connector.h" |
33 #include "content/browser/frame_host/interstitial_page_impl.h" | 33 #include "content/browser/frame_host/interstitial_page_impl.h" |
34 #include "content/browser/frame_host/navigation_entry_impl.h" | 34 #include "content/browser/frame_host/navigation_entry_impl.h" |
35 #include "content/browser/frame_host/navigator_impl.h" | 35 #include "content/browser/frame_host/navigator_impl.h" |
36 #include "content/browser/frame_host/render_frame_host_impl.h" | 36 #include "content/browser/frame_host/render_frame_host_impl.h" |
37 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 37 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
38 #include "content/browser/geolocation/geolocation_dispatcher_host.h" | 38 #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
39 #include "content/browser/host_zoom_map_impl.h" | 39 #include "content/browser/host_zoom_map_impl.h" |
40 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 40 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 41 #include "content/browser/media/audio_stream_monitor.h" |
41 #include "content/browser/media/midi_dispatcher_host.h" | 42 #include "content/browser/media/midi_dispatcher_host.h" |
42 #include "content/browser/message_port_message_filter.h" | 43 #include "content/browser/message_port_message_filter.h" |
43 #include "content/browser/message_port_service.h" | 44 #include "content/browser/message_port_service.h" |
44 #include "content/browser/power_save_blocker_impl.h" | 45 #include "content/browser/power_save_blocker_impl.h" |
45 #include "content/browser/renderer_host/render_process_host_impl.h" | 46 #include "content/browser/renderer_host/render_process_host_impl.h" |
46 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 47 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
47 #include "content/browser/renderer_host/render_view_host_impl.h" | 48 #include "content/browser/renderer_host/render_view_host_impl.h" |
48 #include "content/browser/renderer_host/render_widget_host_impl.h" | 49 #include "content/browser/renderer_host/render_widget_host_impl.h" |
49 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 50 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
50 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.
h" | 51 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host.
h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 370 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
370 totalPinchGestureAmount_(0), | 371 totalPinchGestureAmount_(0), |
371 currentPinchZoomStepDelta_(0), | 372 currentPinchZoomStepDelta_(0), |
372 render_view_message_source_(NULL), | 373 render_view_message_source_(NULL), |
373 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), | 374 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), |
374 fullscreen_widget_had_focus_at_shutdown_(false), | 375 fullscreen_widget_had_focus_at_shutdown_(false), |
375 is_subframe_(false), | 376 is_subframe_(false), |
376 force_disable_overscroll_content_(false), | 377 force_disable_overscroll_content_(false), |
377 last_dialog_suppressed_(false), | 378 last_dialog_suppressed_(false), |
378 accessibility_mode_( | 379 accessibility_mode_( |
379 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()) { | 380 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
| 381 audio_stream_monitor_(this) { |
380 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 382 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
381 g_created_callbacks.Get().at(i).Run(this); | 383 g_created_callbacks.Get().at(i).Run(this); |
382 frame_tree_.SetFrameRemoveListener( | 384 frame_tree_.SetFrameRemoveListener( |
383 base::Bind(&WebContentsImpl::OnFrameRemoved, | 385 base::Bind(&WebContentsImpl::OnFrameRemoved, |
384 base::Unretained(this))); | 386 base::Unretained(this))); |
385 } | 387 } |
386 | 388 |
387 WebContentsImpl::~WebContentsImpl() { | 389 WebContentsImpl::~WebContentsImpl() { |
388 is_being_destroyed_ = true; | 390 is_being_destroyed_ = true; |
389 | 391 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 base::TerminationStatus WebContentsImpl::GetCrashedStatus() const { | 1004 base::TerminationStatus WebContentsImpl::GetCrashedStatus() const { |
1003 return crashed_status_; | 1005 return crashed_status_; |
1004 } | 1006 } |
1005 | 1007 |
1006 bool WebContentsImpl::IsBeingDestroyed() const { | 1008 bool WebContentsImpl::IsBeingDestroyed() const { |
1007 return is_being_destroyed_; | 1009 return is_being_destroyed_; |
1008 } | 1010 } |
1009 | 1011 |
1010 void WebContentsImpl::NotifyNavigationStateChanged( | 1012 void WebContentsImpl::NotifyNavigationStateChanged( |
1011 InvalidateTypes changed_flags) { | 1013 InvalidateTypes changed_flags) { |
| 1014 // Create and release the audio power save blocker depending on whether the |
| 1015 // tab is actively producing audio or not. |
| 1016 if (changed_flags == INVALIDATE_TYPE_TAB && |
| 1017 AudioStreamMonitor::monitoring_available()) { |
| 1018 if (WasRecentlyAudible()) { |
| 1019 if (!audio_power_save_blocker_) |
| 1020 CreateAudioPowerSaveBlocker(); |
| 1021 } else { |
| 1022 audio_power_save_blocker_.reset(); |
| 1023 } |
| 1024 } |
| 1025 |
1012 if (delegate_) | 1026 if (delegate_) |
1013 delegate_->NavigationStateChanged(this, changed_flags); | 1027 delegate_->NavigationStateChanged(this, changed_flags); |
1014 } | 1028 } |
1015 | 1029 |
1016 base::TimeTicks WebContentsImpl::GetLastActiveTime() const { | 1030 base::TimeTicks WebContentsImpl::GetLastActiveTime() const { |
1017 return last_active_time_; | 1031 return last_active_time_; |
1018 } | 1032 } |
1019 | 1033 |
1020 void WebContentsImpl::WasShown() { | 1034 void WebContentsImpl::WasShown() { |
1021 controller_.SetActive(true); | 1035 controller_.SetActive(true); |
(...skipping 13 matching lines...) Expand all Loading... |
1035 last_active_time_ = base::TimeTicks::Now(); | 1049 last_active_time_ = base::TimeTicks::Now(); |
1036 | 1050 |
1037 // The resize rect might have changed while this was inactive -- send the new | 1051 // The resize rect might have changed while this was inactive -- send the new |
1038 // one to make sure it's up to date. | 1052 // one to make sure it's up to date. |
1039 RenderViewHostImpl* rvh = | 1053 RenderViewHostImpl* rvh = |
1040 static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 1054 static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
1041 if (rvh) { | 1055 if (rvh) { |
1042 rvh->ResizeRectChanged(GetRootWindowResizerRect()); | 1056 rvh->ResizeRectChanged(GetRootWindowResizerRect()); |
1043 } | 1057 } |
1044 | 1058 |
| 1059 // Restore power save blocker if there are active video players running. |
| 1060 if (!active_video_players_.empty() && !video_power_save_blocker_) |
| 1061 CreateVideoPowerSaveBlocker(); |
| 1062 |
1045 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); | 1063 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); |
1046 | 1064 |
1047 should_normally_be_visible_ = true; | 1065 should_normally_be_visible_ = true; |
1048 } | 1066 } |
1049 | 1067 |
1050 void WebContentsImpl::WasHidden() { | 1068 void WebContentsImpl::WasHidden() { |
1051 // If there are entities capturing screenshots or video (e.g., mirroring), | 1069 // If there are entities capturing screenshots or video (e.g., mirroring), |
1052 // don't activate the "disable rendering" optimization. | 1070 // don't activate the "disable rendering" optimization. |
1053 if (capturer_count_ == 0) { | 1071 if (capturer_count_ == 0) { |
1054 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 1072 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
1055 // open a tab in the background, then closes the tab before selecting it. | 1073 // open a tab in the background, then closes the tab before selecting it. |
1056 // This is because closing the tab calls WebContentsImpl::Destroy(), which | 1074 // This is because closing the tab calls WebContentsImpl::Destroy(), which |
1057 // removes the |GetRenderViewHost()|; then when we actually destroy the | 1075 // removes the |GetRenderViewHost()|; then when we actually destroy the |
1058 // window, OnWindowPosChanged() notices and calls WasHidden() (which | 1076 // window, OnWindowPosChanged() notices and calls WasHidden() (which |
1059 // calls us). | 1077 // calls us). |
1060 std::set<RenderWidgetHostView*> widgets = GetRenderWidgetHostViewsInTree(); | 1078 std::set<RenderWidgetHostView*> widgets = GetRenderWidgetHostViewsInTree(); |
1061 for (std::set<RenderWidgetHostView*>::iterator iter = widgets.begin(); | 1079 for (std::set<RenderWidgetHostView*>::iterator iter = widgets.begin(); |
1062 iter != widgets.end(); | 1080 iter != widgets.end(); |
1063 iter++) { | 1081 iter++) { |
1064 if (*iter) | 1082 if (*iter) |
1065 (*iter)->Hide(); | 1083 (*iter)->Hide(); |
1066 } | 1084 } |
| 1085 |
| 1086 // Release any video power save blockers held as video is not visible. |
| 1087 video_power_save_blocker_.reset(); |
1067 } | 1088 } |
1068 | 1089 |
1069 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); | 1090 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); |
1070 | 1091 |
1071 should_normally_be_visible_ = false; | 1092 should_normally_be_visible_ = false; |
1072 } | 1093 } |
1073 | 1094 |
1074 bool WebContentsImpl::NeedToFireBeforeUnload() { | 1095 bool WebContentsImpl::NeedToFireBeforeUnload() { |
1075 // TODO(creis): Should we fire even for interstitial pages? | 1096 // TODO(creis): Should we fire even for interstitial pages? |
1076 return WillNotifyDisconnection() && | 1097 return WillNotifyDisconnection() && |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 | 2402 |
2382 void WebContentsImpl::StopFinding(StopFindAction action) { | 2403 void WebContentsImpl::StopFinding(StopFindAction action) { |
2383 Send(new ViewMsg_StopFinding(GetRoutingID(), action)); | 2404 Send(new ViewMsg_StopFinding(GetRoutingID(), action)); |
2384 } | 2405 } |
2385 | 2406 |
2386 void WebContentsImpl::InsertCSS(const std::string& css) { | 2407 void WebContentsImpl::InsertCSS(const std::string& css) { |
2387 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( | 2408 GetMainFrame()->Send(new FrameMsg_CSSInsertRequest( |
2388 GetMainFrame()->GetRoutingID(), css)); | 2409 GetMainFrame()->GetRoutingID(), css)); |
2389 } | 2410 } |
2390 | 2411 |
| 2412 bool WebContentsImpl::WasRecentlyAudible() { |
| 2413 return audio_stream_monitor_.WasRecentlyAudible(); |
| 2414 } |
| 2415 |
2391 bool WebContentsImpl::FocusLocationBarByDefault() { | 2416 bool WebContentsImpl::FocusLocationBarByDefault() { |
2392 NavigationEntry* entry = controller_.GetVisibleEntry(); | 2417 NavigationEntry* entry = controller_.GetVisibleEntry(); |
2393 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL)) | 2418 if (entry && entry->GetURL() == GURL(url::kAboutBlankURL)) |
2394 return true; | 2419 return true; |
2395 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); | 2420 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); |
2396 } | 2421 } |
2397 | 2422 |
2398 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 2423 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
2399 if (delegate_) | 2424 if (delegate_) |
2400 delegate_->SetFocusToLocationBar(select_all); | 2425 delegate_->SetFocusToLocationBar(select_all); |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2994 } | 3019 } |
2995 image_download_map_.erase(id); | 3020 image_download_map_.erase(id); |
2996 } | 3021 } |
2997 | 3022 |
2998 void WebContentsImpl::OnUpdateFaviconURL( | 3023 void WebContentsImpl::OnUpdateFaviconURL( |
2999 const std::vector<FaviconURL>& candidates) { | 3024 const std::vector<FaviconURL>& candidates) { |
3000 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3025 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3001 DidUpdateFaviconURL(candidates)); | 3026 DidUpdateFaviconURL(candidates)); |
3002 } | 3027 } |
3003 | 3028 |
| 3029 void WebContentsImpl::CreateAudioPowerSaveBlocker() { |
| 3030 // ChromeOS has its own way of handling power save blocks for media. |
| 3031 #if !defined(OS_CHROMEOS) |
| 3032 DCHECK(!audio_power_save_blocker_); |
| 3033 audio_power_save_blocker_ = PowerSaveBlocker::Create( |
| 3034 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, "Playing Audio"); |
| 3035 #endif |
| 3036 } |
| 3037 |
| 3038 void WebContentsImpl::CreateVideoPowerSaveBlocker() { |
| 3039 // ChromeOS has its own way of handling power save blocks for media. |
| 3040 #if !defined(OS_CHROMEOS) |
| 3041 DCHECK(!video_power_save_blocker_); |
| 3042 DCHECK(!active_video_players_.empty()); |
| 3043 video_power_save_blocker_ = PowerSaveBlocker::Create( |
| 3044 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, "Playing Video"); |
| 3045 #if defined(OS_ANDROID) |
| 3046 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) |
| 3047 ->InitDisplaySleepBlocker(GetView()->GetNativeView()); |
| 3048 #endif |
| 3049 #endif |
| 3050 } |
| 3051 |
| 3052 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { |
| 3053 // If there are no more audio players and we don't have audio stream |
| 3054 // monitoring, release the audio power save blocker here instead of during |
| 3055 // NotifyNavigationStateChanged(). |
| 3056 if (active_audio_players_.empty() && |
| 3057 !AudioStreamMonitor::monitoring_available()) { |
| 3058 audio_power_save_blocker_.reset(); |
| 3059 } |
| 3060 |
| 3061 // If there are no more video players, clear the video power save blocker. |
| 3062 if (active_video_players_.empty()) |
| 3063 video_power_save_blocker_.reset(); |
| 3064 } |
| 3065 |
3004 void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie, | 3066 void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie, |
3005 bool has_video, | 3067 bool has_video, |
3006 bool has_audio) { | 3068 bool has_audio) { |
3007 #if !defined(OS_CHROMEOS) | 3069 if (has_audio) { |
3008 scoped_ptr<PowerSaveBlocker> blocker; | 3070 AddMediaPlayerEntry(player_cookie, &active_audio_players_); |
3009 if (has_video) { | 3071 |
3010 blocker = PowerSaveBlocker::Create( | 3072 // If we don't have audio stream monitoring, allocate the audio power save |
3011 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, "Playing video"); | 3073 // blocker here instead of during NotifyNavigationStateChanged(). |
3012 #if defined(OS_ANDROID) | 3074 if (!audio_power_save_blocker_ && |
3013 static_cast<PowerSaveBlockerImpl*>(blocker.get()) | 3075 !AudioStreamMonitor::monitoring_available()) { |
3014 ->InitDisplaySleepBlocker(GetView()->GetNativeView()); | 3076 CreateAudioPowerSaveBlocker(); |
3015 #endif | 3077 } |
3016 } else if (has_audio) { | |
3017 blocker = PowerSaveBlocker::Create( | |
3018 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, "Playing audio"); | |
3019 } | 3078 } |
3020 | 3079 |
3021 if (blocker) { | 3080 if (has_video) { |
3022 uintptr_t key = reinterpret_cast<uintptr_t>(render_frame_message_source_); | 3081 AddMediaPlayerEntry(player_cookie, &active_video_players_); |
3023 if (!power_save_blockers_.contains(key)) { | 3082 |
3024 power_save_blockers_.add(key, | 3083 // If we're not hidden and have just created a player, create a blocker. |
3025 make_scoped_ptr(new PowerSaveBlockerMapEntry)); | 3084 if (!video_power_save_blocker_ && !IsHidden()) |
3026 } | 3085 CreateVideoPowerSaveBlocker(); |
3027 PowerSaveBlockerMapEntry* map_entry = | |
3028 power_save_blockers_.get(key); | |
3029 map_entry->set(player_cookie, blocker.Pass()); | |
3030 } | 3086 } |
3031 #endif // !defined(OS_CHROMEOS) | |
3032 } | 3087 } |
3033 | 3088 |
3034 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { | 3089 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { |
3035 #if !defined(OS_CHROMEOS) | 3090 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); |
3036 uintptr_t key = reinterpret_cast<uintptr_t>(render_frame_message_source_); | 3091 RemoveMediaPlayerEntry(player_cookie, &active_video_players_); |
3037 PowerSaveBlockerMapEntry* map_entry = power_save_blockers_.get(key); | 3092 MaybeReleasePowerSaveBlockers(); |
3038 if (map_entry) | |
3039 map_entry->erase(player_cookie); | |
3040 #endif // !defined(OS_CHROMEOS) | |
3041 } | 3093 } |
3042 | 3094 |
3043 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { | 3095 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { |
3044 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3096 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3045 DidFirstVisuallyNonEmptyPaint()); | 3097 DidFirstVisuallyNonEmptyPaint()); |
3046 } | 3098 } |
3047 | 3099 |
3048 void WebContentsImpl::DidChangeVisibleSSLState() { | 3100 void WebContentsImpl::DidChangeVisibleSSLState() { |
3049 if (delegate_) | 3101 if (delegate_) |
3050 delegate_->VisibleSSLStateChanged(this); | 3102 delegate_->VisibleSSLStateChanged(this); |
3051 } | 3103 } |
3052 | 3104 |
3053 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { | 3105 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { |
3054 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3106 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3055 BeforeFormRepostWarningShow()); | 3107 BeforeFormRepostWarningShow()); |
3056 } | 3108 } |
3057 | 3109 |
3058 | |
3059 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { | 3110 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { |
3060 Activate(); | 3111 Activate(); |
3061 if (delegate_) | 3112 if (delegate_) |
3062 delegate_->ShowRepostFormWarningDialog(this); | 3113 delegate_->ShowRepostFormWarningDialog(this); |
3063 } | 3114 } |
3064 | 3115 |
3065 bool WebContentsImpl::HasAccessedInitialDocument() { | 3116 bool WebContentsImpl::HasAccessedInitialDocument() { |
3066 return has_accessed_initial_document_; | 3117 return has_accessed_initial_document_; |
3067 } | 3118 } |
3068 | 3119 |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4197 CHECK(!browser_plugin_guest_); | 4248 CHECK(!browser_plugin_guest_); |
4198 browser_plugin_guest_.reset(guest); | 4249 browser_plugin_guest_.reset(guest); |
4199 } | 4250 } |
4200 | 4251 |
4201 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { | 4252 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { |
4202 return browser_plugin_embedder_.get(); | 4253 return browser_plugin_embedder_.get(); |
4203 } | 4254 } |
4204 | 4255 |
4205 void WebContentsImpl::ClearPowerSaveBlockers( | 4256 void WebContentsImpl::ClearPowerSaveBlockers( |
4206 RenderFrameHost* render_frame_host) { | 4257 RenderFrameHost* render_frame_host) { |
4207 #if !defined(OS_CHROMEOS) | 4258 RemoveAllMediaPlayerEntries(render_frame_host, &active_audio_players_); |
4208 uintptr_t key = reinterpret_cast<uintptr_t>(render_frame_host); | 4259 RemoveAllMediaPlayerEntries(render_frame_host, &active_video_players_); |
4209 scoped_ptr<PowerSaveBlockerMapEntry> map_entry = | 4260 MaybeReleasePowerSaveBlockers(); |
4210 power_save_blockers_.take_and_erase(key); | |
4211 if (map_entry) | |
4212 map_entry->clear(); | |
4213 #endif | |
4214 } | 4261 } |
4215 | 4262 |
4216 void WebContentsImpl::ClearAllPowerSaveBlockers() { | 4263 void WebContentsImpl::ClearAllPowerSaveBlockers() { |
4217 #if !defined(OS_CHROMEOS) | 4264 active_audio_players_.clear(); |
4218 power_save_blockers_.clear(); | 4265 active_video_players_.clear(); |
4219 #endif | 4266 audio_power_save_blocker_.reset(); |
| 4267 video_power_save_blocker_.reset(); |
4220 } | 4268 } |
4221 | 4269 |
4222 gfx::Size WebContentsImpl::GetSizeForNewRenderView() { | 4270 gfx::Size WebContentsImpl::GetSizeForNewRenderView() { |
4223 gfx::Size size; | 4271 gfx::Size size; |
4224 if (delegate_) | 4272 if (delegate_) |
4225 size = delegate_->GetSizeForNewRenderView(this); | 4273 size = delegate_->GetSizeForNewRenderView(this); |
4226 if (size.IsEmpty()) | 4274 if (size.IsEmpty()) |
4227 size = GetContainerBounds().size(); | 4275 size = GetContainerBounds().size(); |
4228 return size; | 4276 return size; |
4229 } | 4277 } |
4230 | 4278 |
4231 void WebContentsImpl::OnFrameRemoved(RenderFrameHost* render_frame_host) { | 4279 void WebContentsImpl::OnFrameRemoved(RenderFrameHost* render_frame_host) { |
4232 FOR_EACH_OBSERVER( | 4280 FOR_EACH_OBSERVER( |
4233 WebContentsObserver, observers_, FrameDetached(render_frame_host)); | 4281 WebContentsObserver, observers_, FrameDetached(render_frame_host)); |
4234 } | 4282 } |
4235 | 4283 |
4236 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 4284 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
4237 if (!delegate_) | 4285 if (!delegate_) |
4238 return; | 4286 return; |
4239 const gfx::Size new_size = GetPreferredSize(); | 4287 const gfx::Size new_size = GetPreferredSize(); |
4240 if (new_size != old_size) | 4288 if (new_size != old_size) |
4241 delegate_->UpdatePreferredSize(this, new_size); | 4289 delegate_->UpdatePreferredSize(this, new_size); |
4242 } | 4290 } |
4243 | 4291 |
| 4292 void WebContentsImpl::AddMediaPlayerEntry(int64 player_cookie, |
| 4293 ActiveMediaPlayerMap* player_map) { |
| 4294 const uintptr_t key = |
| 4295 reinterpret_cast<uintptr_t>(render_frame_message_source_); |
| 4296 DCHECK(std::find((*player_map)[key].begin(), |
| 4297 (*player_map)[key].end(), |
| 4298 player_cookie) == (*player_map)[key].end()); |
| 4299 (*player_map)[key].push_back(player_cookie); |
| 4300 } |
| 4301 |
| 4302 void WebContentsImpl::RemoveMediaPlayerEntry(int64 player_cookie, |
| 4303 ActiveMediaPlayerMap* player_map) { |
| 4304 const uintptr_t key = |
| 4305 reinterpret_cast<uintptr_t>(render_frame_message_source_); |
| 4306 ActiveMediaPlayerMap::iterator it = player_map->find(key); |
| 4307 if (it == player_map->end()) |
| 4308 return; |
| 4309 |
| 4310 // Remove the player. |
| 4311 PlayerList::iterator player_it = |
| 4312 std::find(it->second.begin(), it->second.end(), player_cookie); |
| 4313 if (player_it != it->second.end()) |
| 4314 it->second.erase(player_it); |
| 4315 |
| 4316 // If there are no players left, remove the map entry. |
| 4317 if (it->second.empty()) |
| 4318 player_map->erase(it); |
| 4319 } |
| 4320 |
| 4321 void WebContentsImpl::RemoveAllMediaPlayerEntries( |
| 4322 RenderFrameHost* render_frame_host, |
| 4323 ActiveMediaPlayerMap* player_map) { |
| 4324 ActiveMediaPlayerMap::iterator it = |
| 4325 player_map->find(reinterpret_cast<uintptr_t>(render_frame_host)); |
| 4326 if (it == player_map->end()) |
| 4327 return; |
| 4328 player_map->erase(it); |
| 4329 } |
| 4330 |
4244 void WebContentsImpl::ResumeResponseDeferredAtStart() { | 4331 void WebContentsImpl::ResumeResponseDeferredAtStart() { |
4245 FrameTreeNode* node = frame_tree_.root(); | 4332 FrameTreeNode* node = frame_tree_.root(); |
4246 node->render_manager()->ResumeResponseDeferredAtStart(); | 4333 node->render_manager()->ResumeResponseDeferredAtStart(); |
4247 } | 4334 } |
4248 | 4335 |
4249 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4336 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4250 force_disable_overscroll_content_ = force_disable; | 4337 force_disable_overscroll_content_ = force_disable; |
4251 if (view_) | 4338 if (view_) |
4252 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4339 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4253 } | 4340 } |
4254 | 4341 |
4255 } // namespace content | 4342 } // namespace content |
OLD | NEW |