[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 24/68: Bug 40171: Make WebRequest and GeckoWebExecutor First-Party aware



This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-91.9.0esr-11.5-1
in repository tor-browser.

commit f48033a749ffebda377192ef99d803e1be3fdcda
Author: Alex Catarineu <acat@xxxxxxxxxxxxxx>
AuthorDate: Wed Nov 4 15:58:22 2020 +0100

    Bug 40171: Make WebRequest and GeckoWebExecutor First-Party aware
---
 .../main/java/org/mozilla/geckoview/WebRequest.java    | 18 ++++++++++++++++++
 widget/android/WebExecutorSupport.cpp                  | 10 ++++++++++
 2 files changed, 28 insertions(+)

diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebRequest.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebRequest.java
index d1d6e06b73967..4e17bc034edbd 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebRequest.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebRequest.java
@@ -51,6 +51,11 @@ public class WebRequest extends WebMessage {
      */
     public final @Nullable String referrer;
 
+    /**
+     * The value of the origin of this request.
+     */
+    public final @Nullable String origin;
+
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({CACHE_MODE_DEFAULT, CACHE_MODE_NO_STORE,
             CACHE_MODE_RELOAD, CACHE_MODE_NO_CACHE,
@@ -112,6 +117,7 @@ public class WebRequest extends WebMessage {
         method = builder.mMethod;
         cacheMode = builder.mCacheMode;
         referrer = builder.mReferrer;
+        origin = builder.mOrigin;
 
         if (builder.mBody != null) {
             body = builder.mBody.asReadOnlyBuffer();
@@ -128,6 +134,7 @@ public class WebRequest extends WebMessage {
         /* package */ String mMethod = "GET";
         /* package */ int mCacheMode = CACHE_MODE_DEFAULT;
         /* package */ String mReferrer;
+        /* package */ String mOrigin;
 
         /**
          * Construct a Builder instance with the specified URI.
@@ -226,6 +233,17 @@ public class WebRequest extends WebMessage {
             return this;
         }
 
+        /**
+         * Set the origin URI.
+         *
+         * @param origin A URI String
+         * @return This Builder instance.
+         */
+        public @NonNull Builder origin(final @Nullable String origin) {
+            mOrigin = origin;
+            return this;
+        }
+
         /**
          * @return A {@link WebRequest} constructed with the values from this Builder instance.
          */
diff --git a/widget/android/WebExecutorSupport.cpp b/widget/android/WebExecutorSupport.cpp
index 99e7de95a0fb6..bbdcc8f36bd6f 100644
--- a/widget/android/WebExecutorSupport.cpp
+++ b/widget/android/WebExecutorSupport.cpp
@@ -393,6 +393,16 @@ nsresult WebExecutorSupport::CreateStreamLoader(
   MOZ_ASSERT(cookieJarSettings);
 
   nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
+
+  RefPtr<nsIURI> originUri;
+  const auto origin = req->Origin();
+  if (origin) {
+    rv = NS_NewURI(getter_AddRefs(originUri), origin->ToString());
+    NS_ENSURE_SUCCESS(rv, NS_ERROR_MALFORMED_URI);
+    OriginAttributes attrs = loadInfo->GetOriginAttributes();
+    attrs.SetFirstPartyDomain(true, originUri);
+    loadInfo->SetOriginAttributes(attrs);
+  }
   loadInfo->SetCookieJarSettings(cookieJarSettings);
 
   // setup http/https specific things

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits