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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_RENDERER_GUEST_VIEW_GUEST_VIEW_INTERNAL_CUSTOM_BINDINGS_H_
6 #define EXTENSIONS_RENDERER_GUEST_VIEW_GUEST_VIEW_INTERNAL_CUSTOM_BINDINGS_H_
10 #include "extensions/renderer/object_backed_native_handler.h"
12 namespace extensions
{
15 // Implements custom bindings for the guestViewInternal API.
16 class GuestViewInternalCustomBindings
: public ObjectBackedNativeHandler
{
18 explicit GuestViewInternalCustomBindings(ScriptContext
* context
);
19 ~GuestViewInternalCustomBindings() override
;
22 // ResetMapEntry is called as a callback to SetWeak(). It resets the
23 // weak view reference held in |view_map_|.
24 static void ResetMapEntry(const v8::WeakCallbackInfo
<int>& data
);
26 // AttachGuest attaches a GuestView to a provided container element. Once
27 // attached, the GuestView will participate in layout of the container page
28 // and become visible on screen.
29 // AttachGuest takes four parameters:
30 // |element_instance_id| uniquely identifies a container within the content
31 // module is able to host GuestViews.
32 // |guest_instance_id| uniquely identifies an unattached GuestView.
33 // |attach_params| is typically used to convey the current state of the
34 // container element at the time of attachment. These parameters are passed
35 // down to the GuestView. The GuestView may use these parameters to update the
36 // state of the guest hosted in another process.
37 // |callback| is an optional callback that is called once attachment is
38 // complete. The callback takes in a parameter for the WindowProxy of the
39 // guest identified by |guest_instance_id|.
40 void AttachGuest(const v8::FunctionCallbackInfo
<v8::Value
>& args
);
42 // DetachGuest detaches the container container specified from the associated
43 // GuestViewBase. DetachGuest takes two parameters:
44 // |element_instance_id| uniquely identifies a container within the content
45 // module is able to host GuestViews.
46 // |callback| is an optional callback that is called once the container has
48 void DetachGuest(const v8::FunctionCallbackInfo
<v8::Value
>& args
);
50 // AttachIframeGuest is --site-per-process variant of AttachGuest().
52 // AttachIframeGuest takes a |contentWindow| parameter in addition to the
53 // parameters to AttachGuest. That parameter is used to identify the
54 // RenderFrame of the <iframe> container element.
55 void AttachIframeGuest(const v8::FunctionCallbackInfo
<v8::Value
>& args
);
57 // GetContentWindow takes in a RenderView routing ID and returns the
58 // Window JavaScript object for that RenderView.
59 void GetContentWindow(const v8::FunctionCallbackInfo
<v8::Value
>& args
);
61 // Destroys the GuestViewContainer given an element instance ID in |args|.
62 void DestroyContainer(const v8::FunctionCallbackInfo
<v8::Value
>& args
);
64 // GetViewFromID takes a view ID, and returns the GuestView element associated
65 // with that ID, if one exists. Otherwise, null is returned.
66 void GetViewFromID(const v8::FunctionCallbackInfo
<v8::Value
>& args
);
68 // RegisterDestructionCallback registers a JavaScript callback function to be
69 // called when the guestview's container is destroyed.
70 // RegisterDestructionCallback takes in a single paramater, |callback|.
71 void RegisterDestructionCallback(
72 const v8::FunctionCallbackInfo
<v8::Value
>& args
);
74 // RegisterElementResizeCallback registers a JavaScript callback function to
75 // be called when the element is resized. RegisterElementResizeCallback takes
76 // a single parameter, |callback|.
77 void RegisterElementResizeCallback(
78 const v8::FunctionCallbackInfo
<v8::Value
>& args
);
80 // RegisterView takes in a view ID and a GuestView element, and stores the
81 // pair as an entry in |view_map_|. The view can then be retrieved using
83 void RegisterView(const v8::FunctionCallbackInfo
<v8::Value
>& args
);
85 // Runs a JavaScript function with user gesture.
87 // This is used to request webview element to enter fullscreen (from the
89 // Note that the guest requesting fullscreen means it has already been
90 // triggered by a user gesture and we get to this point if embedder allows
91 // the fullscreen request to proceed.
93 const v8::FunctionCallbackInfo
<v8::Value
>& args
);
96 } // namespace extensions
98 #endif // EXTENSIONS_RENDERER_GUEST_VIEW_GUEST_VIEW_INTERNAL_CUSTOM_BINDINGS_H_