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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java

Issue 2245733004: Serve offline page for online URL on disconnected or bad networks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comment in test Created 4 years, 4 months 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/pageinfo/WebsiteSettingsPopup.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java b/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java
index 569aa704fd55a285ecececd73e466c92940b942c..32d027ff75f8b2be5e7e5d4927a0f752852295fb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java
@@ -287,9 +287,6 @@ public class WebsiteSettingsPopup implements OnClickListener {
// Permissions available to be displayed in mPermissionsList.
private List<PageInfoPermissionEntry> mDisplayedPermissions;
- // Original URL of an offline copy, if web contents contains an offline page.
- private String mOfflinePageOriginalUrl;
-
// Creation date of an offline copy, if web contents contains an offline page.
private String mOfflinePageCreationDate;
@@ -299,17 +296,19 @@ public class WebsiteSettingsPopup implements OnClickListener {
/**
* Creates the WebsiteSettingsPopup, but does not display it. Also initializes the corresponding
* C++ object and saves a pointer to it.
- * @param webContents The WebContents for which to show Website information. This information is
- * retrieved for the visible entry.
- * @param publisher The name of the content publisher, if any.
+ * @param activity Activity which is used for showing a popup.
+ * @param profile Profile of the tab that will show the popup.
+ * @param webContents The WebContents for which to show Website information. This
+ * information is retrieved for the visible entry.
+ * @param offlinePageCreationDate Date when the offline page was created.
+ * @param publisher The name of the content publisher, if any.
*/
private WebsiteSettingsPopup(Activity activity, Profile profile, WebContents webContents,
- String offlinePageOriginalUrl, String offlinePageCreationDate, String publisher) {
+ String offlinePageCreationDate, String publisher) {
mContext = activity;
mProfile = profile;
mWebContents = webContents;
- if (offlinePageOriginalUrl != null && offlinePageCreationDate != null) {
- mOfflinePageOriginalUrl = offlinePageOriginalUrl;
+ if (offlinePageCreationDate != null) {
mOfflinePageCreationDate = offlinePageCreationDate;
}
mWindowAndroid = ContentViewCore.fromWebContents(mWebContents).getWindowAndroid();
@@ -432,14 +431,12 @@ public class WebsiteSettingsPopup implements OnClickListener {
});
// Work out the URL and connection message and status visibility.
- int statusIconVisibility = View.GONE;
+ mFullUrl = mWebContents.getVisibleUrl();
if (isShowingOfflinePage()) {
- mFullUrl = mOfflinePageOriginalUrl;
- statusIconVisibility = View.VISIBLE;
- } else {
- mFullUrl = mWebContents.getVisibleUrl();
+ mFullUrl = OfflinePageUtils.stripSchemeFromOnlineUrl(mFullUrl);
}
+ int statusIconVisibility = isShowingOfflinePage() ? View.VISIBLE : View.GONE;
mContainer.findViewById(R.id.offline_icon).setVisibility(statusIconVisibility);
try {
@@ -905,7 +902,7 @@ public class WebsiteSettingsPopup implements OnClickListener {
* Whether website dialog is displayed for an offline page.
*/
private boolean isShowingOfflinePage() {
- return mOfflinePageOriginalUrl != null && mOfflinePageCreationDate != null;
+ return mOfflinePageCreationDate != null;
}
/**
@@ -928,7 +925,6 @@ public class WebsiteSettingsPopup implements OnClickListener {
assert false : "Invalid source passed";
}
- String offlinePageOriginalUrl = null;
String offlinePageCreationDate = null;
OfflinePageItem offlinePage = tab.getOfflinePage();
@@ -937,12 +933,10 @@ public class WebsiteSettingsPopup implements OnClickListener {
Date creationDate = new Date(offlinePage.getCreationTimeMs());
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
offlinePageCreationDate = df.format(creationDate);
- offlinePageOriginalUrl = OfflinePageUtils.stripSchemeFromOnlineUrl(
- offlinePage.getUrl());
}
new WebsiteSettingsPopup(activity, tab.getProfile(), tab.getWebContents(),
- offlinePageOriginalUrl, offlinePageCreationDate, contentPublisher);
+ offlinePageCreationDate, contentPublisher);
}
private static native long nativeInit(WebsiteSettingsPopup popup, WebContents webContents);

Powered by Google App Engine
This is Rietveld 408576698