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