Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3412)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java

Issue 1542943006: [Offline pages] Removing permission prompt when accessing offline page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
index 523e226f5f9a217ee39d53c42306ce8f65aa1610..9eb276209a292f1ae6514edd2dd88ff0c42e6ce7 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
@@ -9,6 +9,8 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;
+import org.chromium.base.ApplicationStatus;
+import org.chromium.base.PathUtils;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
@@ -114,6 +116,19 @@ public class OfflinePageUtils {
}
/**
+ * Check whether the URL qualifies as offline URL for the purpose of storage permission check.
+ * @param url A URL to check.
+ * @return <code>true</code> if the URL qualifies as an offline page URL, <code>false</code>
+ * otherwise.
+ */
+ public static boolean isOfflineUrlForStoragePermissionCheck(String url) {
+ Context context = ApplicationStatus.getApplicationContext();
+ return url != null && context != null
+ && url.startsWith("file://" + PathUtils.getDataDirectory(context))
newt (away) 2016/01/04 19:45:05 This seems prone to silent breakage if the locatio
jianli 2016/01/04 21:42:00 The name isOfflineUrlForStoragePermissionCheck sou
fgorski 2016/01/04 23:11:35 This sits inside of the profile folder and I am no
+ && url.contains("/Offline%20Pages/archives/") && url.endsWith(".mhtml");
+ }
+
+ /**
* Shows the snackbar for the current tab to provide offline specific information.
* @param activity The activity owning the tab.
* @param tabId The ID of current tab.

Powered by Google App Engine
This is Rietveld 408576698