Bug 1415205 - Add nsIURIMutator interface and nsIURI.mutate() r=bagder draft
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 20 Nov 2017 16:10:03 +0100
changeset 701159 7deeb367424056f3e86bf42e77326bf1414a809a
parent 700576 5c48b5edfc4ca945a2eaa5896454f3f4efa9052a
child 701160 e146624c5ae423f7f69a738aaaafaa55dd0940d9
push id90095
push uservalentin.gosu@gmail.com
push dateTue, 21 Nov 2017 09:46:06 +0000
reviewersbagder
bugs1415205
milestone59.0a1
Bug 1415205 - Add nsIURIMutator interface and nsIURI.mutate() r=bagder MozReview-Commit-ID: 8TYtcLUGRPc
netwerk/base/moz.build
netwerk/base/nsIURI.idl
netwerk/base/nsIURIMutator.idl
--- 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();
+};