| 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.text.TextUtils; | 7 import android.text.TextUtils; |
| 8 | 8 |
| 9 import org.chromium.base.CalledByNative; | 9 import org.chromium.base.CalledByNative; |
| 10 import org.chromium.base.JNINamespace; | 10 import org.chromium.base.JNINamespace; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 public CustomMenuItem(String label, int action) { | 36 public CustomMenuItem(String label, int action) { |
| 37 this.label = label; | 37 this.label = label; |
| 38 this.action = action; | 38 this.action = action; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 private final String mLinkUrl; | 42 private final String mLinkUrl; |
| 43 private final String mLinkText; | 43 private final String mLinkText; |
| 44 private final String mUnfilteredLinkUrl; | 44 private final String mUnfilteredLinkUrl; |
| 45 private final String mSrcUrl; | 45 private final String mSrcUrl; |
| 46 private final boolean mImageWasFetchedLoFi; |
| 46 private final boolean mIsEditable; | 47 private final boolean mIsEditable; |
| 47 private final Referrer mReferrer; | 48 private final Referrer mReferrer; |
| 48 | 49 |
| 49 private final boolean mIsAnchor; | 50 private final boolean mIsAnchor; |
| 50 private final boolean mIsSelectedText; | 51 private final boolean mIsSelectedText; |
| 51 private final boolean mIsImage; | 52 private final boolean mIsImage; |
| 52 private final boolean mIsVideo; | 53 private final boolean mIsVideo; |
| 53 | 54 |
| 54 private final ArrayList<CustomMenuItem> mCustomMenuItems = new ArrayList<Cus
tomMenuItem>(); | 55 private final ArrayList<CustomMenuItem> mCustomMenuItems = new ArrayList<Cus
tomMenuItem>(); |
| 55 | 56 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 110 } |
| 110 | 111 |
| 111 /** | 112 /** |
| 112 * @return The source URL. | 113 * @return The source URL. |
| 113 */ | 114 */ |
| 114 public String getSrcUrl() { | 115 public String getSrcUrl() { |
| 115 return mSrcUrl; | 116 return mSrcUrl; |
| 116 } | 117 } |
| 117 | 118 |
| 118 /** | 119 /** |
| 120 * @return Whether or not an image was fetched using Lo-Fi. |
| 121 */ |
| 122 public boolean imageWasFetchedLoFi() { |
| 123 return mImageWasFetchedLoFi; |
| 124 } |
| 125 |
| 126 /** |
| 119 * @return Whether or not the context menu is being shown for an editable pi
ece of content. | 127 * @return Whether or not the context menu is being shown for an editable pi
ece of content. |
| 120 */ | 128 */ |
| 121 public boolean isEditable() { | 129 public boolean isEditable() { |
| 122 return mIsEditable; | 130 return mIsEditable; |
| 123 } | 131 } |
| 124 | 132 |
| 125 /** | 133 /** |
| 126 * @return the referrer associated with the frame on which the menu is invok
ed | 134 * @return the referrer associated with the frame on which the menu is invok
ed |
| 127 */ | 135 */ |
| 128 public Referrer getReferrer() { | 136 public Referrer getReferrer() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 151 } | 159 } |
| 152 | 160 |
| 153 /** | 161 /** |
| 154 * @return Whether or not the context menu is being shown for a video. | 162 * @return Whether or not the context menu is being shown for a video. |
| 155 */ | 163 */ |
| 156 public boolean isVideo() { | 164 public boolean isVideo() { |
| 157 return mIsVideo; | 165 return mIsVideo; |
| 158 } | 166 } |
| 159 | 167 |
| 160 private ContextMenuParams(int mediaType, String linkUrl, String linkText, | 168 private ContextMenuParams(int mediaType, String linkUrl, String linkText, |
| 161 String unfilteredLinkUrl, String srcUrl, String selectionText, boole
an isEditable, | 169 String unfilteredLinkUrl, String srcUrl, String selectionText, |
| 170 boolean imageWasFetchedLoFi, boolean isEditable, |
| 162 Referrer referrer) { | 171 Referrer referrer) { |
| 163 mLinkUrl = linkUrl; | 172 mLinkUrl = linkUrl; |
| 164 mLinkText = linkText; | 173 mLinkText = linkText; |
| 165 mUnfilteredLinkUrl = unfilteredLinkUrl; | 174 mUnfilteredLinkUrl = unfilteredLinkUrl; |
| 166 mSrcUrl = srcUrl; | 175 mSrcUrl = srcUrl; |
| 176 mImageWasFetchedLoFi = imageWasFetchedLoFi; |
| 167 mIsEditable = isEditable; | 177 mIsEditable = isEditable; |
| 168 mReferrer = referrer; | 178 mReferrer = referrer; |
| 169 | 179 |
| 170 mIsAnchor = !TextUtils.isEmpty(linkUrl); | 180 mIsAnchor = !TextUtils.isEmpty(linkUrl); |
| 171 mIsSelectedText = !TextUtils.isEmpty(selectionText); | 181 mIsSelectedText = !TextUtils.isEmpty(selectionText); |
| 172 mIsImage = mediaType == MediaType.MEDIA_TYPE_IMAGE; | 182 mIsImage = mediaType == MediaType.MEDIA_TYPE_IMAGE; |
| 173 mIsVideo = mediaType == MediaType.MEDIA_TYPE_VIDEO; | 183 mIsVideo = mediaType == MediaType.MEDIA_TYPE_VIDEO; |
| 174 } | 184 } |
| 175 | 185 |
| 176 @CalledByNative | 186 @CalledByNative |
| 177 private static ContextMenuParams create(int mediaType, String linkUrl, Strin
g linkText, | 187 private static ContextMenuParams create(int mediaType, String linkUrl, Strin
g linkText, |
| 178 String unfilteredLinkUrl, String srcUrl, String selectionText, boole
an isEditable, | 188 String unfilteredLinkUrl, String srcUrl, String selectionText, |
| 179 String sanitizedReferrer, int referrerPolicy) { | 189 boolean imageWasFetchedLoFi, boolean isEditable, String sanitizedRef
errer, |
| 190 int referrerPolicy) { |
| 180 Referrer referrer = TextUtils.isEmpty(sanitizedReferrer) | 191 Referrer referrer = TextUtils.isEmpty(sanitizedReferrer) |
| 181 ? null : new Referrer(sanitizedReferrer, referrerPolicy); | 192 ? null : new Referrer(sanitizedReferrer, referrerPolicy); |
| 182 return new ContextMenuParams(mediaType, linkUrl, linkText, unfilteredLin
kUrl, srcUrl, | 193 return new ContextMenuParams(mediaType, linkUrl, linkText, unfilteredLin
kUrl, srcUrl, |
| 183 selectionText, isEditable, referrer); | 194 selectionText, imageWasFetchedLoFi, isEditable, referrer); |
| 184 } | 195 } |
| 185 | 196 |
| 186 @CalledByNative | 197 @CalledByNative |
| 187 private void addCustomItem(String label, int action) { | 198 private void addCustomItem(String label, int action) { |
| 188 mCustomMenuItems.add(new CustomMenuItem(label, action)); | 199 mCustomMenuItems.add(new CustomMenuItem(label, action)); |
| 189 } | 200 } |
| 190 } | 201 } |
| OLD | NEW |