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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 #include "ui/gfx/display.h" | 114 #include "ui/gfx/display.h" |
115 #include "ui/gfx/screen.h" | 115 #include "ui/gfx/screen.h" |
116 #include "ui/gl/gl_switches.h" | 116 #include "ui/gl/gl_switches.h" |
117 | 117 |
118 #if defined(ENABLE_BROWSER_CDMS) | 118 #if defined(ENABLE_BROWSER_CDMS) |
119 #include "content/browser/media/media_web_contents_observer.h" | 119 #include "content/browser/media/media_web_contents_observer.h" |
120 #endif | 120 #endif |
121 | 121 |
122 #if defined(OS_ANDROID) | 122 #if defined(OS_ANDROID) |
123 #include "content/browser/android/content_video_view.h" | 123 #include "content/browser/android/content_video_view.h" |
124 #include "content/browser/media/android/media_session.h" | |
125 #if !defined(USE_AURA) | |
no sievers
2015/11/02 22:27:15
nit: for headers should we make the correct style
mfomitchev
2015/11/03 22:23:19
Done.
| |
124 #include "content/browser/android/date_time_chooser_android.h" | 126 #include "content/browser/android/date_time_chooser_android.h" |
125 #include "content/browser/media/android/media_session.h" | |
126 #include "content/browser/web_contents/web_contents_android.h" | 127 #include "content/browser/web_contents/web_contents_android.h" |
127 #endif | 128 #endif // !USE_AURA |
129 #endif // OS_ANDROID | |
128 | 130 |
129 #if defined(OS_MACOSX) | 131 #if defined(OS_MACOSX) |
130 #include "base/mac/foundation_util.h" | 132 #include "base/mac/foundation_util.h" |
131 #endif | 133 #endif |
132 | 134 |
133 namespace content { | 135 namespace content { |
134 namespace { | 136 namespace { |
135 | 137 |
136 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 138 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
137 const char kDotGoogleDotCom[] = ".google.com"; | 139 const char kDotGoogleDotCom[] = ".google.com"; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 OnBrowserPluginMessage(render_frame_host, | 663 OnBrowserPluginMessage(render_frame_host, |
662 message)) | 664 message)) |
663 #endif | 665 #endif |
664 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) | 666 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFaviconURL, OnUpdateFaviconURL) |
665 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, | 667 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage, |
666 OnShowValidationMessage) | 668 OnShowValidationMessage) |
667 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, | 669 IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage, |
668 OnHideValidationMessage) | 670 OnHideValidationMessage) |
669 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, | 671 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage, |
670 OnMoveValidationMessage) | 672 OnMoveValidationMessage) |
671 #if defined(OS_ANDROID) | 673 #if defined(OS_ANDROID) && !defined(USE_AURA) |
672 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, | 674 IPC_MESSAGE_HANDLER(ViewHostMsg_FindMatchRects_Reply, |
673 OnFindMatchRectsReply) | 675 OnFindMatchRectsReply) |
674 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, | 676 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenDateTimeDialog, |
675 OnOpenDateTimeDialog) | 677 OnOpenDateTimeDialog) |
676 #endif | 678 #endif |
677 IPC_MESSAGE_UNHANDLED(handled = false) | 679 IPC_MESSAGE_UNHANDLED(handled = false) |
678 IPC_END_MESSAGE_MAP() | 680 IPC_END_MESSAGE_MAP() |
679 render_view_message_source_ = NULL; | 681 render_view_message_source_ = NULL; |
680 render_frame_message_source_ = NULL; | 682 render_frame_message_source_ = NULL; |
681 | 683 |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1404 | 1406 |
1405 registrar_.Add(this, | 1407 registrar_.Add(this, |
1406 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1408 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
1407 NotificationService::AllBrowserContextsAndSources()); | 1409 NotificationService::AllBrowserContextsAndSources()); |
1408 | 1410 |
1409 screen_orientation_dispatcher_host_.reset( | 1411 screen_orientation_dispatcher_host_.reset( |
1410 new ScreenOrientationDispatcherHostImpl(this)); | 1412 new ScreenOrientationDispatcherHostImpl(this)); |
1411 | 1413 |
1412 manifest_manager_host_.reset(new ManifestManagerHost(this)); | 1414 manifest_manager_host_.reset(new ManifestManagerHost(this)); |
1413 | 1415 |
1414 #if defined(OS_ANDROID) | 1416 #if defined(OS_ANDROID) && !defined(USE_AURA) |
1415 date_time_chooser_.reset(new DateTimeChooserAndroid()); | 1417 date_time_chooser_.reset(new DateTimeChooserAndroid()); |
1416 #endif | 1418 #endif |
1417 | 1419 |
1418 // BrowserPluginGuest::Init needs to be called after this WebContents has | 1420 // BrowserPluginGuest::Init needs to be called after this WebContents has |
1419 // a RenderWidgetHostViewGuest. That is, |view_->CreateView| above. | 1421 // a RenderWidgetHostViewGuest. That is, |view_->CreateView| above. |
1420 if (browser_plugin_guest_) | 1422 if (browser_plugin_guest_) |
1421 browser_plugin_guest_->Init(); | 1423 browser_plugin_guest_->Init(); |
1422 | 1424 |
1423 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 1425 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
1424 g_created_callbacks.Get().at(i).Run(this); | 1426 g_created_callbacks.Get().at(i).Run(this); |
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3200 int number_of_matches, | 3202 int number_of_matches, |
3201 const gfx::Rect& selection_rect, | 3203 const gfx::Rect& selection_rect, |
3202 int active_match_ordinal, | 3204 int active_match_ordinal, |
3203 bool final_update) { | 3205 bool final_update) { |
3204 if (delegate_) { | 3206 if (delegate_) { |
3205 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, | 3207 delegate_->FindReply(this, request_id, number_of_matches, selection_rect, |
3206 active_match_ordinal, final_update); | 3208 active_match_ordinal, final_update); |
3207 } | 3209 } |
3208 } | 3210 } |
3209 | 3211 |
3210 #if defined(OS_ANDROID) | 3212 #if defined(OS_ANDROID) && !defined(USE_AURA) |
3211 void WebContentsImpl::OnFindMatchRectsReply( | 3213 void WebContentsImpl::OnFindMatchRectsReply( |
3212 int version, | 3214 int version, |
3213 const std::vector<gfx::RectF>& rects, | 3215 const std::vector<gfx::RectF>& rects, |
3214 const gfx::RectF& active_rect) { | 3216 const gfx::RectF& active_rect) { |
3215 if (delegate_) | 3217 if (delegate_) |
3216 delegate_->FindMatchRectsReply(this, version, rects, active_rect); | 3218 delegate_->FindMatchRectsReply(this, version, rects, active_rect); |
3217 } | 3219 } |
3218 | 3220 |
3219 void WebContentsImpl::OnOpenDateTimeDialog( | 3221 void WebContentsImpl::OnOpenDateTimeDialog( |
3220 const ViewHostMsg_DateTimeDialogValue_Params& value) { | 3222 const ViewHostMsg_DateTimeDialogValue_Params& value) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3363 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, | 3365 PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
3364 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); | 3366 PowerSaveBlocker::kReasonAudioPlayback, "Playing audio"); |
3365 } | 3367 } |
3366 | 3368 |
3367 void WebContentsImpl::CreateVideoPowerSaveBlocker() { | 3369 void WebContentsImpl::CreateVideoPowerSaveBlocker() { |
3368 DCHECK(!video_power_save_blocker_); | 3370 DCHECK(!video_power_save_blocker_); |
3369 DCHECK(!active_video_players_.empty()); | 3371 DCHECK(!active_video_players_.empty()); |
3370 video_power_save_blocker_ = PowerSaveBlocker::Create( | 3372 video_power_save_blocker_ = PowerSaveBlocker::Create( |
3371 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 3373 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
3372 PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); | 3374 PowerSaveBlocker::kReasonVideoPlayback, "Playing video"); |
3373 #if defined(OS_ANDROID) | 3375 //TODO(mfomitchev): Support PowerSaveBlocker on Aura - crbug.com/546718. |
3374 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) | 3376 #if defined(OS_ANDROID) && !defined(USE_AURA) |
3377 static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get()) | |
3375 ->InitDisplaySleepBlocker(this); | 3378 ->InitDisplaySleepBlocker(this); |
3376 #endif | 3379 #endif |
3377 } | 3380 } |
3378 | 3381 |
3379 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { | 3382 void WebContentsImpl::MaybeReleasePowerSaveBlockers() { |
3380 // If there are no more audio players and we don't have audio stream | 3383 // If there are no more audio players and we don't have audio stream |
3381 // monitoring, release the audio power save blocker here instead of during | 3384 // monitoring, release the audio power save blocker here instead of during |
3382 // NotifyNavigationStateChanged(). | 3385 // NotifyNavigationStateChanged(). |
3383 if (active_audio_players_.empty() && | 3386 if (active_audio_players_.empty() && |
3384 !AudioStreamMonitor::monitoring_available()) { | 3387 !AudioStreamMonitor::monitoring_available()) { |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4454 parent_routing_id, previous_sibling_routing_id)) | 4457 parent_routing_id, previous_sibling_routing_id)) |
4455 return false; | 4458 return false; |
4456 | 4459 |
4457 // TODO(nasko): When RenderWidgetHost is owned by RenderFrameHost, the passed | 4460 // TODO(nasko): When RenderWidgetHost is owned by RenderFrameHost, the passed |
4458 // RenderFrameHost will have to be associated with the appropriate | 4461 // RenderFrameHost will have to be associated with the appropriate |
4459 // RenderWidgetHostView or a new one should be created here. | 4462 // RenderWidgetHostView or a new one should be created here. |
4460 | 4463 |
4461 return true; | 4464 return true; |
4462 } | 4465 } |
4463 | 4466 |
4464 #if defined(OS_ANDROID) | 4467 #if defined(OS_ANDROID) && !defined(USE_AURA) |
4465 | 4468 |
4466 base::android::ScopedJavaLocalRef<jobject> | 4469 base::android::ScopedJavaLocalRef<jobject> |
4467 WebContentsImpl::GetJavaWebContents() { | 4470 WebContentsImpl::GetJavaWebContents() { |
4468 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 4471 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
4469 return GetWebContentsAndroid()->GetJavaObject(); | 4472 return GetWebContentsAndroid()->GetJavaObject(); |
4470 } | 4473 } |
4471 | 4474 |
4472 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { | 4475 WebContentsAndroid* WebContentsImpl::GetWebContentsAndroid() { |
4473 WebContentsAndroid* web_contents_android = | 4476 WebContentsAndroid* web_contents_android = |
4474 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 4477 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4679 return NULL; | 4682 return NULL; |
4680 } | 4683 } |
4681 | 4684 |
4682 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4685 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4683 force_disable_overscroll_content_ = force_disable; | 4686 force_disable_overscroll_content_ = force_disable; |
4684 if (view_) | 4687 if (view_) |
4685 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4688 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4686 } | 4689 } |
4687 | 4690 |
4688 } // namespace content | 4691 } // namespace content |
OLD | NEW |