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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuHandler.java

Issue 2505533003: 📰 Make NTP Tiles show download link when appropriate (Closed)
Patch Set: style Created 4 years, 1 month 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/MostVisitedItem.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuHandler.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuHandler.java
index 3752485e7c26e672950bd4aaba524f66d6669256..e3359e5292f4344dc3c67ee5e5ef906ddff0327c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuHandler.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuHandler.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.ntp;
import android.support.annotation.IntDef;
+import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.view.ContextMenu;
import android.view.Menu;
@@ -15,6 +16,8 @@
import org.chromium.base.Callback;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
+import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig;
+import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
import org.chromium.ui.mojom.WindowOpenDisposition;
import java.lang.annotation.Retention;
@@ -46,8 +49,9 @@
/** Removed the current item. */
void removeItem();
- /** @return whether the current item can be saved offline. */
- boolean canBeSavedOffline();
+ /** @return the url for the the current item, or {@code null} if not applicable. */
+ @Nullable
+ String getUrl();
}
/** Interface for a view that can be set to stop responding to touches. */
@@ -72,8 +76,11 @@ public boolean showItem(@ContextMenuItemId int itemId) {
return true;
case ID_OPEN_IN_INCOGNITO_TAB:
return mManager.isOpenInIncognitoEnabled();
- case ID_SAVE_FOR_OFFLINE:
- return mDelegate.canBeSavedOffline();
+ case ID_SAVE_FOR_OFFLINE: {
+ if (!SnippetsConfig.isSaveToOfflineEnabled()) return false;
+ String itemUrl = mDelegate.getUrl();
+ return itemUrl != null && OfflinePageBridge.canSavePage(itemUrl);
+ }
case ID_REMOVE:
return true;
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/MostVisitedItem.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698