Chromium Code Reviews| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 #include "third_party/skia/include/core/SkBitmap.h" | 110 #include "third_party/skia/include/core/SkBitmap.h" |
| 111 #include "ui/base/layout.h" | 111 #include "ui/base/layout.h" |
| 112 #include "ui/gfx/display.h" | 112 #include "ui/gfx/display.h" |
| 113 #include "ui/gfx/screen.h" | 113 #include "ui/gfx/screen.h" |
| 114 #include "ui/gl/gl_switches.h" | 114 #include "ui/gl/gl_switches.h" |
| 115 | 115 |
| 116 #if defined(ENABLE_BROWSER_CDMS) | 116 #if defined(ENABLE_BROWSER_CDMS) |
| 117 #include "content/browser/media/media_web_contents_observer.h" | 117 #include "content/browser/media/media_web_contents_observer.h" |
| 118 #endif | 118 #endif |
| 119 | 119 |
| 120 #if defined(OS_ANDROID) | 120 #if defined(OS_ANDROID) &&!defined(USE_AURA) |
| 121 #include "content/browser/android/content_video_view.h" | 121 #include "content/browser/android/content_video_view.h" |
| 122 #include "content/browser/android/date_time_chooser_android.h" | 122 #include "content/browser/android/date_time_chooser_android.h" |
| 123 #include "content/browser/android/media_players_observer.h" | 123 #include "content/browser/android/media_players_observer.h" |
| 124 #include "content/browser/media/android/media_session.h" | 124 #include "content/browser/media/android/media_session.h" |
| 125 #include "content/browser/web_contents/web_contents_android.h" | 125 #include "content/browser/web_contents/web_contents_android.h" |
| 126 #endif | 126 #endif |
| 127 | 127 |
| 128 #if defined(OS_MACOSX) | 128 #if defined(OS_MACOSX) |
| 129 #include "base/mac/foundation_util.h" | 129 #include "base/mac/foundation_util.h" |
| 130 #endif | 130 #endif |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), | 405 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), |
| 406 virtual_keyboard_requested_(false), | 406 virtual_keyboard_requested_(false), |
| 407 loading_weak_factory_(this) { | 407 loading_weak_factory_(this) { |
| 408 frame_tree_.SetFrameRemoveListener( | 408 frame_tree_.SetFrameRemoveListener( |
| 409 base::Bind(&WebContentsImpl::OnFrameRemoved, | 409 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 410 base::Unretained(this))); | 410 base::Unretained(this))); |
| 411 #if defined(ENABLE_BROWSER_CDMS) | 411 #if defined(ENABLE_BROWSER_CDMS) |
| 412 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); | 412 media_web_contents_observer_.reset(new MediaWebContentsObserver(this)); |
| 413 #endif | 413 #endif |
| 414 | 414 |
| 415 #if defined(OS_ANDROID) | 415 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 416 audio_state_provider_.reset(new MediaPlayersObserver(this)); | 416 audio_state_provider_.reset(new MediaPlayersObserver(this)); |
|
no sievers
2015/10/20 19:24:22
use the android one
| |
| 417 #else | 417 #else |
| 418 audio_state_provider_.reset(new AudioStreamMonitor(this)); | 418 audio_state_provider_.reset(new AudioStreamMonitor(this)); |
| 419 #endif | 419 #endif |
| 420 } | 420 } |
| 421 | 421 |
| 422 WebContentsImpl::~WebContentsImpl() { | 422 WebContentsImpl::~WebContentsImpl() { |
| 423 is_being_destroyed_ = true; | 423 is_being_destroyed_ = true; |
| 424 | 424 |
| 425 // Delete all RFH pending shutdown, which will lead the corresponding RVH to | 425 // Delete all RFH pending shutdown, which will lead the corresponding RVH to |
| 426 // shutdown and be deleted as well. | 426 // shutdown and be deleted as well. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 OnBrowserPluginMessage(render_frame_host, | 653 OnBrowserPluginMessage(render_frame_host, |
| 654 message)) | 654 message)) |
| 655 #endif | 655 #endif |
| 656 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 656 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
| 657 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | 657 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, |
| 658 OnShowValidationMessage) | 658 OnShowValidationMessage) |
| 659 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | 659 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
| 660 OnHideValidationMessage) | 660 OnHideValidationMessage) |
| 661 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | 661 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, |
| 662 OnMoveValidationMessage) | 662 OnMoveValidationMessage) |
| 663 #if defined(OS_ANDROID) | 663 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 664 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 664 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
| 665 OnFindMatchRectsReply) | 665 OnFindMatchRectsReply) |
| 666 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | 666 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, |
| 667 OnOpenDateTimeDialog) | 667 OnOpenDateTimeDialog) |
| 668 #endif | 668 #endif |
| 669 IPC_MESSAGE_UNHANDLED(handled = false) | 669 IPC_MESSAGE_UNHANDLED(handled = false) |
| 670 IPC_END_MESSAGE_MAP() | 670 IPC_END_MESSAGE_MAP() |
| 671 render_view_message_source_ = NULL; | 671 render_view_message_source_ = NULL; |
| 672 render_frame_message_source_ = NULL; | 672 render_frame_message_source_ = NULL; |
| 673 | 673 |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1382 | 1382 |
| 1383 registrar_.Add(this, | 1383 registrar_.Add(this, |
| 1384 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1384 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1385 NotificationService::AllBrowserContextsAndSources()); | 1385 NotificationService::AllBrowserContextsAndSources()); |
| 1386 | 1386 |
| 1387 screen_orientation_dispatcher_host_.reset( | 1387 screen_orientation_dispatcher_host_.reset( |
| 1388 new ScreenOrientationDispatcherHostImpl(this)); | 1388 new ScreenOrientationDispatcherHostImpl(this)); |
| 1389 | 1389 |
| 1390 manifest_manager_host_.reset(new ManifestManagerHost(this)); | 1390 manifest_manager_host_.reset(new ManifestManagerHost(this)); |
| 1391 | 1391 |
| 1392 #if defined(OS_ANDROID) | 1392 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 1393 date_time_chooser_.reset(new DateTimeChooserAndroid()); | 1393 date_time_chooser_.reset(new DateTimeChooserAndroid()); |
| 1394 #endif | 1394 #endif |
| 1395 | 1395 |
| 1396 // BrowserPluginGuest::Init needs to be called after this WebContents has | 1396 // BrowserPluginGuest::Init needs to be called after this WebContents has |
| 1397 // a RenderWidgetHostViewGuest. That is, |view_->CreateView| above. | 1397 // a RenderWidgetHostViewGuest. That is, |view_->CreateView| above. |
| 1398 if (browser_plugin_guest_) | 1398 if (browser_plugin_guest_) |
| 1399 browser_plugin_guest_->Init(); | 1399 browser_plugin_guest_->Init(); |
| 1400 | 1400 |
| 1401 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 1401 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
| 1402 g_created_callbacks.Get().at(i).Run(this); | 1402 g_created_callbacks.Get().at(i).Run(this); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1589 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab())); | 1589 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab())); |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 void WebContentsImpl::ExitFullscreenMode() { | 1592 void WebContentsImpl::ExitFullscreenMode() { |
| 1593 // This method is being called to leave renderer-initiated fullscreen mode. | 1593 // This method is being called to leave renderer-initiated fullscreen mode. |
| 1594 // Make sure any existing fullscreen widget is shut down first. | 1594 // Make sure any existing fullscreen widget is shut down first. |
| 1595 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1595 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
| 1596 if (widget_view) | 1596 if (widget_view) |
| 1597 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); | 1597 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown(); |
| 1598 | 1598 |
| 1599 #if defined(OS_ANDROID) | 1599 #if defined(OS_ANDROID) && !defined(USE_AURA) |
|
no sievers
2015/10/20 19:24:22
TODO: fullscreen video bug
| |
| 1600 ContentVideoView* video_view = ContentVideoView::GetInstance(); | 1600 ContentVideoView* video_view = ContentVideoView::GetInstance(); |
| 1601 if (video_view != NULL) | 1601 if (video_view != NULL) |
| 1602 video_view->OnExitFullscreen(); | 1602 video_view->OnExitFullscreen(); |
| 1603 #endif | 1603 #endif |
| 1604 | 1604 |
| 1605 if (delegate_) | 1605 if (delegate_) |
| 1606 delegate_->ExitFullscreenModeForTab(this); | 1606 delegate_->ExitFullscreenModeForTab(this); |
| 1607 | 1607 |
| 1608 // Ensure web contents exit fullscreen state by sending a resize message, | 1608 // Ensure web contents exit fullscreen state by sending a resize message, |
| 1609 // which includes the fullscreen state. This is required for the situation | 1609 // which includes the fullscreen state. This is required for the situation |
| (...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3162 int number_of_matches, | 3162 int number_of_matches, |
| 3163 const gfx::Rect& selection_rect, | 3163 const gfx::Rect& selection_rect, |
| 3164 int active_match_ordinal, | 3164 int active_match_ordinal, |
| 3165 bool final_update) { | 3165 bool final_update) { |
| 3166 if (delegate_) { | 3166 if (delegate_) { |
| 3167 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | 3167 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, |
| 3168 active_match_ordinal, final_update); | 3168 active_match_ordinal, final_update); |
| 3169 } | 3169 } |
| 3170 } | 3170 } |
| 3171 | 3171 |
| 3172 #if defined(OS_ANDROID) | 3172 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 3173 void WebContentsImpl::OnFindMatchRectsReply( | 3173 void WebContentsImpl::OnFindMatchRectsReply( |
| 3174 int version, | 3174 int version, |
| 3175 const std::vector<gfx::RectF>& rects, | 3175 const std::vector<gfx::RectF>& rects, |
| 3176 const gfx::RectF& active_rect) { | 3176 const gfx::RectF& active_rect) { |
| 3177 if (delegate_) | 3177 if (delegate_) |
| 3178 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 3178 delegate_->FindMatchRectsReply(this, version, rects, active_rect); |
| 3179 } | 3179 } |
| 3180 | 3180 |
| 3181 void WebContentsImpl::OnOpenDateTimeDialog( | 3181 void WebContentsImpl::OnOpenDateTimeDialog( |
| 3182 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 3182 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3327 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 3327 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
| 3328 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); | 3328 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); |
| 3329 } | 3329 } |
| 3330 | 3330 |
| 3331 void WebContentsImpl::CreateVideoPowerSaveBlocker() { | 3331 void WebContentsImpl::CreateVideoPowerSaveBlocker() { |
| 3332 DCHECK(!video_power_save_blocker_); | 3332 DCHECK(!video_power_save_blocker_); |
| 3333 DCHECK(!active_video_players_.empty()); | 3333 DCHECK(!active_video_players_.empty()); |
| 3334 video_power_save_blocker_ = PowerSaveBlocker::Create( | 3334 video_power_save_blocker_ = PowerSaveBlocker::Create( |
| 3335 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 3335 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 3336 PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); | 3336 PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); |
| 3337 #if defined(OS_ANDROID) | 3337 #if defined(OS_ANDROID) &&!defined(USE_AURA) |
| 3338 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) | 3338 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) |
| 3339 ->InitDisplaySleepBlocker(this); | 3339 ->InitDisplaySleepBlocker(this); |
| 3340 #endif | 3340 #endif |
| 3341 } | 3341 } |
| 3342 | 3342 |
| 3343 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { | 3343 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { |
| 3344 // If there are no more audio players and we don't have audio stream | 3344 // If there are no more audio players and we don't have audio stream |
| 3345 // monitoring, release the audio power save blocker here instead of during | 3345 // monitoring, release the audio power save blocker here instead of during |
| 3346 // NotifyNavigationStateChanged(). | 3346 // NotifyNavigationStateChanged(). |
| 3347 if (active_audio_players_.empty() && | 3347 if (active_audio_players_.empty() && |
| 3348 !audio_state_provider_->IsAudioStateAvailable()) { | 3348 !audio_state_provider_->IsAudioStateAvailable()) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3385 } | 3385 } |
| 3386 | 3386 |
| 3387 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { | 3387 void WebContentsImpl::OnMediaPausedNotification(int64 player_cookie) { |
| 3388 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); | 3388 RemoveMediaPlayerEntry(player_cookie, &active_audio_players_); |
| 3389 RemoveMediaPlayerEntry(player_cookie, &active_video_players_); | 3389 RemoveMediaPlayerEntry(player_cookie, &active_video_players_); |
| 3390 MaybeReleasePowerSaveBlockers(); | 3390 MaybeReleasePowerSaveBlockers(); |
| 3391 | 3391 |
| 3392 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaPaused()); | 3392 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaPaused()); |
| 3393 } | 3393 } |
| 3394 | 3394 |
| 3395 #if defined(OS_ANDROID) | 3395 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 3396 | 3396 |
| 3397 void WebContentsImpl::OnMediaSessionStateChanged() { | 3397 void WebContentsImpl::OnMediaSessionStateChanged() { |
| 3398 MediaSession* session = MediaSession::Get(this); | 3398 MediaSession* session = MediaSession::Get(this); |
| 3399 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3399 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3400 MediaSessionStateChanged(session->IsControllable(), | 3400 MediaSessionStateChanged(session->IsControllable(), |
| 3401 session->IsSuspended())); | 3401 session->IsSuspended())); |
| 3402 } | 3402 } |
| 3403 | 3403 |
| 3404 void WebContentsImpl::ResumeMediaSession() { | 3404 void WebContentsImpl::ResumeMediaSession() { |
| 3405 MediaSession::Get(this)->Resume(); | 3405 MediaSession::Get(this)->Resume(); |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4409 proxy_routing_id)) | 4409 proxy_routing_id)) |
| 4410 return false; | 4410 return false; |
| 4411 | 4411 |
| 4412 // TODO(nasko): When RenderWidgetHost is owned by RenderFrameHost, the passed | 4412 // TODO(nasko): When RenderWidgetHost is owned by RenderFrameHost, the passed |
| 4413 // RenderFrameHost will have to be associated with the appropriate | 4413 // RenderFrameHost will have to be associated with the appropriate |
| 4414 // RenderWidgetHostView or a new one should be created here. | 4414 // RenderWidgetHostView or a new one should be created here. |
| 4415 | 4415 |
| 4416 return true; | 4416 return true; |
| 4417 } | 4417 } |
| 4418 | 4418 |
| 4419 #if defined(OS_ANDROID) | 4419 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 4420 | 4420 |
| 4421 base::android::ScopedJavaLocalRef<jobject> | 4421 base::android::ScopedJavaLocalRef<jobject> |
| 4422 WebContentsImpl::GetJavaWebContents() { | 4422 WebContentsImpl::GetJavaWebContents() { |
| 4423 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 4423 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 4424 return GetWebContentsAndroid()->GetJavaObject(); | 4424 return GetWebContentsAndroid()->GetJavaObject(); |
| 4425 } | 4425 } |
| 4426 | 4426 |
| 4427 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { | 4427 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { |
| 4428 WebContentsAndroid* web_contents_android = | 4428 WebContentsAndroid* web_contents_android = |
| 4429 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 4429 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4608 player_map->erase(it); | 4608 player_map->erase(it); |
| 4609 } | 4609 } |
| 4610 | 4610 |
| 4611 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4611 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4612 force_disable_overscroll_content_ = force_disable; | 4612 force_disable_overscroll_content_ = force_disable; |
| 4613 if (view_) | 4613 if (view_) |
| 4614 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4614 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4615 } | 4615 } |
| 4616 | 4616 |
| 4617 } // namespace content | 4617 } // namespace content |
| OLD | NEW |