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

Side by Side Diff: extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc

Issue 984963004: <webview>: Implement fullscreen permission for html5 element.requestFullscreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tmptmptmp
Patch Set: Disable one test one test on mac with bug ref, use document.webkitIsFullScreen Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/guest_view/guest_view_internal_custom_bindings.h" 5 #include "extensions/renderer/guest_view/guest_view_internal_custom_bindings.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "content/public/child/v8_value_converter.h" 10 #include "content/public/child/v8_value_converter.h"
11 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
12 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
13 #include "extensions/common/extension_messages.h" 13 #include "extensions/common/extension_messages.h"
14 #include "extensions/common/guest_view/guest_view_constants.h" 14 #include "extensions/common/guest_view/guest_view_constants.h"
15 #include "extensions/renderer/guest_view/extensions_guest_view_container.h" 15 #include "extensions/renderer/guest_view/extensions_guest_view_container.h"
16 #include "extensions/renderer/script_context.h" 16 #include "extensions/renderer/script_context.h"
17 #include "third_party/WebKit/public/web/WebFrame.h" 17 #include "third_party/WebKit/public/web/WebFrame.h"
18 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
18 #include "third_party/WebKit/public/web/WebView.h" 19 #include "third_party/WebKit/public/web/WebView.h"
19 #include "v8/include/v8.h" 20 #include "v8/include/v8.h"
20 21
21 using content::V8ValueConverter; 22 using content::V8ValueConverter;
22 23
23 namespace extensions { 24 namespace extensions {
24 25
25 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings( 26 GuestViewInternalCustomBindings::GuestViewInternalCustomBindings(
26 ScriptContext* context) 27 ScriptContext* context)
27 : ObjectBackedNativeHandler(context) { 28 : ObjectBackedNativeHandler(context) {
28 RouteFunction("AttachGuest", 29 RouteFunction("AttachGuest",
29 base::Bind(&GuestViewInternalCustomBindings::AttachGuest, 30 base::Bind(&GuestViewInternalCustomBindings::AttachGuest,
30 base::Unretained(this))); 31 base::Unretained(this)));
31 RouteFunction("DetachGuest", 32 RouteFunction("DetachGuest",
32 base::Bind(&GuestViewInternalCustomBindings::DetachGuest, 33 base::Bind(&GuestViewInternalCustomBindings::DetachGuest,
33 base::Unretained(this))); 34 base::Unretained(this)));
34 RouteFunction("GetContentWindow", 35 RouteFunction("GetContentWindow",
35 base::Bind(&GuestViewInternalCustomBindings::GetContentWindow, 36 base::Bind(&GuestViewInternalCustomBindings::GetContentWindow,
36 base::Unretained(this))); 37 base::Unretained(this)));
37 RouteFunction( 38 RouteFunction(
38 "RegisterDestructionCallback", 39 "RegisterDestructionCallback",
39 base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback, 40 base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback,
40 base::Unretained(this))); 41 base::Unretained(this)));
41 RouteFunction( 42 RouteFunction(
42 "RegisterElementResizeCallback", 43 "RegisterElementResizeCallback",
43 base::Bind( 44 base::Bind(
44 &GuestViewInternalCustomBindings::RegisterElementResizeCallback, 45 &GuestViewInternalCustomBindings::RegisterElementResizeCallback,
45 base::Unretained(this))); 46 base::Unretained(this)));
47 RouteFunction(
48 "RunWithGesture",
49 base::Bind(&GuestViewInternalCustomBindings::RunWithGesture,
50 base::Unretained(this)));
46 } 51 }
47 52
48 void GuestViewInternalCustomBindings::AttachGuest( 53 void GuestViewInternalCustomBindings::AttachGuest(
49 const v8::FunctionCallbackInfo<v8::Value>& args) { 54 const v8::FunctionCallbackInfo<v8::Value>& args) {
50 // Allow for an optional callback parameter. 55 // Allow for an optional callback parameter.
51 CHECK(args.Length() >= 3 && args.Length() <= 4); 56 CHECK(args.Length() >= 3 && args.Length() <= 4);
52 // Element Instance ID. 57 // Element Instance ID.
53 CHECK(args[0]->IsInt32()); 58 CHECK(args[0]->IsInt32());
54 // Guest Instance ID. 59 // Guest Instance ID.
55 CHECK(args[1]->IsInt32()); 60 CHECK(args[1]->IsInt32());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ExtensionsGuestViewContainer::FromID(element_instance_id); 196 ExtensionsGuestViewContainer::FromID(element_instance_id);
192 if (!guest_view_container) 197 if (!guest_view_container)
193 return; 198 return;
194 199
195 guest_view_container->RegisterElementResizeCallback( 200 guest_view_container->RegisterElementResizeCallback(
196 args[1].As<v8::Function>(), args.GetIsolate()); 201 args[1].As<v8::Function>(), args.GetIsolate());
197 202
198 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true)); 203 args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
199 } 204 }
200 205
206 void GuestViewInternalCustomBindings::RunWithGesture(
207 const v8::FunctionCallbackInfo<v8::Value>& args) {
208 // Gesture is required to request fullscreen.
209 blink::WebScopedUserGesture user_gesture;
210 CHECK_EQ(args.Length(), 1);
211 CHECK(args[0]->IsFunction());
212 v8::Handle<v8::Value> no_args;
213 context()->CallFunction(v8::Handle<v8::Function>::Cast(args[0]), 0, &no_args);
214 }
215
201 } // namespace extensions 216 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698