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

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

Issue 2507023003: [NTP] Implement reactions to snippet context menu actions. (Closed)
Patch Set: bauerb@ comments. 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 | no next file » | 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/NewTabPage.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
index 7a8158252ab8c24cea0daaa4fc29f69667e85858..da10c9b97b504c3236baca4c5df76e0506bb707d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
@@ -354,21 +354,15 @@ public class NewTabPage
mSnippetsBridge.onSuggestionOpened(article, windowOpenDisposition);
NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_SNIPPET);
- if (article.isDownload() && article.mIsDownloadedAsset) {
+ if (article.mIsDownloadedAsset) {
+ assert windowOpenDisposition == WindowOpenDisposition.CURRENT_TAB
+ || windowOpenDisposition == WindowOpenDisposition.NEW_WINDOW
+ || windowOpenDisposition == WindowOpenDisposition.NEW_FOREGROUND_TAB;
DownloadUtils.openFile(
article.getDownloadAssetFile(), article.getDownloadAssetMimeType(), false);
return;
}
- if (article.getOfflinePageOfflineId() != null) {
- // TODO(vitaliii): Handle other window dispositions.
- if (windowOpenDisposition == WindowOpenDisposition.CURRENT_TAB) {
- OfflinePageUtils.openInExistingTab(
- article.mUrl, article.getOfflinePageOfflineId(), mTab);
- }
- return;
- }
-
if (article.isRecentTab()) {
assert windowOpenDisposition == WindowOpenDisposition.CURRENT_TAB;
// TODO(vitaliii): Add a debug check that the result is true after crbug.com/662924
@@ -382,8 +376,18 @@ public class NewTabPage
NewTabPageUma.monitorContentSuggestionVisit(mTab, article.mCategory);
}
- LoadUrlParams loadUrlParams =
- new LoadUrlParams(article.mUrl, PageTransition.AUTO_BOOKMARK);
+ LoadUrlParams loadUrlParams;
+ // The snippet's offline page is ignored if the snippet is saved or opened in incognito.
+ if (article.getOfflinePageOfflineId() != null
+ && windowOpenDisposition != WindowOpenDisposition.SAVE_TO_DISK
+ && windowOpenDisposition != WindowOpenDisposition.OFF_THE_RECORD) {
+ loadUrlParams = OfflinePageUtils.getLoadUrlParamsForOpeningOfflineVersion(
+ article.mUrl, article.getOfflinePageOfflineId());
+ // Extra headers are not read in loadUrl, but verbatim headers are.
+ loadUrlParams.setVerbatimHeaders(loadUrlParams.getExtraHeadersString());
+ } else {
+ loadUrlParams = new LoadUrlParams(article.mUrl, PageTransition.AUTO_BOOKMARK);
+ }
// For article suggestions, we set the referrer. This is exploited
// to filter out these history entries for NTP tiles.
@@ -402,8 +406,6 @@ public class NewTabPage
int tabIndex = TabModelUtils.getTabIndexById(tabModel, tabId);
if (tabIndex == TabModel.INVALID_TAB_INDEX) return false;
TabModelUtils.setIndex(tabModel, tabIndex);
- assert recentTabArticle.getOfflinePageOfflineId().equals(
- Long.parseLong(recentTabArticle.getRecentTabId()));
OfflinePageUtils.openInExistingTab(recentTabArticle.mUrl,
recentTabArticle.getOfflinePageOfflineId(), tabModel.getTabAt(tabIndex));
return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698