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

gitolite role git at cupani.torproject.org
Wed May 4 20:45:19 UTC 2022


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

richard pushed a commit to branch geckoview-96.0.3-11.0-1
in repository tor-browser.

commit f9a777f0631ef7f66ea99f0ac09ef6dc67a2acb6
Author: Alex Catarineu <acat at torproject.org>
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 17c4e1cd4f350..26c36b659c6ff 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
@@ -43,6 +43,11 @@ public class WebRequest extends WebMessage {
   /** The value of the Referer header for this request. */
   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,
@@ -103,6 +108,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();
@@ -117,6 +123,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.
@@ -215,6 +222,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. */
     public @NonNull WebRequest build() {
       if (mUri == null) {
diff --git a/widget/android/WebExecutorSupport.cpp b/widget/android/WebExecutorSupport.cpp
index 966192fbfa494..05ae49e037974 100644
--- a/widget/android/WebExecutorSupport.cpp
+++ b/widget/android/WebExecutorSupport.cpp
@@ -390,6 +390,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.


More information about the tor-commits mailing list