2013-01-28 15:08:21 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef URL_h___
|
|
|
|
#define URL_h___
|
|
|
|
|
2013-09-04 21:07:21 +04:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-12-12 23:30:27 +04:00
|
|
|
#include "mozilla/dom/URLSearchParams.h"
|
2013-09-04 21:07:21 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-08-15 22:17:48 +04:00
|
|
|
#include "nsString.h"
|
2013-01-28 15:08:21 +04:00
|
|
|
|
2013-08-15 22:17:48 +04:00
|
|
|
class nsISupports;
|
2013-09-04 21:07:21 +04:00
|
|
|
class nsIURI;
|
2013-01-28 15:08:21 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2013-02-15 12:04:11 +04:00
|
|
|
|
2013-08-15 22:17:48 +04:00
|
|
|
class ErrorResult;
|
2013-02-15 12:04:11 +04:00
|
|
|
class DOMMediaStream;
|
|
|
|
|
2013-01-28 15:08:21 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2014-10-08 20:15:23 +04:00
|
|
|
class File;
|
2013-06-21 07:15:15 +04:00
|
|
|
class MediaSource;
|
2013-08-15 22:17:48 +04:00
|
|
|
class GlobalObject;
|
|
|
|
struct objectURLOptions;
|
2013-06-21 07:15:15 +04:00
|
|
|
|
2013-09-04 21:07:34 +04:00
|
|
|
namespace workers {
|
|
|
|
class URLProxy;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class URL final : public URLSearchParamsObserver
|
2013-01-28 15:08:21 +04:00
|
|
|
{
|
2014-06-23 23:56:07 +04:00
|
|
|
~URL() {}
|
|
|
|
|
2013-01-28 15:08:21 +04:00
|
|
|
public:
|
2013-12-12 23:30:27 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(URL)
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit URL(nsIURI* aURI);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2013-01-28 15:08:21 +04:00
|
|
|
// WebIDL methods
|
2015-01-09 00:56:42 +03:00
|
|
|
bool
|
Bug 1117172 part 2. Change the non-wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, Codegen.py, and
StructuredClone.cpp. The rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/WrapObject\((JSContext *\* *(?:aCx|cx)),(\s*)(JS::MutableHandle<JSObject\*> aReflector)/WrapObject(\1,\2JS::Handle<JSObject*> aGivenProto,\2\3/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx)), this, aReflector/\1, this, aGivenProto, aReflector/'
2015-03-19 17:13:32 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
|
|
|
static already_AddRefed<URL>
|
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
URL& aBase, ErrorResult& aRv);
|
|
|
|
static already_AddRefed<URL>
|
|
|
|
Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
|
|
|
|
const nsAString& aBase, ErrorResult& aRv);
|
|
|
|
|
2013-08-23 09:17:08 +04:00
|
|
|
static void CreateObjectURL(const GlobalObject& aGlobal,
|
2014-10-08 20:15:23 +04:00
|
|
|
File& aBlob,
|
2013-01-28 15:08:21 +04:00
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 22:10:20 +03:00
|
|
|
nsAString& aResult,
|
2013-01-28 15:08:21 +04:00
|
|
|
ErrorResult& aError);
|
2012-12-03 20:07:49 +04:00
|
|
|
static void CreateObjectURL(const GlobalObject& aGlobal,
|
2013-02-15 12:04:11 +04:00
|
|
|
DOMMediaStream& aStream,
|
2013-09-04 21:07:21 +04:00
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 22:10:20 +03:00
|
|
|
nsAString& aResult,
|
2013-09-04 21:07:21 +04:00
|
|
|
ErrorResult& aError);
|
2013-06-21 07:15:15 +04:00
|
|
|
static void CreateObjectURL(const GlobalObject& aGlobal,
|
|
|
|
MediaSource& aSource,
|
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 22:10:20 +03:00
|
|
|
nsAString& aResult,
|
2013-09-04 21:07:21 +04:00
|
|
|
ErrorResult& aError);
|
2012-12-03 20:07:49 +04:00
|
|
|
static void RevokeObjectURL(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aURL);
|
2013-01-28 15:08:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHref(nsAString& aHref, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
|
|
|
void SetHref(const nsAString& aHref, ErrorResult& aRv);
|
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetProtocol(const nsAString& aProtocol, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetUsername(nsAString& aUsername, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetUsername(const nsAString& aUsername, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetPassword(nsAString& aPassword, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetPassword(const nsAString& aPassword, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHost(nsAString& aHost, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetHost(const nsAString& aHost, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHostname(nsAString& aHostname, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetHostname(const nsAString& aHostname, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetPort(nsAString& aPort, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetPort(const nsAString& aPort, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetPathname(nsAString& aPathname, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetPathname(const nsAString& aPathname, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetSearch(nsAString& aRetval, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetSearch(const nsAString& aArg, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-03-19 19:36:46 +04:00
|
|
|
URLSearchParams* SearchParams();
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2014-03-19 19:36:46 +04:00
|
|
|
void SetSearchParams(URLSearchParams& aSearchParams);
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void GetHash(nsAString& aRetval, ErrorResult& aRv) const;
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
void SetHash(const nsAString& aArg, ErrorResult& aRv);
|
2013-09-04 21:07:21 +04:00
|
|
|
|
2015-02-27 22:10:20 +03:00
|
|
|
void Stringify(nsAString& aRetval, ErrorResult& aRv) const
|
2014-01-14 02:46:04 +04:00
|
|
|
{
|
2014-07-12 03:30:27 +04:00
|
|
|
GetHref(aRetval, aRv);
|
2014-01-14 02:46:04 +04:00
|
|
|
}
|
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
// URLSearchParamsObserver
|
2015-03-21 19:28:04 +03:00
|
|
|
void URLSearchParamsUpdated(URLSearchParams* aSearchParams) override;
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2013-01-28 15:08:21 +04:00
|
|
|
private:
|
2013-09-04 21:07:21 +04:00
|
|
|
nsIURI* GetURI() const
|
|
|
|
{
|
|
|
|
return mURI;
|
|
|
|
}
|
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
void CreateSearchParamsIfNeeded();
|
|
|
|
|
|
|
|
void SetSearchInternal(const nsAString& aSearch);
|
|
|
|
|
2014-02-03 20:48:38 +04:00
|
|
|
void UpdateURLSearchParams();
|
|
|
|
|
2013-10-10 10:56:01 +04:00
|
|
|
static void CreateObjectURLInternal(const GlobalObject& aGlobal,
|
|
|
|
nsISupports* aObject,
|
2013-01-28 15:08:21 +04:00
|
|
|
const nsACString& aScheme,
|
2013-09-04 21:07:21 +04:00
|
|
|
const objectURLOptions& aOptions,
|
2015-02-27 22:10:20 +03:00
|
|
|
nsAString& aResult,
|
2013-09-04 21:07:21 +04:00
|
|
|
ErrorResult& aError);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
2013-12-12 23:30:27 +04:00
|
|
|
nsRefPtr<URLSearchParams> mSearchParams;
|
2013-09-04 21:07:34 +04:00
|
|
|
|
|
|
|
friend class mozilla::dom::workers::URLProxy;
|
2013-01-28 15:08:21 +04:00
|
|
|
};
|
|
|
|
|
2013-11-20 20:29:03 +04:00
|
|
|
bool IsChromeURI(nsIURI* aURI);
|
|
|
|
|
2013-01-28 15:08:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* URL_h___ */
|