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..8354eee2ed65f69f3ba0e763f6937165e88953ff 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,30 @@ 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()); |
|
dewittj
2016/05/16 21:07:46
The bridge can be null if offline pages is not ena
chili
2016/05/16 23:06:41
Checking for null now. How do I check for enabled
fgorski
2016/05/17 04:12:25
In case of offline pages: OfflinePageBridge#isOffl
|
| + |
| + SingleOfflinePageItemCallback callback = new SingleOfflinePageItemCallback() { |
| + @Override |
| + public void onResult(OfflinePageItem item) { |
| + String offlinePageOriginalUrl = null; |
| + String offlinePageCreationDate = null; |
| + |
| + if (item != null) { |
| + 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, |
| + offlinePageOriginalUrl, offlinePageCreationDate, contentPublisher); |
| } |
| - } |
| + }; |
| - new WebsiteSettingsPopup(activity, tab.getProfile(), webContents, offlinePageOriginalUrl, |
| - offlinePageCreationDate, contentPublisher); |
| + offlinePageBridge.getPageByOfflineUrl(webContents.getVisibleUrl(), callback); |
| } |
| private static native long nativeInit(WebsiteSettingsPopup popup, WebContents webContents); |