Bug 1415205 - Add nsIURIMutator interface and nsIURI.mutate() r=bagder
MozReview-Commit-ID: 8TYtcLUGRPc
--- a/netwerk/base/moz.build
+++ b/netwerk/base/moz.build
@@ -120,16 +120,17 @@ XPIDL_SOURCES += [
'nsITraceableChannel.idl',
'nsITransport.idl',
'nsIUDPSocket.idl',
'nsIUnicharStreamLoader.idl',
'nsIUploadChannel.idl',
'nsIUploadChannel2.idl',
'nsIURI.idl',
'nsIURIClassifier.idl',
+ 'nsIURIMutator.idl',
'nsIURIWithBlobImpl.idl',
'nsIURIWithPrincipal.idl',
'nsIURL.idl',
'nsIURLParser.idl',
'nsPILoadGroupInternal.idl',
'nsPISocketTransportService.idl',
]
--- a/netwerk/base/nsIURI.idl
+++ b/netwerk/base/nsIURI.idl
@@ -42,16 +42,17 @@
#undef SetPort // XXX Windows!
namespace mozilla {
class Encoding;
}
%}
[ptr] native Encoding(const mozilla::Encoding);
+interface nsIURIMutator;
/**
* nsIURI - interface for an uniform resource identifier w/ i18n support.
*
* AUTF8String attributes may contain unescaped UTF-8 characters.
* Consumers should be careful to escape the UTF-8 strings as necessary, but
* should always try to "display" the UTF-8 version as provided by this
* interface.
@@ -322,9 +323,17 @@ interface nsIURI : nsISupports
readonly attribute AUTF8String displaySpec;
/**
* Returns the same as calling .prePath, only with a UTF8 encoded hostname
* (if that hostname doesn't contain blacklisted characters, and
* the network.IDN_show_punycode pref is false)
*/
readonly attribute AUTF8String displayPrePath;
+
+ /**
+ * Returns an nsIURIMutator that can be used to make changes to the URI.
+ * After performing the setter operations on the mutator, one may call
+ * mutator.finalize() to get a new immutable URI with the desired
+ * properties.
+ */
+ nsIURIMutator mutate();
};
new file mode 100644
--- /dev/null
+++ b/netwerk/base/nsIURIMutator.idl
@@ -0,0 +1,45 @@
+/* -*- 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/. */
+
+#include "nsISupports.idl"
+interface nsIURI;
+
+%{C++
+#include "nsStringGlue.h"
+
+#undef GetPort // XXX Windows!
+#undef SetPort // XXX Windows!
+
+namespace mozilla {
+class Encoding;
+}
+%}
+
+[ptr] native Encoding(const mozilla::Encoding);
+
+[scriptable, builtinclass, uuid(5403a6ec-99d7-405e-8b45-9f805bbdfcef)]
+interface nsIURISetters : nsISupports
+{
+ void setSpec(in AUTF8String aSpec);
+ void setScheme(in AUTF8String aScheme);
+ void setUserPass(in AUTF8String aUserPass);
+ void setUsername(in AUTF8String aUsername);
+ void setPassword(in AUTF8String aPassword);
+ void setHostPort(in AUTF8String aHostPort);
+ void setHostAndPort(in AUTF8String aHostAndPort);
+ void setHost(in AUTF8String aHost);
+ void setPort(in long aPort);
+ void setPathQueryRef(in AUTF8String aPathQueryRef);
+ void setRef(in AUTF8String aRef);
+ void setFilePath(in AUTF8String aFilePath);
+ void setQuery(in AUTF8String aQuery);
+ [noscript] void setQueryWithEncoding(in AUTF8String query, in Encoding encoding);
+};
+
+[scriptable, builtinclass, uuid(4d1f3103-1c44-4dcd-b717-5d22a697a7d9)]
+interface nsIURIMutator : nsIURISetters
+{
+ nsIURI finalize();
+};