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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef nsBrowserElement_h 8 #define nsBrowserElement_h 9 10 #include "mozilla/dom/BindingDeclarations.h" 11 12 #include "nsCOMPtr.h" 13 #include "nsIBrowserElementAPI.h" 14 15 class nsFrameLoader; 16 17 namespace mozilla { 18 19 namespace dom { 20 class Promise; 21 } // namespace dom 22 23 class ErrorResult; 24 25 /** 26 * A helper class for browser-element frames 27 */ 28 class nsBrowserElement { 29 public: 30 nsBrowserElement() = default; 31 virtual ~nsBrowserElement() = default; 32 33 void SendMouseEvent(const nsAString& aType, uint32_t aX, uint32_t aY, 34 uint32_t aButton, uint32_t aClickCount, 35 uint32_t aModifiers, ErrorResult& aRv); 36 void GoBack(ErrorResult& aRv); 37 void GoForward(ErrorResult& aRv); 38 void Reload(bool aHardReload, ErrorResult& aRv); 39 void Stop(ErrorResult& aRv); 40 41 already_AddRefed<dom::Promise> GetCanGoBack(ErrorResult& aRv); 42 already_AddRefed<dom::Promise> GetCanGoForward(ErrorResult& aRv); 43 44 protected: 45 virtual already_AddRefed<nsFrameLoader> GetFrameLoader() = 0; 46 47 void InitBrowserElementAPI(); 48 void DestroyBrowserElementFrameScripts(); 49 nsCOMPtr<nsIBrowserElementAPI> mBrowserElementAPI; 50 51 private: 52 bool IsBrowserElementOrThrow(ErrorResult& aRv); 53 }; 54 55 } // namespace mozilla 56 57 #endif // nsBrowserElement_h 58