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.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; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); | 51 menu.setGroupVisible(R.id.contextmenu_group_video, params.isVideo()); |
52 | 52 |
53 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) { | 53 if (mDelegate.isIncognito() || !mDelegate.isIncognitoSupported()) { |
54 menu.findItem(R.id.contextmenu_open_in_incognito_tab).setVisible(fal
se); | 54 menu.findItem(R.id.contextmenu_open_in_incognito_tab).setVisible(fal
se); |
55 } | 55 } |
56 | 56 |
57 if (params.getLinkText().trim().isEmpty()) { | 57 if (params.getLinkText().trim().isEmpty()) { |
58 menu.findItem(R.id.contextmenu_copy_link_text).setVisible(false); | 58 menu.findItem(R.id.contextmenu_copy_link_text).setVisible(false); |
59 } | 59 } |
60 | 60 |
61 menu.findItem(R.id.contextmenu_save_link_as).setEnabled( | 61 menu.findItem(R.id.contextmenu_save_link_as).setVisible( |
62 UrlUtilities.isDownloadableScheme(params.getLinkUrl())); | 62 UrlUtilities.isDownloadableScheme(params.getLinkUrl())); |
63 | 63 |
64 if (params.isVideo()) { | 64 if (params.isVideo()) { |
65 menu.findItem(R.id.contextmenu_save_video).setEnabled( | 65 menu.findItem(R.id.contextmenu_save_video).setVisible( |
66 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); | 66 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); |
67 } else if (params.isImage()) { | 67 } else if (params.isImage()) { |
68 menu.findItem(R.id.contextmenu_save_image).setEnabled( | 68 menu.findItem(R.id.contextmenu_save_image).setVisible( |
69 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); | 69 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); |
70 | 70 |
71 if (mDelegate.canLoadOriginalImage()) { | 71 if (mDelegate.canLoadOriginalImage()) { |
72 menu.findItem(R.id.contextmenu_open_image_in_new_tab).setVisible
(false); | 72 menu.findItem(R.id.contextmenu_open_image_in_new_tab).setVisible
(false); |
73 } else { | 73 } else { |
74 menu.findItem(R.id.contextmenu_open_original_image_in_new_tab).s
etVisible(false); | 74 menu.findItem(R.id.contextmenu_open_original_image_in_new_tab).s
etVisible(false); |
75 } | 75 } |
76 | 76 |
77 // Avoid showing open image option for same image which is already o
pened. | 77 // Avoid showing open image option for same image which is already o
pened. |
78 if (mDelegate.getPageUrl().equals(params.getSrcUrl())) { | 78 if (mDelegate.getPageUrl().equals(params.getSrcUrl())) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); | 124 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); |
125 } else if (itemId == R.id.contextmenu_copy_image_url) { | 125 } else if (itemId == R.id.contextmenu_copy_image_url) { |
126 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); | 126 mDelegate.onSaveToClipboard(params.getSrcUrl(), true); |
127 } else { | 127 } else { |
128 assert false; | 128 assert false; |
129 } | 129 } |
130 | 130 |
131 return true; | 131 return true; |
132 } | 132 } |
133 } | 133 } |
OLD | NEW |