tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Client.h (2371B)


      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/. */
      6 #ifndef _mozilla_dom_Client_h
      7 #define _mozilla_dom_Client_h
      8 
      9 #include "X11UndefineNone.h"
     10 #include "mozilla/StorageAccess.h"
     11 #include "mozilla/dom/ClientBinding.h"
     12 #include "nsCOMPtr.h"
     13 #include "nsContentUtils.h"
     14 #include "nsISupports.h"
     15 #include "nsWrapperCache.h"
     16 
     17 class nsIGlobalObject;
     18 
     19 namespace mozilla {
     20 
     21 class ErrorResult;
     22 
     23 namespace dom {
     24 
     25 class ClientHandle;
     26 class ClientInfoAndState;
     27 class Promise;
     28 template <typename t>
     29 class Sequence;
     30 struct StructuredSerializeOptions;
     31 
     32 class Client final : public nsISupports, public nsWrapperCache {
     33  nsCOMPtr<nsIGlobalObject> mGlobal;
     34  UniquePtr<ClientInfoAndState> mData;
     35  RefPtr<ClientHandle> mHandle;
     36 
     37  ~Client() = default;
     38 
     39  void EnsureHandle();
     40 
     41 public:
     42  Client(nsIGlobalObject* aGlobal, const ClientInfoAndState& aData);
     43 
     44  TimeStamp CreationTime() const;
     45 
     46  TimeStamp LastFocusTime() const;
     47 
     48  StorageAccess GetStorageAccess() const;
     49 
     50  // nsWrapperCache interface methods
     51  JSObject* WrapObject(JSContext* aCx,
     52                       JS::Handle<JSObject*> aGivenProto) override;
     53 
     54  // DOM bindings methods
     55  nsIGlobalObject* GetParentObject() const;
     56 
     57  // Client Bindings
     58  void GetUrl(nsAString& aUrlOut) const;
     59 
     60  void GetId(nsAString& aIdOut) const;
     61 
     62  ClientType Type() const;
     63 
     64  FrameType GetFrameType() const;
     65 
     66  // WindowClient bindings
     67  VisibilityState GetVisibilityState() const;
     68 
     69  bool Focused() const;
     70 
     71  already_AddRefed<Promise> Focus(CallerType aCallerType, ErrorResult& aRv);
     72 
     73  already_AddRefed<Promise> Navigate(const nsAString& aURL, ErrorResult& aRv);
     74 
     75  void PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
     76                   const Sequence<JSObject*>& aTransferrable, ErrorResult& aRv);
     77 
     78  void PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
     79                   const StructuredSerializeOptions& aOptions,
     80                   ErrorResult& aRv);
     81 
     82  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     83  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(mozilla::dom::Client)
     84 };
     85 
     86 }  // namespace dom
     87 }  // namespace mozilla
     88 
     89 #endif  // _mozilla_dom_Client_h