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