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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java

Issue 398893006: Context menu should not shows data: in heading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Header should be linkurl or no header Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.os.Build; 8 import android.os.Build;
9 import android.text.TextUtils; 9 import android.text.TextUtils;
10 import android.view.ContextMenu; 10 import android.view.ContextMenu;
11 import android.view.MenuInflater; 11 import android.view.MenuInflater;
12 12
13 import org.chromium.chrome.R; 13 import org.chromium.chrome.R;
14 import org.chromium.chrome.browser.UrlUtilities; 14 import org.chromium.chrome.browser.UrlUtilities;
15 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 15 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
16 16
17 /** 17 /**
18 * A {@link ContextMenuPopulator} used for showing the default Chrome context me nu. 18 * A {@link ContextMenuPopulator} used for showing the default Chrome context me nu.
19 */ 19 */
20 public class ChromeContextMenuPopulator implements ContextMenuPopulator { 20 public class ChromeContextMenuPopulator implements ContextMenuPopulator {
21 private final ChromeContextMenuItemDelegate mDelegate; 21 private final ChromeContextMenuItemDelegate mDelegate;
22 private MenuInflater mMenuInflater; 22 private MenuInflater mMenuInflater;
23 private final String BLANK_URL = "about:blank";
23 24
24 /** 25 /**
25 * Builds a {@link ChromeContextMenuPopulator}. 26 * Builds a {@link ChromeContextMenuPopulator}.
26 * @param delegate The {@link ChromeContextMenuItemDelegate} that will be no tified with actions 27 * @param delegate The {@link ChromeContextMenuItemDelegate} that will be no tified with actions
27 * to perform when menu items are selected. 28 * to perform when menu items are selected.
28 */ 29 */
29 public ChromeContextMenuPopulator(ChromeContextMenuItemDelegate delegate) { 30 public ChromeContextMenuPopulator(ChromeContextMenuItemDelegate delegate) {
30 mDelegate = delegate; 31 mDelegate = delegate;
31 } 32 }
32 33
33 @Override 34 @Override
34 public boolean shouldShowContextMenu(ContextMenuParams params) { 35 public boolean shouldShowContextMenu(ContextMenuParams params) {
35 return params != null && (params.isAnchor() || params.isEditable() || pa rams.isImage() 36 return params != null && (params.isAnchor() || params.isEditable() || pa rams.isImage()
36 || params.isSelectedText() || params.isVideo() || params.isCusto mMenu()); 37 || params.isSelectedText() || params.isVideo() || params.isCusto mMenu());
37 } 38 }
38 39
39 @Override 40 @Override
40 public void buildContextMenu(ContextMenu menu, Context context, ContextMenuP arams params) { 41 public void buildContextMenu(ContextMenu menu, Context context, ContextMenuP arams params) {
41 if (params.isImage() && !TextUtils.isEmpty(params.getSrcUrl())) 42 if (!TextUtils.isEmpty(params.getLinkUrl()) && !params.getLinkUrl().star tsWith(BLANK_URL))
Bernhard Bauer 2014/07/28 07:51:18 params.getLinkUrl().equals(BLANK_URL)?
Jitu( very slow this week) 2014/07/28 08:01:49 Done.
42 menu.setHeaderTitle(params.getSrcUrl()); 43 menu.setHeaderTitle(params.getLinkUrl());
43 else if (!TextUtils.isEmpty(params.getLinkUrl()) )
44 menu.setHeaderTitle(params.getLinkUrl());
45 44
46 if (mMenuInflater == null) mMenuInflater = new MenuInflater(context); 45 if (mMenuInflater == null) mMenuInflater = new MenuInflater(context);
47 46
48 mMenuInflater.inflate(R.menu.chrome_context_menu, menu); 47 mMenuInflater.inflate(R.menu.chrome_context_menu, menu);
49 48
50 menu.setGroupVisible(R.id.contextmenu_group_anchor, params.isAnchor()); 49 menu.setGroupVisible(R.id.contextmenu_group_anchor, params.isAnchor());
51 menu.setGroupVisible(R.id.contextmenu_group_image, params.isImage()); 50 menu.setGroupVisible(R.id.contextmenu_group_image, params.isImage());
52 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); 51 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo());
53 52
54 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) { 53 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 mDelegate.onSearchByImageInNewTab(); 122 mDelegate.onSearchByImageInNewTab();
124 } else if (itemId == R.id.contextmenu_copy_image) { 123 } else if (itemId == R.id.contextmenu_copy_image) {
125 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); 124 mDelegate.onSaveImageToClipboard(params.getSrcUrl());
126 } else { 125 } else {
127 assert false; 126 assert false;
128 } 127 }
129 128
130 return true; 129 return true;
131 } 130 }
132 } 131 }
OLDNEW
« 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