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::tab_audio_indicator_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()) | |
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 } |
1067 } | 1084 } |
1068 | 1085 |
1086 // Release any video power save blockers held as video is not visible. | |
1087 video_power_save_blocker_.reset(); | |
miu
2014/09/05 18:20:25
Seems like this should go in the block of code a f
DaleCurtis
2014/09/05 18:30:14
Fair enough, I thought capturing already had its o
miu
2014/09/05 18:44:31
It's a subtle point: It's not *capturing* that has
DaleCurtis
2014/09/05 22:13:35
Done. Did you want to modify IncrementCapturerCoun
miu
2014/09/06 02:50:59
Looks like it already does. IIUC, DecrementCaptur
| |
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() && |
1077 !ShowingInterstitialPage() && | 1097 !ShowingInterstitialPage() && |
1078 !static_cast<RenderViewHostImpl*>( | 1098 !static_cast<RenderViewHostImpl*>( |
(...skipping 1302 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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2992 } | 3017 } |
2993 image_download_map_.erase(id); | 3018 image_download_map_.erase(id); |
2994 } | 3019 } |
2995 | 3020 |
2996 void WebContentsImpl::OnUpdateFaviconURL( | 3021 void WebContentsImpl::OnUpdateFaviconURL( |
2997 const std::vector<FaviconURL>& candidates) { | 3022 const std::vector<FaviconURL>& candidates) { |
2998 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3023 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2999 DidUpdateFaviconURL(candidates)); | 3024 DidUpdateFaviconURL(candidates)); |
3000 } | 3025 } |
3001 | 3026 |
3027 void WebContentsImpl::CreateAudioPowerSaveBlocker() { | |
3028 DCHECK(!audio_power_save_blocker_); | |
3029 audio_power_save_blocker_ = PowerSaveBlocker::Create( | |
3030 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, "Playing Audio"); | |
3031 } | |
3032 | |
3033 void WebContentsImpl::CreateVideoPowerSaveBlocker() { | |
3034 DCHECK(!video_power_save_blocker_); | |
3035 DCHECK(!active_video_players_.empty()); | |
3036 video_power_save_blocker_ = PowerSaveBlocker::Create( | |
3037 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, "Playing Video"); | |
3038 #if defined(OS_ANDROID) | |
3039 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) | |
3040 ->InitDisplaySleepBlocker(GetView()->GetNativeView()); | |
3041 #endif | |
3042 } | |
3043 | |
3044 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { | |
3045 // If there are no more audio players and we don't have audio power level | |
3046 // analysis, release the audio power save blocker here instead of during | |
3047 // NotifyNavigationStateChanged(). | |
3048 if (active_audio_players_.empty() && | |
3049 !AudioStreamMonitor::tab_audio_indicator_available()) { | |
3050 audio_power_save_blocker_.reset(); | |
3051 } | |
3052 | |
3053 // If there are no more video players, clear the video power save blocker. | |
3054 if (active_video_players_.empty()) | |
3055 video_power_save_blocker_.reset(); | |
3056 } | |
3057 | |
3002 void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie, | 3058 void WebContentsImpl::OnMediaPlayingNotification(int64 player_cookie, |
3003 bool has_video, | 3059 bool has_video, |
3004 bool has_audio) { | 3060 bool has_audio) { |
3005 #if !defined(OS_CHROMEOS) | 3061 #if !defined(OS_CHROMEOS) |
3006 scoped_ptr<PowerSaveBlocker> blocker; | 3062 if (has_audio) { |
3007 if (has_video) { | 3063 AddMediaPlayerEntry(player_cookie, &active_audio_players_); |
3008 blocker = PowerSaveBlocker::Create( | 3064 |
3009 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, "Playing video"); | 3065 // If we don't have audio power level analysis, allocate the audio power |
3010 #if defined(OS_ANDROID) | 3066 // save blocker here instead of during NotifyNavigationStateChanged(). |
3011 static_cast<PowerSaveBlockerImpl*>(blocker.get()) | 3067 if (!audio_power_save_blocker_ && |
3012 ->InitDisplaySleepBlocker(GetView()->GetNativeView()); | 3068 !AudioStreamMonitor::tab_audio_indicator_available()) { |
3013 #endif | 3069 CreateAudioPowerSaveBlocker(); |
3014 } else if (has_audio) { | 3070 } |
3015 blocker = PowerSaveBlocker::Create( | |
3016 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, "Playing audio"); | |
3017 } | 3071 } |
3018 | 3072 |
3019 if (blocker) { | 3073 if (has_video) { |
3020 uintptr_t key = reinterpret_cast<uintptr_t>(render_frame_message_source_); | 3074 AddMediaPlayerEntry(player_cookie, &active_video_players_); |
3021 if (!power_save_blockers_.contains(key)) { | 3075 |
3022 power_save_blockers_.add(key, | 3076 // If we're not hidden and just created a video player, create a blocker. |
3023 make_scoped_ptr(new PowerSaveBlockerMapEntry)); | 3077 if (!video_power_save_blocker_ && !IsHidden()) |
3024 } | 3078 CreateVideoPowerSaveBlocker(); |
3025 PowerSaveBlockerMapEntry* map_entry = | |
3026 power_save_blockers_.get(key); | |
3027 map_entry->set(player_cookie, blocker.Pass()); | |
3028 } | 3079 } |
3029 #endif // !defined(OS_CHROMEOS) | 3080 #endif // !defined(OS_CHROMEOS) |
3030 } | 3081 } |
3031 | 3082 |
3032 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { | 3083 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { |
3033 #if !defined(OS_CHROMEOS) | 3084 #if !defined(OS_CHROMEOS) |
3034 uintptr_t key = reinterpret_cast<uintptr_t>(render_frame_message_source_); | 3085 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); |
3035 PowerSaveBlockerMapEntry* map_entry = power_save_blockers_.get(key); | 3086 RemoveMediaPlayerEntry(player_cookie, &active_video_players_); |
3036 if (map_entry) | 3087 MaybeReleasePowerSaveBlockers(); |
3037 map_entry->erase(player_cookie); | |
3038 #endif // !defined(OS_CHROMEOS) | 3088 #endif // !defined(OS_CHROMEOS) |
3039 } | 3089 } |
3040 | 3090 |
3041 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { | 3091 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { |
3042 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3092 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3043 DidFirstVisuallyNonEmptyPaint()); | 3093 DidFirstVisuallyNonEmptyPaint()); |
3044 } | 3094 } |
3045 | 3095 |
3046 void WebContentsImpl::DidChangeVisibleSSLState() { | 3096 void WebContentsImpl::DidChangeVisibleSSLState() { |
3047 if (delegate_) | 3097 if (delegate_) |
3048 delegate_->VisibleSSLStateChanged(this); | 3098 delegate_->VisibleSSLStateChanged(this); |
3049 } | 3099 } |
3050 | 3100 |
3051 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { | 3101 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { |
3052 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3102 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3053 BeforeFormRepostWarningShow()); | 3103 BeforeFormRepostWarningShow()); |
3054 } | 3104 } |
3055 | 3105 |
3056 | |
3057 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { | 3106 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { |
3058 Activate(); | 3107 Activate(); |
3059 if (delegate_) | 3108 if (delegate_) |
3060 delegate_->ShowRepostFormWarningDialog(this); | 3109 delegate_->ShowRepostFormWarningDialog(this); |
3061 } | 3110 } |
3062 | 3111 |
3063 bool WebContentsImpl::HasAccessedInitialDocument() { | 3112 bool WebContentsImpl::HasAccessedInitialDocument() { |
3064 return has_accessed_initial_document_; | 3113 return has_accessed_initial_document_; |
3065 } | 3114 } |
3066 | 3115 |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4196 browser_plugin_guest_.reset(guest); | 4245 browser_plugin_guest_.reset(guest); |
4197 } | 4246 } |
4198 | 4247 |
4199 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { | 4248 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { |
4200 return browser_plugin_embedder_.get(); | 4249 return browser_plugin_embedder_.get(); |
4201 } | 4250 } |
4202 | 4251 |
4203 void WebContentsImpl::ClearPowerSaveBlockers( | 4252 void WebContentsImpl::ClearPowerSaveBlockers( |
4204 RenderFrameHost* render_frame_host) { | 4253 RenderFrameHost* render_frame_host) { |
4205 #if !defined(OS_CHROMEOS) | 4254 #if !defined(OS_CHROMEOS) |
4206 uintptr_t key = reinterpret_cast<uintptr_t>(render_frame_host); | 4255 RemoveAllMediaPlayerEntries(render_frame_host, &active_audio_players_); |
4207 scoped_ptr<PowerSaveBlockerMapEntry> map_entry = | 4256 RemoveAllMediaPlayerEntries(render_frame_host, &active_video_players_); |
4208 power_save_blockers_.take_and_erase(key); | 4257 MaybeReleasePowerSaveBlockers(); |
4209 if (map_entry) | |
4210 map_entry->clear(); | |
4211 #endif | 4258 #endif |
4212 } | 4259 } |
4213 | 4260 |
4214 void WebContentsImpl::ClearAllPowerSaveBlockers() { | 4261 void WebContentsImpl::ClearAllPowerSaveBlockers() { |
4215 #if !defined(OS_CHROMEOS) | 4262 #if !defined(OS_CHROMEOS) |
4216 power_save_blockers_.clear(); | 4263 active_audio_players_.clear(); |
4264 active_video_players_.clear(); | |
4265 audio_power_save_blocker_.reset(); | |
4266 video_power_save_blocker_.reset(); | |
4217 #endif | 4267 #endif |
4218 } | 4268 } |
4219 | 4269 |
4220 gfx::Size WebContentsImpl::GetSizeForNewRenderView() { | 4270 gfx::Size WebContentsImpl::GetSizeForNewRenderView() { |
4221 gfx::Size size; | 4271 gfx::Size size; |
4222 if (delegate_) | 4272 if (delegate_) |
4223 size = delegate_->GetSizeForNewRenderView(this); | 4273 size = delegate_->GetSizeForNewRenderView(this); |
4224 if (size.IsEmpty()) | 4274 if (size.IsEmpty()) |
4225 size = GetContainerBounds().size(); | 4275 size = GetContainerBounds().size(); |
4226 return size; | 4276 return size; |
4227 } | 4277 } |
4228 | 4278 |
4229 void WebContentsImpl::OnFrameRemoved(RenderFrameHost* render_frame_host) { | 4279 void WebContentsImpl::OnFrameRemoved(RenderFrameHost* render_frame_host) { |
4230 FOR_EACH_OBSERVER( | 4280 FOR_EACH_OBSERVER( |
4231 WebContentsObserver, observers_, FrameDetached(render_frame_host)); | 4281 WebContentsObserver, observers_, FrameDetached(render_frame_host)); |
4232 } | 4282 } |
4233 | 4283 |
4234 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 4284 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
4235 if (!delegate_) | 4285 if (!delegate_) |
4236 return; | 4286 return; |
4237 const gfx::Size new_size = GetPreferredSize(); | 4287 const gfx::Size new_size = GetPreferredSize(); |
4238 if (new_size != old_size) | 4288 if (new_size != old_size) |
4239 delegate_->UpdatePreferredSize(this, new_size); | 4289 delegate_->UpdatePreferredSize(this, new_size); |
4240 } | 4290 } |
4241 | 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 | |
4242 void WebContentsImpl::ResumeResponseDeferredAtStart() { | 4331 void WebContentsImpl::ResumeResponseDeferredAtStart() { |
4243 FrameTreeNode* node = frame_tree_.root(); | 4332 FrameTreeNode* node = frame_tree_.root(); |
4244 node->render_manager()->ResumeResponseDeferredAtStart(); | 4333 node->render_manager()->ResumeResponseDeferredAtStart(); |
4245 } | 4334 } |
4246 | 4335 |
4247 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4336 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4248 force_disable_overscroll_content_ = force_disable; | 4337 force_disable_overscroll_content_ = force_disable; |
4249 if (view_) | 4338 if (view_) |
4250 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4339 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4251 } | 4340 } |
4252 | 4341 |
4253 } // namespace content | 4342 } // namespace content |
OLD | NEW |