Bug 1731994: part 7) Update documentation of `nsIContentPermissionPrompt`. r=edgar...
[gecko.git] / widget / android / GeckoViewSupport.h
blob2870cc0e18df6f39a2d9eb7d35e1bf9162589985
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"
15 class nsWindow;
17 namespace mozilla {
18 namespace widget {
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;
30 public:
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) {}
43 ~GeckoViewSupport();
45 nsWindow* GetNsWindow() const { return mWindow; }
47 using Base::DisposeNative;
49 /**
50 * GeckoView methods
52 private:
53 nsCOMPtr<nsPIDOMWindowOuter> mDOMWindow;
54 bool mIsReady{false};
56 public:
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,
65 bool aPrivateMode);
67 // Close and destroy the nsWindow.
68 void Close();
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);
104 disposer->Run();
108 } // namespace widget
109 } // namespace mozilla
111 #endif // mozilla_widget_GeckoViewSupport_h