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.VisibleForTesting; | 9 import org.chromium.base.VisibleForTesting; |
10 import org.chromium.base.annotations.CalledByNative; | 10 import org.chromium.base.annotations.CalledByNative; |
(...skipping 25 matching lines...) Expand all Loading... | |
36 private final String mUnfilteredLinkUrl; | 36 private final String mUnfilteredLinkUrl; |
37 private final String mSrcUrl; | 37 private final String mSrcUrl; |
38 private final boolean mImageWasFetchedLoFi; | 38 private final boolean mImageWasFetchedLoFi; |
39 private final Referrer mReferrer; | 39 private final Referrer mReferrer; |
40 | 40 |
41 private final boolean mIsAnchor; | 41 private final boolean mIsAnchor; |
42 private final boolean mIsImage; | 42 private final boolean mIsImage; |
43 private final boolean mIsVideo; | 43 private final boolean mIsVideo; |
44 private final boolean mCanSaveMedia; | 44 private final boolean mCanSaveMedia; |
45 | 45 |
46 private final int mTriggeringTouchXDp; | |
47 private final int mTriggeringTouchYDp; | |
48 | |
46 /** | 49 /** |
47 * @return The URL associated with the main frame of the page that triggered the context menu. | 50 * @return The URL associated with the main frame of the page that triggered the context menu. |
48 */ | 51 */ |
49 public String getPageUrl() { | 52 public String getPageUrl() { |
50 return mPageUrl; | 53 return mPageUrl; |
51 } | 54 } |
52 | 55 |
53 /** | 56 /** |
54 * @return The link URL, if any. | 57 * @return The link URL, if any. |
55 */ | 58 */ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 /** | 130 /** |
128 * @return Whether or not the context menu is been shown for a download item . | 131 * @return Whether or not the context menu is been shown for a download item . |
129 */ | 132 */ |
130 public boolean isFile() { | 133 public boolean isFile() { |
131 if (!TextUtils.isEmpty(mSrcUrl) && mSrcUrl.startsWith(UrlConstants.FILE_ URL_PREFIX)) { | 134 if (!TextUtils.isEmpty(mSrcUrl) && mSrcUrl.startsWith(UrlConstants.FILE_ URL_PREFIX)) { |
132 return true; | 135 return true; |
133 } | 136 } |
134 return false; | 137 return false; |
135 } | 138 } |
136 | 139 |
140 /** | |
141 * @return The x-coordinate of the touch that triggered the context menu in dp relative to the | |
142 * render view; 0 corresponds to the left edge. | |
143 */ | |
144 public int getTriggeringTouchXDp() { | |
145 return mTriggeringTouchXDp; | |
146 } | |
147 | |
148 /** | |
149 * @return The y-coordinate of the touch that triggered the context menu in dp relative to the | |
150 * render view; 0 corresponds to the left edge. | |
151 */ | |
152 public int getTriggeringTouchYDp() { | |
153 return mTriggeringTouchYDp; | |
154 } | |
155 | |
137 @VisibleForTesting | 156 @VisibleForTesting |
138 public ContextMenuParams(int mediaType, String pageUrl, String linkUrl, Stri ng linkText, | 157 public ContextMenuParams(int mediaType, String pageUrl, String linkUrl, Stri ng linkText, |
Daniel Park
2017/06/09 21:32:53
this isn't a new change since this is already mark
| |
139 String unfilteredLinkUrl, String srcUrl, String titleText, boolean i mageWasFetchedLoFi, | 158 String unfilteredLinkUrl, String srcUrl, String titleText, boolean i mageWasFetchedLoFi, |
140 Referrer referrer, boolean canSaveMedia) { | 159 Referrer referrer, boolean canSaveMedia, int triggeringTouchXDp, |
160 int triggeringTouchYDp) { | |
141 mPageUrl = pageUrl; | 161 mPageUrl = pageUrl; |
142 mLinkUrl = linkUrl; | 162 mLinkUrl = linkUrl; |
143 mLinkText = linkText; | 163 mLinkText = linkText; |
144 mTitleText = titleText; | 164 mTitleText = titleText; |
145 mUnfilteredLinkUrl = unfilteredLinkUrl; | 165 mUnfilteredLinkUrl = unfilteredLinkUrl; |
146 mSrcUrl = srcUrl; | 166 mSrcUrl = srcUrl; |
147 mImageWasFetchedLoFi = imageWasFetchedLoFi; | 167 mImageWasFetchedLoFi = imageWasFetchedLoFi; |
148 mReferrer = referrer; | 168 mReferrer = referrer; |
149 | 169 |
150 mIsAnchor = !TextUtils.isEmpty(linkUrl); | 170 mIsAnchor = !TextUtils.isEmpty(linkUrl); |
151 mIsImage = mediaType == MediaType.MEDIA_TYPE_IMAGE; | 171 mIsImage = mediaType == MediaType.MEDIA_TYPE_IMAGE; |
152 mIsVideo = mediaType == MediaType.MEDIA_TYPE_VIDEO; | 172 mIsVideo = mediaType == MediaType.MEDIA_TYPE_VIDEO; |
153 mCanSaveMedia = canSaveMedia; | 173 mCanSaveMedia = canSaveMedia; |
174 mTriggeringTouchXDp = triggeringTouchXDp; | |
175 mTriggeringTouchYDp = triggeringTouchYDp; | |
154 } | 176 } |
155 | 177 |
156 @CalledByNative | 178 @CalledByNative |
157 private static ContextMenuParams create(int mediaType, String pageUrl, Strin g linkUrl, | 179 private static ContextMenuParams create(int mediaType, String pageUrl, Strin g linkUrl, |
158 String linkText, String unfilteredLinkUrl, String srcUrl, String tit leText, | 180 String linkText, String unfilteredLinkUrl, String srcUrl, String tit leText, |
159 boolean imageWasFetchedLoFi, String sanitizedReferrer, int referrerP olicy, | 181 boolean imageWasFetchedLoFi, String sanitizedReferrer, int referrerP olicy, |
160 boolean canSaveMedia) { | 182 boolean canSaveMedia, int triggeringTouchXDp, int triggeringTouchYDp ) { |
161 Referrer referrer = TextUtils.isEmpty(sanitizedReferrer) | 183 Referrer referrer = TextUtils.isEmpty(sanitizedReferrer) |
162 ? null : new Referrer(sanitizedReferrer, referrerPolicy); | 184 ? null : new Referrer(sanitizedReferrer, referrerPolicy); |
163 return new ContextMenuParams(mediaType, pageUrl, linkUrl, linkText, unfi lteredLinkUrl, | 185 return new ContextMenuParams(mediaType, pageUrl, linkUrl, linkText, unfi lteredLinkUrl, |
164 srcUrl, titleText, imageWasFetchedLoFi, referrer, canSaveMedia); | 186 srcUrl, titleText, imageWasFetchedLoFi, referrer, canSaveMedia, triggeringTouchXDp, |
187 triggeringTouchYDp); | |
165 } | 188 } |
166 } | 189 } |
OLD | NEW |