Chromium Code Reviews| 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.os.Build; | 9 import android.os.Build; |
| 9 import android.text.TextUtils; | 10 import android.text.TextUtils; |
| 10 import android.view.ContextMenu; | 11 import android.view.ContextMenu; |
| 11 import android.view.MenuInflater; | 12 import android.view.MenuInflater; |
| 12 | 13 |
| 13 import org.chromium.chrome.R; | 14 import org.chromium.chrome.R; |
| 14 import org.chromium.chrome.browser.UrlUtilities; | 15 import org.chromium.chrome.browser.UrlUtilities; |
| 15 import org.chromium.chrome.browser.search_engines.TemplateUrlService; | 16 import org.chromium.chrome.browser.search_engines.TemplateUrlService; |
| 16 | 17 |
| 17 /** | 18 /** |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); | 52 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); |
| 52 | 53 |
| 53 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) { | 54 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) { |
| 54 menu.findItem(R.id.contextmenu_open_in_incognito_tab).setVisible(fal se); | 55 menu.findItem(R.id.contextmenu_open_in_incognito_tab).setVisible(fal se); |
| 55 } | 56 } |
| 56 | 57 |
| 57 if (params.getLinkText().trim().isEmpty()) { | 58 if (params.getLinkText().trim().isEmpty()) { |
| 58 menu.findItem(R.id.contextmenu_copy_link_text).setVisible(false); | 59 menu.findItem(R.id.contextmenu_copy_link_text).setVisible(false); |
| 59 } | 60 } |
| 60 | 61 |
| 62 if (params.getLinkUrl().startsWith("mailto:")) { | |
|
Bernhard Bauer
2014/09/18 10:35:32
Use MailTo.isMailTo()?
ankit
2014/09/18 10:45:20
Done.
| |
| 63 menu.findItem(R.id.contextmenu_copy_link_address_text).setVisible(fa lse); | |
| 64 } else { | |
| 65 menu.findItem(R.id.contextmenu_copy_email_address).setVisible(false) ; | |
| 66 } | |
| 67 | |
| 61 menu.findItem(R.id.contextmenu_save_link_as).setVisible( | 68 menu.findItem(R.id.contextmenu_save_link_as).setVisible( |
| 62 UrlUtilities.isDownloadableScheme(params.getLinkUrl())); | 69 UrlUtilities.isDownloadableScheme(params.getLinkUrl())); |
| 63 | 70 |
| 64 if (params.isVideo()) { | 71 if (params.isVideo()) { |
| 65 menu.findItem(R.id.contextmenu_save_video).setVisible( | 72 menu.findItem(R.id.contextmenu_save_video).setVisible( |
| 66 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); | 73 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); |
| 67 } else if (params.isImage()) { | 74 } else if (params.isImage()) { |
| 68 menu.findItem(R.id.contextmenu_save_image).setVisible( | 75 menu.findItem(R.id.contextmenu_save_image).setVisible( |
| 69 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); | 76 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); |
| 70 | 77 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 } else if (itemId == R.id.contextmenu_save_link_as) { | 128 } else if (itemId == R.id.contextmenu_save_link_as) { |
| 122 if (mDelegate.startDownload(params.getUnfilteredLinkUrl(), true)) { | 129 if (mDelegate.startDownload(params.getUnfilteredLinkUrl(), true)) { |
| 123 helper.startContextMenuDownload(true); | 130 helper.startContextMenuDownload(true); |
| 124 } | 131 } |
| 125 } else if (itemId == R.id.contextmenu_search_by_image) { | 132 } else if (itemId == R.id.contextmenu_search_by_image) { |
| 126 mDelegate.onSearchByImageInNewTab(); | 133 mDelegate.onSearchByImageInNewTab(); |
| 127 } else if (itemId == R.id.contextmenu_copy_image) { | 134 } else if (itemId == R.id.contextmenu_copy_image) { |
| 128 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); | 135 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); |
| 129 } else if (itemId == R.id.contextmenu_copy_image_url) { | 136 } else if (itemId == R.id.contextmenu_copy_image_url) { |
| 130 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); | 137 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); |
| 138 } else if (itemId == R.id.contextmenu_copy_email_address) { | |
|
Bernhard Bauer
2014/09/18 10:35:32
Move this up, right after copy_link_address_text?
ankit
2014/09/18 10:45:20
Done.
| |
| 139 mDelegate.onSaveToClipboard(MailTo.parse(params.getLinkUrl()).getTo( ), false); | |
| 131 } else { | 140 } else { |
| 132 assert false; | 141 assert false; |
| 133 } | 142 } |
| 134 | 143 |
| 135 return true; | 144 return true; |
| 136 } | 145 } |
| 137 } | 146 } |
| OLD | NEW |