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.os.Build; | 9 import android.os.Build; |
10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 @Override | 35 @Override |
36 public boolean shouldShowContextMenu(ContextMenuParams params) { | 36 public boolean shouldShowContextMenu(ContextMenuParams params) { |
37 return params != null && (params.isAnchor() || params.isEditable() || pa
rams.isImage() | 37 return params != null && (params.isAnchor() || params.isEditable() || pa
rams.isImage() |
38 || params.isSelectedText() || params.isVideo() || params.isCusto
mMenu()); | 38 || params.isSelectedText() || params.isVideo() || params.isCusto
mMenu()); |
39 } | 39 } |
40 | 40 |
41 @Override | 41 @Override |
42 public void buildContextMenu(ContextMenu menu, Context context, ContextMenuP
arams params) { | 42 public void buildContextMenu(ContextMenu menu, Context context, ContextMenuP
arams params) { |
43 if (!TextUtils.isEmpty(params.getLinkUrl()) && !params.getLinkUrl().equa
ls(BLANK_URL)) | 43 if (!TextUtils.isEmpty(params.getLinkUrl()) && !params.getLinkUrl().equa
ls(BLANK_URL)) { |
44 menu.setHeaderTitle(params.getLinkUrl()); | 44 menu.setHeaderTitle(params.getLinkUrl()); |
| 45 } |
45 | 46 |
46 if (mMenuInflater == null) mMenuInflater = new MenuInflater(context); | 47 if (mMenuInflater == null) mMenuInflater = new MenuInflater(context); |
47 | 48 |
48 mMenuInflater.inflate(R.menu.chrome_context_menu, menu); | 49 mMenuInflater.inflate(R.menu.chrome_context_menu, menu); |
49 | 50 |
50 menu.setGroupVisible(R.id.contextmenu_group_anchor, params.isAnchor()); | 51 menu.setGroupVisible(R.id.contextmenu_group_anchor, params.isAnchor()); |
51 menu.setGroupVisible(R.id.contextmenu_group_image, params.isImage()); | 52 menu.setGroupVisible(R.id.contextmenu_group_image, params.isImage()); |
52 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); | 53 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); |
53 | 54 |
54 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) { | 55 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); | 139 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); |
139 } else if (itemId == R.id.contextmenu_copy_image_url) { | 140 } else if (itemId == R.id.contextmenu_copy_image_url) { |
140 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); | 141 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); |
141 } else { | 142 } else { |
142 assert false; | 143 assert false; |
143 } | 144 } |
144 | 145 |
145 return true; | 146 return true; |
146 } | 147 } |
147 } | 148 } |
OLD | NEW |