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

[tor-commits] [tor-browser] 60/63: 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 geckoview-102.2.0esr-12.0-1
in repository tor-browser.

commit 852568c9fe991d1344e90e60559620978bf74eee
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 6d4f37ebf3710..a2e43def0b4d1 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
@@ -40,6 +40,11 @@ public class WebRequest extends WebMessage {
    */
   public final @CacheMode int cacheMode;
 
+  /**
+   * The value of the origin of this request.
+   */
+  public final @Nullable String origin;
+
   /**
    * If true, do not use newer protocol features that might have interop problems on the Internet.
    * Intended only for use with critical infrastructure.
@@ -110,6 +115,7 @@ public class WebRequest extends WebMessage {
     cacheMode = builder.mCacheMode;
     referrer = builder.mReferrer;
     beConservative = builder.mBeConservative;
+    origin = builder.mOrigin;
 
     if (builder.mBody != null) {
       body = builder.mBody.asReadOnlyBuffer();
@@ -125,6 +131,7 @@ public class WebRequest extends WebMessage {
     /* package */ int mCacheMode = CACHE_MODE_DEFAULT;
     /* package */ String mReferrer;
     /* package */ boolean mBeConservative;
+    /* package */ String mOrigin;
 
     /**
      * Construct a Builder instance with the specified URI.
@@ -235,6 +242,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 21cda516da08c..027ec2e7fb525 100644
--- a/widget/android/WebExecutorSupport.cpp
+++ b/widget/android/WebExecutorSupport.cpp
@@ -395,6 +395,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