| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.tab; | 5 package org.chromium.chrome.browser.tab; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.net.MailTo; | 9 import android.net.MailTo; |
| 10 import android.net.Uri; | 10 import android.net.Uri; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 import java.net.URI; | 33 import java.net.URI; |
| 34 import java.util.Locale; | 34 import java.util.Locale; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * A default {@link ContextMenuItemDelegate} that supports the context menu func
tionality in Tab. | 37 * A default {@link ContextMenuItemDelegate} that supports the context menu func
tionality in Tab. |
| 38 */ | 38 */ |
| 39 public class TabContextMenuItemDelegate implements ContextMenuItemDelegate { | 39 public class TabContextMenuItemDelegate implements ContextMenuItemDelegate { |
| 40 public static final String PAGESPEED_PASSTHROUGH_HEADERS = | 40 public static final String PAGESPEED_PASSTHROUGH_HEADERS = |
| 41 "Chrome-Proxy: pass-through\nCache-Control: no-cache"; | 41 "Chrome-Proxy: pass-through\nCache-Control: no-cache"; |
| 42 | 42 |
| 43 private final Clipboard mClipboard; | |
| 44 private final Tab mTab; | 43 private final Tab mTab; |
| 45 private boolean mLoadOriginalImageRequestedForPageLoad; | 44 private boolean mLoadOriginalImageRequestedForPageLoad; |
| 46 private EmptyTabObserver mDataReductionProxyContextMenuTabObserver; | 45 private EmptyTabObserver mDataReductionProxyContextMenuTabObserver; |
| 47 | 46 |
| 48 /** | 47 /** |
| 49 * Builds a {@link TabContextMenuItemDelegate} instance. | 48 * Builds a {@link TabContextMenuItemDelegate} instance. |
| 50 */ | 49 */ |
| 51 public TabContextMenuItemDelegate(Tab tab) { | 50 public TabContextMenuItemDelegate(Tab tab) { |
| 52 mTab = tab; | 51 mTab = tab; |
| 53 mClipboard = new Clipboard(mTab.getApplicationContext()); | |
| 54 mDataReductionProxyContextMenuTabObserver = new EmptyTabObserver() { | 52 mDataReductionProxyContextMenuTabObserver = new EmptyTabObserver() { |
| 55 @Override | 53 @Override |
| 56 public void onPageLoadStarted(Tab tab, String url) { | 54 public void onPageLoadStarted(Tab tab, String url) { |
| 57 mLoadOriginalImageRequestedForPageLoad = false; | 55 mLoadOriginalImageRequestedForPageLoad = false; |
| 58 } | 56 } |
| 59 }; | 57 }; |
| 60 mTab.addObserver(mDataReductionProxyContextMenuTabObserver); | 58 mTab.addObserver(mDataReductionProxyContextMenuTabObserver); |
| 61 } | 59 } |
| 62 | 60 |
| 63 @Override | 61 @Override |
| (...skipping 21 matching lines...) Expand all Loading... |
| 85 return isSpdyProxyEnabledForUrl(url); | 83 return isSpdyProxyEnabledForUrl(url); |
| 86 } | 84 } |
| 87 | 85 |
| 88 @Override | 86 @Override |
| 89 public boolean startDownload(String url, boolean isLink) { | 87 public boolean startDownload(String url, boolean isLink) { |
| 90 return !isLink || !mTab.shouldInterceptContextMenuDownload(url); | 88 return !isLink || !mTab.shouldInterceptContextMenuDownload(url); |
| 91 } | 89 } |
| 92 | 90 |
| 93 @Override | 91 @Override |
| 94 public void onSaveToClipboard(String text, int clipboardType) { | 92 public void onSaveToClipboard(String text, int clipboardType) { |
| 95 mClipboard.setText(text); | 93 Clipboard.getInstance().setText(text); |
| 96 } | 94 } |
| 97 | 95 |
| 98 @Override | 96 @Override |
| 99 public boolean supportsCall() { | 97 public boolean supportsCall() { |
| 100 Intent intent = new Intent(Intent.ACTION_VIEW); | 98 Intent intent = new Intent(Intent.ACTION_VIEW); |
| 101 intent.setData(Uri.parse("tel:")); | 99 intent.setData(Uri.parse("tel:")); |
| 102 return mTab.getWindowAndroid().canResolveActivity(intent); | 100 return mTab.getWindowAndroid().canResolveActivity(intent); |
| 103 } | 101 } |
| 104 | 102 |
| 105 @Override | 103 @Override |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled
() | 285 if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled
() |
| 288 && url != null && !url.toLowerCase(Locale.US).startsWith( | 286 && url != null && !url.toLowerCase(Locale.US).startsWith( |
| 289 UrlConstants.HTTPS_URL_PREFIX) | 287 UrlConstants.HTTPS_URL_PREFIX) |
| 290 && !isIncognito()) { | 288 && !isIncognito()) { |
| 291 return true; | 289 return true; |
| 292 } | 290 } |
| 293 return false; | 291 return false; |
| 294 } | 292 } |
| 295 | 293 |
| 296 } | 294 } |
| OLD | NEW |