OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.contextmenu; | 5 package org.chromium.chrome.browser.contextmenu; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.net.MailTo; | 8 import android.net.MailTo; |
9 import android.support.annotation.IntDef; | 9 import android.support.annotation.IntDef; |
10 import android.support.annotation.StringRes; | 10 import android.support.annotation.StringRes; |
11 import android.text.TextUtils; | 11 import android.text.TextUtils; |
12 import android.util.Pair; | 12 import android.util.Pair; |
13 import android.view.ContextMenu; | 13 import android.view.ContextMenu; |
14 import android.webkit.MimeTypeMap; | 14 import android.webkit.MimeTypeMap; |
15 | 15 |
16 import org.chromium.base.CollectionUtil; | 16 import org.chromium.base.CollectionUtil; |
17 import org.chromium.base.CommandLine; | |
18 import org.chromium.base.metrics.RecordHistogram; | 17 import org.chromium.base.metrics.RecordHistogram; |
19 import org.chromium.chrome.R; | 18 import org.chromium.chrome.R; |
20 import org.chromium.chrome.browser.ChromeFeatureList; | 19 import org.chromium.chrome.browser.ChromeFeatureList; |
21 import org.chromium.chrome.browser.ChromeSwitches; | |
22 import org.chromium.chrome.browser.firstrun.FirstRunStatus; | 20 import org.chromium.chrome.browser.firstrun.FirstRunStatus; |
23 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; | 21 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
24 import org.chromium.chrome.browser.preferences.datareduction.DataReductionProxyU
ma; | 22 import org.chromium.chrome.browser.preferences.datareduction.DataReductionProxyU
ma; |
25 import org.chromium.chrome.browser.search_engines.TemplateUrlService; | 23 import org.chromium.chrome.browser.search_engines.TemplateUrlService; |
26 import org.chromium.chrome.browser.util.UrlUtilities; | 24 import org.chromium.chrome.browser.util.UrlUtilities; |
27 import org.chromium.content_public.common.ContentUrlConstants; | 25 import org.chromium.content_public.common.ContentUrlConstants; |
28 | 26 |
29 import java.lang.annotation.Retention; | 27 import java.lang.annotation.Retention; |
30 import java.lang.annotation.RetentionPolicy; | 28 import java.lang.annotation.RetentionPolicy; |
31 import java.net.URI; | 29 import java.net.URI; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 titleText = params.getTitleText(); | 249 titleText = params.getTitleText(); |
252 } | 250 } |
253 return titleText; | 251 return titleText; |
254 } | 252 } |
255 | 253 |
256 @Override | 254 @Override |
257 public List<Pair<Integer, List<ContextMenuItem>>> buildContextMenu( | 255 public List<Pair<Integer, List<ContextMenuItem>>> buildContextMenu( |
258 ContextMenu menu, Context context, ContextMenuParams params) { | 256 ContextMenu menu, Context context, ContextMenuParams params) { |
259 // Add all items in a group | 257 // Add all items in a group |
260 Set<ContextMenuItem> supportedOptions = new HashSet<>(); | 258 Set<ContextMenuItem> supportedOptions = new HashSet<>(); |
261 // Limit context menu to copying until FRE has been completed, | 259 if (FirstRunStatus.getFirstRunFlowComplete()) { |
262 // unless FRE has been explicitly disabled (for full context menu in tes
ts). | |
263 if (FirstRunStatus.getFirstRunFlowComplete() | |
264 || CommandLine.getInstance().hasSwitch( | |
265 ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)) { | |
266 supportedOptions.addAll(BASE_WHITELIST); | 260 supportedOptions.addAll(BASE_WHITELIST); |
267 if (mMode == FULLSCREEN_TAB_MODE) { | 261 if (mMode == FULLSCREEN_TAB_MODE) { |
268 supportedOptions.addAll(FULLSCREEN_TAB_MODE_WHITELIST); | 262 supportedOptions.addAll(FULLSCREEN_TAB_MODE_WHITELIST); |
269 } else if (mMode == CUSTOM_TAB_MODE) { | 263 } else if (mMode == CUSTOM_TAB_MODE) { |
270 supportedOptions.addAll(CUSTOM_TAB_MODE_WHITELIST); | 264 supportedOptions.addAll(CUSTOM_TAB_MODE_WHITELIST); |
271 } else { | 265 } else { |
272 supportedOptions.addAll(NORMAL_MODE_WHITELIST); | 266 supportedOptions.addAll(NORMAL_MODE_WHITELIST); |
273 } | 267 } |
274 } else { | 268 } else { |
275 supportedOptions.add(ChromeContextMenuItem.COPY_LINK_ADDRESS); | 269 supportedOptions.add(ChromeContextMenuItem.COPY_LINK_ADDRESS); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 * @param params The {@link ContextMenuParams} to check. | 657 * @param params The {@link ContextMenuParams} to check. |
664 */ | 658 */ |
665 private String getUrl(ContextMenuParams params) { | 659 private String getUrl(ContextMenuParams params) { |
666 if (params.isAnchor()) { | 660 if (params.isAnchor()) { |
667 return params.getLinkUrl(); | 661 return params.getLinkUrl(); |
668 } else { | 662 } else { |
669 return params.getSrcUrl(); | 663 return params.getSrcUrl(); |
670 } | 664 } |
671 } | 665 } |
672 } | 666 } |
OLD | NEW |