| 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 (MailTo.isMailTo(params.getLinkUrl())) { |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 mDelegate.onOpenInNewTab(params.getLinkUrl(), params.getReferrer()); | 111 mDelegate.onOpenInNewTab(params.getLinkUrl(), params.getReferrer()); |
| 105 } else if (itemId == R.id.contextmenu_open_in_incognito_tab) { | 112 } else if (itemId == R.id.contextmenu_open_in_incognito_tab) { |
| 106 mDelegate.onOpenInNewIncognitoTab(params.getLinkUrl()); | 113 mDelegate.onOpenInNewIncognitoTab(params.getLinkUrl()); |
| 107 } else if (itemId == R.id.contextmenu_open_image) { | 114 } else if (itemId == R.id.contextmenu_open_image) { |
| 108 mDelegate.onOpenImageUrl(params.getSrcUrl(), params.getReferrer()); | 115 mDelegate.onOpenImageUrl(params.getSrcUrl(), params.getReferrer()); |
| 109 } else if (itemId == R.id.contextmenu_open_image_in_new_tab || | 116 } else if (itemId == R.id.contextmenu_open_image_in_new_tab || |
| 110 itemId == R.id.contextmenu_open_original_image_in_new_tab) { | 117 itemId == R.id.contextmenu_open_original_image_in_new_tab) { |
| 111 mDelegate.onOpenImageInNewTab(params.getSrcUrl(), params.getReferrer
()); | 118 mDelegate.onOpenImageInNewTab(params.getSrcUrl(), params.getReferrer
()); |
| 112 } else if (itemId == R.id.contextmenu_copy_link_address_text) { | 119 } else if (itemId == R.id.contextmenu_copy_link_address_text) { |
| 113 mDelegate.onSaveToClipboard(params.getUnfilteredLinkUrl(), true); | 120 mDelegate.onSaveToClipboard(params.getUnfilteredLinkUrl(), true); |
| 121 } else if (itemId == R.id.contextmenu_copy_email_address) { |
| 122 mDelegate.onSaveToClipboard(MailTo.parse(params.getLinkUrl()).getTo(
), false); |
| 114 } else if (itemId == R.id.contextmenu_copy_link_text) { | 123 } else if (itemId == R.id.contextmenu_copy_link_text) { |
| 115 mDelegate.onSaveToClipboard(params.getLinkText(), false); | 124 mDelegate.onSaveToClipboard(params.getLinkText(), false); |
| 116 } else if (itemId == R.id.contextmenu_save_image || | 125 } else if (itemId == R.id.contextmenu_save_image || |
| 117 itemId == R.id.contextmenu_save_video) { | 126 itemId == R.id.contextmenu_save_video) { |
| 118 if (mDelegate.startDownload(params.getSrcUrl(), false)) { | 127 if (mDelegate.startDownload(params.getSrcUrl(), false)) { |
| 119 helper.startContextMenuDownload(false); | 128 helper.startContextMenuDownload(false); |
| 120 } | 129 } |
| 121 } else if (itemId == R.id.contextmenu_save_link_as) { | 130 } else if (itemId == R.id.contextmenu_save_link_as) { |
| 122 if (mDelegate.startDownload(params.getUnfilteredLinkUrl(), true)) { | 131 if (mDelegate.startDownload(params.getUnfilteredLinkUrl(), true)) { |
| 123 helper.startContextMenuDownload(true); | 132 helper.startContextMenuDownload(true); |
| 124 } | 133 } |
| 125 } else if (itemId == R.id.contextmenu_search_by_image) { | 134 } else if (itemId == R.id.contextmenu_search_by_image) { |
| 126 mDelegate.onSearchByImageInNewTab(); | 135 mDelegate.onSearchByImageInNewTab(); |
| 127 } else if (itemId == R.id.contextmenu_copy_image) { | 136 } else if (itemId == R.id.contextmenu_copy_image) { |
| 128 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); | 137 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); |
| 129 } else if (itemId == R.id.contextmenu_copy_image_url) { | 138 } else if (itemId == R.id.contextmenu_copy_image_url) { |
| 130 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); | 139 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); |
| 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 |