dom/base/URL.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef URL_h___
     6 #define URL_h___
     8 #include "mozilla/dom/BindingDeclarations.h"
     9 #include "mozilla/dom/URLSearchParams.h"
    10 #include "nsCycleCollectionParticipant.h"
    11 #include "nsAutoPtr.h"
    12 #include "nsString.h"
    14 class nsIDOMBlob;
    15 class nsISupports;
    16 class nsIURI;
    18 namespace mozilla {
    20 class ErrorResult;
    21 class DOMMediaStream;
    23 namespace dom {
    25 class MediaSource;
    26 class GlobalObject;
    27 struct objectURLOptions;
    29 namespace workers {
    30 class URLProxy;
    31 }
    33 class URL MOZ_FINAL : public URLSearchParamsObserver
    34 {
    35 public:
    36   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    37   NS_DECL_CYCLE_COLLECTION_CLASS(URL)
    39   URL(nsIURI* aURI);
    41   // WebIDL methods
    42   JSObject*
    43   WrapObject(JSContext* aCx);
    45   static already_AddRefed<URL>
    46   Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
    47               URL& aBase, ErrorResult& aRv);
    48   static already_AddRefed<URL>
    49   Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
    50               const nsAString& aBase, ErrorResult& aRv);
    52   static void CreateObjectURL(const GlobalObject& aGlobal,
    53                               nsIDOMBlob* aBlob,
    54                               const objectURLOptions& aOptions,
    55                               nsString& aResult,
    56                               ErrorResult& aError);
    57   static void CreateObjectURL(const GlobalObject& aGlobal,
    58                               DOMMediaStream& aStream,
    59                               const objectURLOptions& aOptions,
    60                               nsString& aResult,
    61                               ErrorResult& aError);
    62   static void CreateObjectURL(const GlobalObject& aGlobal,
    63                               MediaSource& aSource,
    64                               const objectURLOptions& aOptions,
    65                               nsString& aResult,
    66                               ErrorResult& aError);
    67   static void RevokeObjectURL(const GlobalObject& aGlobal,
    68                               const nsAString& aURL);
    70   void GetHref(nsString& aHref) const;
    72   void SetHref(const nsAString& aHref, ErrorResult& aRv);
    74   void GetOrigin(nsString& aOrigin) const;
    76   void GetProtocol(nsString& aProtocol) const;
    78   void SetProtocol(const nsAString& aProtocol);
    80   void GetUsername(nsString& aUsername) const;
    82   void SetUsername(const nsAString& aUsername);
    84   void GetPassword(nsString& aPassword) const;
    86   void SetPassword(const nsAString& aPassword);
    88   void GetHost(nsString& aHost) const;
    90   void SetHost(const nsAString& aHost);
    92   void GetHostname(nsString& aHostname) const;
    94   void SetHostname(const nsAString& aHostname);
    96   void GetPort(nsString& aPort) const;
    98   void SetPort(const nsAString& aPort);
   100   void GetPathname(nsString& aPathname) const;
   102   void SetPathname(const nsAString& aPathname);
   104   void GetSearch(nsString& aRetval) const;
   106   void SetSearch(const nsAString& aArg);
   108   URLSearchParams* SearchParams();
   110   void SetSearchParams(URLSearchParams& aSearchParams);
   112   void GetHash(nsString& aRetval) const;
   114   void SetHash(const nsAString& aArg);
   116   void Stringify(nsString& aRetval) const
   117   {
   118     GetHref(aRetval);
   119   }
   121   // URLSearchParamsObserver
   122   void URLSearchParamsUpdated() MOZ_OVERRIDE;
   124 private:
   125   nsIURI* GetURI() const
   126   {
   127     return mURI;
   128   }
   130   void CreateSearchParamsIfNeeded();
   132   void SetSearchInternal(const nsAString& aSearch);
   134   void UpdateURLSearchParams();
   136   static void CreateObjectURLInternal(const GlobalObject& aGlobal,
   137                                       nsISupports* aObject,
   138                                       const nsACString& aScheme,
   139                                       const objectURLOptions& aOptions,
   140                                       nsString& aResult,
   141                                       ErrorResult& aError);
   143   nsCOMPtr<nsIURI> mURI;
   144   nsRefPtr<URLSearchParams> mSearchParams;
   146   friend class mozilla::dom::workers::URLProxy;
   147 };
   149 bool IsChromeURI(nsIURI* aURI);
   151 }
   152 }
   154 #endif /* URL_h___ */

mercurial