Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1467)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 23477051: Embed Flash Fullscreen widget within browser window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add caution comment to chrome_switches.cc. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index cbb0ca3fd4d08f8d99a511c3eee48e1e3ec869de..e5798e7c10fce5c0ecb4af9554aa58a8ad5e8f32 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -846,6 +846,14 @@ RenderWidgetHostViewPort* WebContentsImpl::GetRenderWidgetHostViewPort() const {
return RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView());
}
+RenderWidgetHostView* WebContentsImpl::GetFullscreenRenderWidgetHostView()
+ const {
+ RenderWidgetHost* const widget_host =
+ RenderWidgetHostImpl::FromID(GetRenderProcessHost()->GetID(),
+ GetFullscreenWidgetRoutingID());
+ return widget_host ? widget_host->GetView() : NULL;
+}
+
WebContentsView* WebContentsImpl::GetView() const {
return view_.get();
}
@@ -1328,6 +1336,8 @@ void WebContentsImpl::RenderWidgetDeleted(
if (render_widget_host &&
render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_) {
+ if (delegate_ && delegate_->EmbedsFullscreenWidget())
+ delegate_->ToggleFullscreenModeForTab(this, false);
FOR_EACH_OBSERVER(WebContentsObserver,
observers_,
DidDestroyFullscreenWidget(
@@ -1405,6 +1415,13 @@ void WebContentsImpl::HandleGestureEnd() {
}
void WebContentsImpl::ToggleFullscreenMode(bool enter_fullscreen) {
+ // This method is being called to enter or leave renderer-initiated fullscreen
+ // mode. Either way, make sure any existing fullscreen widget is shut down
+ // first.
+ RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
+ if (widget_view)
+ RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
+
if (delegate_)
delegate_->ToggleFullscreenModeForTab(this, enter_fullscreen);
}
@@ -1601,12 +1618,6 @@ void WebContentsImpl::ShowCreatedWidget(int route_id,
void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) {
ShowCreatedWidget(route_id, true, gfx::Rect());
-
- DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_);
- fullscreen_widget_routing_id_ = route_id;
- FOR_EACH_OBSERVER(WebContentsObserver,
- observers_,
- DidShowFullscreenWidget(route_id));
}
void WebContentsImpl::ShowCreatedWidget(int route_id,
@@ -1619,17 +1630,35 @@ void WebContentsImpl::ShowCreatedWidget(int route_id,
RenderWidgetHostViewPort::FromRWHV(GetCreatedWidget(route_id));
if (!widget_host_view)
return;
- if (is_fullscreen)
- widget_host_view->InitAsFullscreen(GetRenderWidgetHostViewPort());
- else
+ bool allow_privileged = false;
+ if (is_fullscreen) {
+ if (delegate_ && delegate_->EmbedsFullscreenWidget()) {
+ widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView());
+ delegate_->ToggleFullscreenModeForTab(this, true);
+ } else {
+ widget_host_view->InitAsFullscreen(GetRenderWidgetHostViewPort());
+ // Only allow privileged mouse lock for fullscreen render widget, which is
+ // used to implement Pepper Flash fullscreen.
+ allow_privileged = true;
+ }
+
+ DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_);
+ fullscreen_widget_routing_id_ = route_id;
+ FOR_EACH_OBSERVER(WebContentsObserver,
+ observers_,
+ DidShowFullscreenWidget(route_id));
+ if (!widget_host_view->HasFocus())
+ widget_host_view->Focus();
+ } else {
widget_host_view->InitAsPopup(GetRenderWidgetHostViewPort(), initial_pos);
+ }
RenderWidgetHostImpl* render_widget_host_impl =
RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost());
render_widget_host_impl->Init();
- // Only allow privileged mouse lock for fullscreen render widget, which is
- // used to implement Pepper Flash fullscreen.
- render_widget_host_impl->set_allow_privileged_mouse_lock(is_fullscreen);
+ render_widget_host_impl->set_allow_privileged_mouse_lock(allow_privileged);
+ // TODO(miu): For now, all mouse lock requests by embedded Flash fullscreen
+ // will be denied. This is to be rectified in a soon-upcoming change.
#if defined(OS_MACOSX)
// A RenderWidgetHostViewMac has lifetime scoped to the view. Now that it's
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698