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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java

Issue 1404793006: Remove certain context menu items for images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: newt's nits Created 5 years, 2 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/tab/TabContextMenuItemDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java
index d9e083f96375223e8fcade2b53694bf54117276e..c0ed65ec5f55e4558e66225efd082347b5cd8698 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java
@@ -4,8 +4,6 @@
package org.chromium.chrome.browser.tab;
-import android.text.TextUtils;
-
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.contextmenu.ContextMenuItemDelegate;
@@ -23,55 +21,17 @@ import java.util.Locale;
* A default {@link ContextMenuItemDelegate} that supports the context menu functionality in Tab.
*/
public class TabContextMenuItemDelegate implements ContextMenuItemDelegate {
- public static final String PAGESPEED_PASSTHROUGH_HEADERS =
- "Chrome-Proxy: pass-through\nCache-Control: no-cache";
-
private final Clipboard mClipboard;
private final Tab mTab;
private final ChromeActivity mActivity;
/**
- * The data reduction proxy was in use on the last page load if true.
- */
- protected boolean mUsedSpdyProxy;
-
- /**
- * The data reduction proxy was in pass through mode on the last page load if true.
- */
- protected boolean mUsedSpdyProxyWithPassthrough;
-
- /**
- * The last page load had request headers indicating that the data reduction proxy should
- * be put in pass through mode, if true.
- */
- protected boolean mLastPageLoadHasSpdyProxyPassthroughHeaders;
-
- /**
* Builds a {@link TabContextMenuItemDelegate} instance.
*/
public TabContextMenuItemDelegate(Tab tab, ChromeActivity activity) {
mTab = tab;
mActivity = activity;
mClipboard = new Clipboard(mTab.getApplicationContext());
- mTab.addObserver(new EmptyTabObserver() {
- @Override
- public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) {
- super.onLoadUrl(tab, params, loadType);
- // The data reduction proxy can only be set to pass through mode via loading an
- // image in a new tab. We squirrel away whether pass through mode was set, and check
- // it in: @see TabWebContentsDelegateAndroid#onLoadStopped()
- mLastPageLoadHasSpdyProxyPassthroughHeaders = false;
- if (TextUtils.equals(params.getVerbatimHeaders(), PAGESPEED_PASSTHROUGH_HEADERS)) {
- mLastPageLoadHasSpdyProxyPassthroughHeaders = true;
- }
- }
-
- @Override
- public void onPageLoadFinished(Tab tab) {
- super.onPageLoadFinished(tab);
- maybeSetDataReductionProxyUsed();
- }
- });
}
@Override
@@ -85,11 +45,6 @@ public class TabContextMenuItemDelegate implements ContextMenuItemDelegate {
}
@Override
- public boolean canLoadOriginalImage() {
- return mUsedSpdyProxy && !mUsedSpdyProxyWithPassthrough;
- }
-
- @Override
public boolean isDataReductionProxyEnabledForURL(String url) {
return isSpdyProxyEnabledForUrl(url);
}
@@ -105,11 +60,6 @@ public class TabContextMenuItemDelegate implements ContextMenuItemDelegate {
}
@Override
- public void onSaveImageToClipboard(String url) {
- mClipboard.setHTMLText("<img src=\"" + url + "\">", url, url);
- }
-
- @Override
public void onOpenInNewTab(String url, Referrer referrer) {
RecordUserAction.record("MobileNewTabOpened");
LoadUrlParams loadUrlParams = new LoadUrlParams(url);
@@ -148,22 +98,12 @@ public class TabContextMenuItemDelegate implements ContextMenuItemDelegate {
mTab.loadUrl(loadUrlParams);
}
- @Override
- public void onOpenImageInNewTab(String url, Referrer referrer) {
- boolean useOriginal = isSpdyProxyEnabledForUrl(url);
- LoadUrlParams loadUrlParams = new LoadUrlParams(url);
- loadUrlParams.setVerbatimHeaders(useOriginal ? PAGESPEED_PASSTHROUGH_HEADERS : null);
- loadUrlParams.setReferrer(referrer);
- mActivity.getTabModelSelector().openNewTab(loadUrlParams,
- TabLaunchType.FROM_LONGPRESS_BACKGROUND, mTab, isIncognito());
- }
-
/**
* Checks if spdy proxy is enabled for input url.
* @param url Input url to check for spdy setting.
* @return true if url is enabled for spdy proxy.
*/
- boolean isSpdyProxyEnabledForUrl(String url) {
+ private boolean isSpdyProxyEnabledForUrl(String url) {
if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()
&& url != null && !url.toLowerCase(Locale.US).startsWith("https://")
&& !isIncognito()) {
@@ -171,25 +111,4 @@ public class TabContextMenuItemDelegate implements ContextMenuItemDelegate {
}
return false;
}
-
- /**
- * Remember if the last load used the data reduction proxy, and if so,
- * also remember if it used pass through mode.
- */
- private void maybeSetDataReductionProxyUsed() {
- // Ignore internal URLs.
- String url = mTab.getUrl();
- if (url != null && url.toLowerCase(Locale.US).startsWith("chrome://")) {
- return;
- }
- mUsedSpdyProxy = false;
- mUsedSpdyProxyWithPassthrough = false;
- if (isSpdyProxyEnabledForUrl(url)) {
- mUsedSpdyProxy = true;
- if (mLastPageLoadHasSpdyProxyPassthroughHeaders) {
- mLastPageLoadHasSpdyProxyPassthroughHeaders = false;
- mUsedSpdyProxyWithPassthrough = true;
- }
- }
- }
}

Powered by Google App Engine
This is Rietveld 408576698