Chromium Code Reviews| 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 10c7fc0078d3a7ffc5d428ba84b6b6c4459547ce..8e67a430680ef9cd5563eb88450ccec5d0b2bf7e 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 |
| @@ -45,6 +45,7 @@ import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.ContentSettingsType; |
| import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; |
| +import org.chromium.chrome.browser.offlinepages.OfflinePageBridge.SingleOfflinePageItemCallback; |
| import org.chromium.chrome.browser.offlinepages.OfflinePageItem; |
| import org.chromium.chrome.browser.offlinepages.OfflinePageUtils; |
| import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer; |
| @@ -901,27 +902,35 @@ public class WebsiteSettingsPopup implements OnClickListener { |
| * information is retrieved for the visible entry. |
| * @param contentPublisher The name of the publisher of the content. |
| */ |
| - public static void show(Activity activity, Tab tab, String contentPublisher) { |
| - WebContents webContents = tab.getWebContents(); |
| - String offlinePageOriginalUrl = null; |
| - String offlinePageCreationDate = null; |
| - |
| - if (tab.isOfflinePage()) { |
| - OfflinePageBridge offlinePageBridge = OfflinePageBridge.getForProfile(tab.getProfile()); |
| - OfflinePageItem item = |
| - offlinePageBridge.getPageByOfflineUrl(webContents.getVisibleUrl()); |
| - if (item != null) { |
| - // Get formatted creation date and original URL of the offline copy. |
| - Date creationDate = new Date(item.getCreationTimeMs()); |
| - DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
| - offlinePageCreationDate = df.format(creationDate); |
| - offlinePageOriginalUrl = OfflinePageUtils.stripSchemeFromOnlineUrl( |
| - tab.getOfflinePageOriginalUrl()); |
| - } |
| + public static void show(final Activity activity, final Tab tab, final String contentPublisher) { |
| + final WebContents webContents = tab.getWebContents(); |
| + |
| + OfflinePageBridge offlinePageBridge = OfflinePageBridge.getForProfile(tab.getProfile()); |
| + if (offlinePageBridge == null) { |
| + new WebsiteSettingsPopup(activity, tab.getProfile(), webContents, |
| + null, null, contentPublisher); |
| + return; |
| } |
| - new WebsiteSettingsPopup(activity, tab.getProfile(), webContents, offlinePageOriginalUrl, |
| - offlinePageCreationDate, contentPublisher); |
| + SingleOfflinePageItemCallback callback = new SingleOfflinePageItemCallback() { |
| + @Override |
| + public void onResult(OfflinePageItem item) { |
| + String offlinePageOriginalUrl = null; |
| + String offlinePageCreationDate = null; |
| + |
| + if (item != null) { |
|
fgorski
2016/05/17 04:12:25
did you remove the comment on purpose?
// Get for
chili
2016/05/17 17:53:29
I did because it didn't seem to add any informatio
|
| + Date creationDate = new Date(item.getCreationTimeMs()); |
| + DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); |
| + offlinePageCreationDate = df.format(creationDate); |
| + offlinePageOriginalUrl = |
| + OfflinePageUtils.stripSchemeFromOnlineUrl(item.getUrl()); |
| + } |
| + new WebsiteSettingsPopup(activity, tab.getProfile(), webContents, |
|
fgorski
2016/05/17 04:12:25
tab.getWebContents() does not require final at the
chili
2016/05/17 17:53:29
It does if I set it as a variable and use it insid
|
| + offlinePageOriginalUrl, offlinePageCreationDate, contentPublisher); |
| + } |
| + }; |
| + |
| + offlinePageBridge.getPageByOfflineUrl(webContents.getVisibleUrl(), callback); |
| } |
| private static native long nativeInit(WebsiteSettingsPopup popup, WebContents webContents); |