1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_widget_GeckoViewSupport_h
8 #define mozilla_widget_GeckoViewSupport_h
10 #include "mozilla/java/GeckoResultWrappers.h"
11 #include "mozilla/java/GeckoSessionNatives.h"
12 #include "mozilla/java/WebResponseWrappers.h"
13 #include "mozilla/widget/WindowEvent.h"
20 class GeckoViewSupport final
21 : public java::GeckoSession::Window::Natives
<GeckoViewSupport
> {
22 RefPtr
<nsWindow
> mWindow
;
24 // We hold a WeakRef because we want to allow the
25 // GeckoSession.Window to be garbage collected.
26 // Callers need to create a LocalRef from this
27 // before calling methods.
28 java::GeckoSession::Window::WeakRef mGeckoViewWindow
;
31 typedef java::GeckoSession::Window::Natives
<GeckoViewSupport
> Base
;
33 template <typename Functor
>
34 static void OnNativeCall(Functor
&& aCall
) {
35 NS_DispatchToMainThread(new WindowEvent
<Functor
>(std::move(aCall
)));
38 GeckoViewSupport(nsWindow
* aWindow
,
39 const java::GeckoSession::Window::LocalRef
& aInstance
,
40 nsPIDOMWindowOuter
* aDOMWindow
)
41 : mWindow(aWindow
), mGeckoViewWindow(aInstance
), mDOMWindow(aDOMWindow
) {}
45 nsWindow
* GetNsWindow() const { return mWindow
; }
47 using Base::DisposeNative
;
53 nsCOMPtr
<nsPIDOMWindowOuter
> mDOMWindow
;
57 // Create and attach a window.
58 static void Open(const jni::Class::LocalRef
& aCls
,
59 java::GeckoSession::Window::Param aWindow
,
60 jni::Object::Param aQueue
, jni::Object::Param aCompositor
,
61 jni::Object::Param aDispatcher
,
62 jni::Object::Param aSessionAccessibility
,
63 jni::Object::Param aInitData
, jni::String::Param aId
,
64 jni::String::Param aChromeURI
, int32_t aScreenId
,
67 // Close and destroy the nsWindow.
70 // Transfer this nsWindow to new GeckoSession objects.
71 void Transfer(const java::GeckoSession::Window::LocalRef
& inst
,
72 jni::Object::Param aQueue
, jni::Object::Param aCompositor
,
73 jni::Object::Param aDispatcher
,
74 jni::Object::Param aSessionAccessibility
,
75 jni::Object::Param aInitData
);
77 void AttachEditable(const java::GeckoSession::Window::LocalRef
& inst
,
78 jni::Object::Param aEditableParent
);
80 void AttachAccessibility(const java::GeckoSession::Window::LocalRef
& inst
,
81 jni::Object::Param aSessionAccessibility
);
83 void OnReady(jni::Object::Param aQueue
= nullptr);
85 auto OnLoadRequest(mozilla::jni::String::Param aUri
, int32_t aWindowType
,
86 int32_t aFlags
, mozilla::jni::String::Param aTriggeringUri
,
87 bool aHasUserGesture
, bool aIsTopLevel
) const
88 -> java::GeckoResult::LocalRef
;
90 void OnShowDynamicToolbar() const;
92 void PassExternalResponse(java::WebResponse::Param aResponse
);
94 void AttachMediaSessionController(
95 const java::GeckoSession::Window::LocalRef
& inst
,
96 jni::Object::Param aController
, const int64_t aId
);
98 void DetachMediaSessionController(
99 const java::GeckoSession::Window::LocalRef
& inst
,
100 jni::Object::Param aController
);
102 void OnWeakNonIntrusiveDetach(already_AddRefed
<Runnable
> aDisposer
) {
103 RefPtr
<Runnable
> disposer(aDisposer
);
108 } // namespace widget
109 } // namespace mozilla
111 #endif // mozilla_widget_GeckoViewSupport_h