summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/guest_view
diff options
context:
space:
mode:
authorlazyboy <lazyboy@chromium.org>2015-03-18 20:21:01 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-19 03:21:46 +0000
commit6d745d6dadfd0e161a91d7f3a21f919886ed8e7b (patch)
treed4dfb159a682da0c24d201655af2941d1f535785 /extensions/renderer/guest_view
parentdf69a28d5b46c2d9a25a14b9fc427a26ecf9f55f (diff)
downloadchromium_src-6d745d6dadfd0e161a91d7f3a21f919886ed8e7b.zip
chromium_src-6d745d6dadfd0e161a91d7f3a21f919886ed8e7b.tar.gz
chromium_src-6d745d6dadfd0e161a91d7f3a21f919886ed8e7b.tar.bz2
<webview>: Implement fullscreen permission for html5 element.requestFullscreen()
We do it in two stages, first a DOM element requests fullscreen inside <webview>, this fires a permissionrequest to the embedder of <webview> to decide whether to allow/deny the request. The element goes fullscreen within the <webview>'s bounds at this point. The embedder can: a) allow the request: in this case we perform the second stage, where the <webview> element in the embedder enters fullscreen (provided that the embedder has permission to enter fullscreen). b) deny the request: in this case, <webview> exits fullscreen mode. Note that b) will cause a flicker and blink interface is required to avoid that. That is tracked on http://crbug.com/466854. BUG=141198 Test= Load a chrome app with a <webview> in it, make the <webview> point to some site that has html5 fullscreen request, e.g. youtube.com. Add an event listener in the chrome app so that it allows <webview> fullscreen, e.g. <webview>.addEventListener('permissionrequest', function(e) { if (e.permission === 'fullscreen') e.request.allow(); }); Now perform necessary action to request fullscreen from the <webview>, for the youtube case, this would be fullscreening the video player. Check that the element enters fullscreen mode. Review URL: https://codereview.chromium.org/984963004 Cr-Commit-Position: refs/heads/master@{#321282}
Diffstat (limited to 'extensions/renderer/guest_view')
-rw-r--r--extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc15
-rw-r--r--extensions/renderer/guest_view/guest_view_internal_custom_bindings.h10
2 files changed, 25 insertions, 0 deletions
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
index a57f454..8bc2a2e 100644
--- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
+++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
@@ -15,6 +15,7 @@
#include "extensions/renderer/guest_view/extensions_guest_view_container.h"
#include "extensions/renderer/script_context.h"
#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebScopedUserGesture.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "v8/include/v8.h"
@@ -43,6 +44,10 @@ GuestViewInternalCustomBindings::GuestViewInternalCustomBindings(
base::Bind(
&GuestViewInternalCustomBindings::RegisterElementResizeCallback,
base::Unretained(this)));
+ RouteFunction(
+ "RunWithGesture",
+ base::Bind(&GuestViewInternalCustomBindings::RunWithGesture,
+ base::Unretained(this)));
}
void GuestViewInternalCustomBindings::AttachGuest(
@@ -198,4 +203,14 @@ void GuestViewInternalCustomBindings::RegisterElementResizeCallback(
args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
}
+void GuestViewInternalCustomBindings::RunWithGesture(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ // Gesture is required to request fullscreen.
+ blink::WebScopedUserGesture user_gesture;
+ CHECK_EQ(args.Length(), 1);
+ CHECK(args[0]->IsFunction());
+ v8::Handle<v8::Value> no_args;
+ context()->CallFunction(v8::Handle<v8::Function>::Cast(args[0]), 0, &no_args);
+}
+
} // namespace extensions
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
index 2c19137..b28634f 100644
--- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
+++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
@@ -55,6 +55,16 @@ class GuestViewInternalCustomBindings : public ObjectBackedNativeHandler {
// a single parameter, |callback|.
void RegisterElementResizeCallback(
const v8::FunctionCallbackInfo<v8::Value>& args);
+
+ // Runs a JavaScript function with user gesture.
+ //
+ // This is used to request webview element to enter fullscreen (from the
+ // embedder).
+ // Note that the guest requesting fullscreen means it has already been
+ // triggered by a user gesture and we get to this point if embedder allows
+ // the fullscreen request to proceed.
+ void RunWithGesture(
+ const v8::FunctionCallbackInfo<v8::Value>& args);
};
} // namespace extensions