NavigationPrecommitController.h (1764B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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/. */ 6 7 #ifndef DOM_NAVIGATIONPRECOMMITCONTROLLER_H_ 8 #define DOM_NAVIGATIONPRECOMMITCONTROLLER_H_ 9 10 #include "js/TypeDecls.h" 11 #include "mozilla/ErrorResult.h" 12 #include "mozilla/dom/BindingDeclarations.h" 13 #include "nsCycleCollectionParticipant.h" 14 #include "nsWrapperCache.h" 15 16 namespace mozilla::dom { 17 18 struct NavigationNavigateOptions; 19 class NavigateEvent; 20 class NavigationInterceptHandler; 21 } // namespace mozilla::dom 22 23 class nsIGlobalObject; 24 25 namespace mozilla::dom { 26 27 class NavigationPrecommitController final : public nsISupports, 28 public nsWrapperCache { 29 public: 30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 31 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(NavigationPrecommitController) 32 33 public: 34 NavigationPrecommitController(NavigateEvent* aEvent, 35 nsIGlobalObject* aGlobalObject); 36 37 protected: 38 ~NavigationPrecommitController(); 39 40 public: 41 nsIGlobalObject* GetParentObject() const; 42 43 JSObject* WrapObject(JSContext* aCx, 44 JS::Handle<JSObject*> aGivenProto) override; 45 46 void Redirect(JSContext* aCx, const nsAString& aUrl, 47 const NavigationNavigateOptions& aOptions, ErrorResult& aRv); 48 49 void AddHandler(NavigationInterceptHandler& aHandler, ErrorResult& aRv); 50 51 private: 52 nsCOMPtr<nsIGlobalObject> mGlobalObject; 53 54 RefPtr<NavigateEvent> mEvent; 55 }; 56 57 } // namespace mozilla::dom 58 59 #endif // DOM_NAVIGATIONPRECOMMITCONTROLLER_H_