[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/tor-browser-60.2.1esr-8.5-1] Bug 1448305 - Avoid disk cache for icons of private tabs. r=JanH
commit c04236287b17b1e8a3ca2a30344d2fe718cae788
Author: Rob Wu <rob@xxxxxxxx>
Date: Thu Jun 21 15:35:39 2018 +0200
Bug 1448305 - Avoid disk cache for icons of private tabs. r=JanH
---
.../mozilla/gecko/icons/TestIconRequestBuilder.java | 21 +++++++++++++++++++++
mobile/android/base/java/org/mozilla/gecko/Tab.java | 1 +
.../java/org/mozilla/gecko/icons/IconRequest.java | 9 +++++++++
.../org/mozilla/gecko/icons/IconRequestBuilder.java | 10 ++++++++++
.../gecko/icons/processing/DiskProcessor.java | 2 +-
5 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/mobile/android/app/src/test/java/org/mozilla/gecko/icons/TestIconRequestBuilder.java b/mobile/android/app/src/test/java/org/mozilla/gecko/icons/TestIconRequestBuilder.java
index 620caa9f70d0..066febaf2b93 100644
--- a/mobile/android/app/src/test/java/org/mozilla/gecko/icons/TestIconRequestBuilder.java
+++ b/mobile/android/app/src/test/java/org/mozilla/gecko/icons/TestIconRequestBuilder.java
@@ -85,6 +85,27 @@ public class TestIconRequestBuilder {
}
@Test
+ public void testPrivateMode() {
+ IconRequest request = Icons.with(RuntimeEnvironment.application)
+ .pageUrl(TEST_PAGE_URL_1)
+ .build();
+
+ Assert.assertFalse(request.isPrivateMode());
+
+ request.modify()
+ .setPrivateMode(true)
+ .deferBuild();
+
+ Assert.assertTrue(request.isPrivateMode());
+
+ request.modify()
+ .setPrivateMode(false)
+ .deferBuild();
+
+ Assert.assertFalse(request.isPrivateMode());
+ }
+
+ @Test
public void testSkipNetwork() {
IconRequest request = Icons.with(RuntimeEnvironment.application)
.pageUrl(TEST_PAGE_URL_1)
diff --git a/mobile/android/base/java/org/mozilla/gecko/Tab.java b/mobile/android/base/java/org/mozilla/gecko/Tab.java
index 8b84a2c7db66..91c1d1571435 100644
--- a/mobile/android/base/java/org/mozilla/gecko/Tab.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tab.java
@@ -443,6 +443,7 @@ public class Tab {
}
mRunningIconRequest = mIconRequestBuilder
+ .setPrivateMode(isPrivate())
.build()
.execute(new IconCallback() {
@Override
diff --git a/mobile/android/base/java/org/mozilla/gecko/icons/IconRequest.java b/mobile/android/base/java/org/mozilla/gecko/icons/IconRequest.java
index 8161b9510f3f..da74a8fb5318 100644
--- a/mobile/android/base/java/org/mozilla/gecko/icons/IconRequest.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/IconRequest.java
@@ -23,6 +23,7 @@ public class IconRequest {
// Those values are written by the IconRequestBuilder class.
/* package-private */ String pageUrl;
/* package-private */ boolean privileged;
+ /* package-private */ boolean isPrivate;
/* package-private */ TreeSet<IconDescriptor> icons;
/* package-private */ boolean skipNetwork;
/* package-private */ boolean backgroundThread;
@@ -40,6 +41,7 @@ public class IconRequest {
// Setting some sensible defaults.
this.privileged = false;
+ this.isPrivate = false;
this.skipMemory = false;
this.skipDisk = false;
this.skipNetwork = false;
@@ -97,6 +99,13 @@ public class IconRequest {
}
/**
+ * Is this request initiated from a tab in private browsing mode?
+ */
+ public boolean isPrivateMode() {
+ return isPrivate;
+ }
+
+ /**
* Get the number of icon descriptors associated with this request.
*/
public int getIconCount() {
diff --git a/mobile/android/base/java/org/mozilla/gecko/icons/IconRequestBuilder.java b/mobile/android/base/java/org/mozilla/gecko/icons/IconRequestBuilder.java
index ddae3b64bc64..b2fb46e3a39f 100644
--- a/mobile/android/base/java/org/mozilla/gecko/icons/IconRequestBuilder.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/IconRequestBuilder.java
@@ -62,6 +62,15 @@ public class IconRequestBuilder {
}
/**
+ * Set the private mode to avoid saving the result to the disk.
+ */
+ @CheckResult
+ public IconRequestBuilder setPrivateMode(boolean isPrivate) {
+ internal.isPrivate = isPrivate;
+ return this;
+ }
+
+ /**
* Skip the network and do not load an icon from a network connection.
*/
@CheckResult
@@ -165,6 +174,7 @@ public class IconRequestBuilder {
IconRequest request = new IconRequest(internal.getContext());
request.pageUrl = internal.pageUrl;
request.privileged = internal.privileged;
+ request.isPrivate = internal.isPrivate;
request.icons = new TreeSet<>(internal.icons);
request.skipNetwork = internal.skipNetwork;
request.backgroundThread = internal.backgroundThread;
diff --git a/mobile/android/base/java/org/mozilla/gecko/icons/processing/DiskProcessor.java b/mobile/android/base/java/org/mozilla/gecko/icons/processing/DiskProcessor.java
index 150aa503b83e..4923c6fc93c4 100644
--- a/mobile/android/base/java/org/mozilla/gecko/icons/processing/DiskProcessor.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/processing/DiskProcessor.java
@@ -8,7 +8,7 @@ import org.mozilla.gecko.util.StringUtils;
public class DiskProcessor implements Processor {
@Override
public void process(IconRequest request, IconResponse response) {
- if (request.shouldSkipDisk()) {
+ if (request.shouldSkipDisk() || request.isPrivateMode()) {
return;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits