| 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.annotations.CalledByNative; | 9 import org.chromium.base.annotations.CalledByNative; |
| 10 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 private final String mLinkText; | 32 private final String mLinkText; |
| 33 private final String mTitleText; | 33 private final String mTitleText; |
| 34 private final String mUnfilteredLinkUrl; | 34 private final String mUnfilteredLinkUrl; |
| 35 private final String mSrcUrl; | 35 private final String mSrcUrl; |
| 36 private final boolean mImageWasFetchedLoFi; | 36 private final boolean mImageWasFetchedLoFi; |
| 37 private final Referrer mReferrer; | 37 private final Referrer mReferrer; |
| 38 | 38 |
| 39 private final boolean mIsAnchor; | 39 private final boolean mIsAnchor; |
| 40 private final boolean mIsImage; | 40 private final boolean mIsImage; |
| 41 private final boolean mIsVideo; | 41 private final boolean mIsVideo; |
| 42 private final boolean mCanSavemedia; | |
| 43 | 42 |
| 44 /** | 43 /** |
| 45 * @return The URL associated with the main frame of the page that triggered
the context menu. | 44 * @return The URL associated with the main frame of the page that triggered
the context menu. |
| 46 */ | 45 */ |
| 47 public String getPageUrl() { | 46 public String getPageUrl() { |
| 48 return mPageUrl; | 47 return mPageUrl; |
| 49 } | 48 } |
| 50 | 49 |
| 51 /** | 50 /** |
| 52 * @return The link URL, if any. | 51 * @return The link URL, if any. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return mIsImage; | 110 return mIsImage; |
| 112 } | 111 } |
| 113 | 112 |
| 114 /** | 113 /** |
| 115 * @return Whether or not the context menu is being shown for a video. | 114 * @return Whether or not the context menu is being shown for a video. |
| 116 */ | 115 */ |
| 117 public boolean isVideo() { | 116 public boolean isVideo() { |
| 118 return mIsVideo; | 117 return mIsVideo; |
| 119 } | 118 } |
| 120 | 119 |
| 121 public boolean canSaveMedia() { | |
| 122 return mCanSavemedia; | |
| 123 } | |
| 124 | |
| 125 private ContextMenuParams(int mediaType, String pageUrl, String linkUrl, Str
ing linkText, | 120 private ContextMenuParams(int mediaType, String pageUrl, String linkUrl, Str
ing linkText, |
| 126 String unfilteredLinkUrl, String srcUrl, String titleText, boolean i
mageWasFetchedLoFi, | 121 String unfilteredLinkUrl, String srcUrl, String titleText, boolean i
mageWasFetchedLoFi, |
| 127 Referrer referrer, boolean canSavemedia) { | 122 Referrer referrer) { |
| 128 mPageUrl = pageUrl; | 123 mPageUrl = pageUrl; |
| 129 mLinkUrl = linkUrl; | 124 mLinkUrl = linkUrl; |
| 130 mLinkText = linkText; | 125 mLinkText = linkText; |
| 131 mTitleText = titleText; | 126 mTitleText = titleText; |
| 132 mUnfilteredLinkUrl = unfilteredLinkUrl; | 127 mUnfilteredLinkUrl = unfilteredLinkUrl; |
| 133 mSrcUrl = srcUrl; | 128 mSrcUrl = srcUrl; |
| 134 mImageWasFetchedLoFi = imageWasFetchedLoFi; | 129 mImageWasFetchedLoFi = imageWasFetchedLoFi; |
| 135 mReferrer = referrer; | 130 mReferrer = referrer; |
| 136 | 131 |
| 137 mIsAnchor = !TextUtils.isEmpty(linkUrl); | 132 mIsAnchor = !TextUtils.isEmpty(linkUrl); |
| 138 mIsImage = mediaType == MediaType.MEDIA_TYPE_IMAGE; | 133 mIsImage = mediaType == MediaType.MEDIA_TYPE_IMAGE; |
| 139 mIsVideo = mediaType == MediaType.MEDIA_TYPE_VIDEO; | 134 mIsVideo = mediaType == MediaType.MEDIA_TYPE_VIDEO; |
| 140 mCanSavemedia = canSavemedia; | |
| 141 } | 135 } |
| 142 | 136 |
| 143 @CalledByNative | 137 @CalledByNative |
| 144 private static ContextMenuParams create(int mediaType, String pageUrl, Strin
g linkUrl, | 138 private static ContextMenuParams create(int mediaType, String pageUrl, Strin
g linkUrl, |
| 145 String linkText, String unfilteredLinkUrl, String srcUrl, String tit
leText, | 139 String linkText, String unfilteredLinkUrl, String srcUrl, String tit
leText, |
| 146 boolean imageWasFetchedLoFi, String sanitizedReferrer, int referrerP
olicy, | 140 boolean imageWasFetchedLoFi, String sanitizedReferrer, int referrerP
olicy) { |
| 147 boolean canSavemedia) { | |
| 148 Referrer referrer = TextUtils.isEmpty(sanitizedReferrer) | 141 Referrer referrer = TextUtils.isEmpty(sanitizedReferrer) |
| 149 ? null : new Referrer(sanitizedReferrer, referrerPolicy); | 142 ? null : new Referrer(sanitizedReferrer, referrerPolicy); |
| 150 return new ContextMenuParams(mediaType, pageUrl, linkUrl, linkText, unfi
lteredLinkUrl, | 143 return new ContextMenuParams(mediaType, pageUrl, linkUrl, linkText, unfi
lteredLinkUrl, |
| 151 srcUrl, titleText, imageWasFetchedLoFi, referrer, canSavemedia); | 144 srcUrl, titleText, imageWasFetchedLoFi, referrer); |
| 152 } | 145 } |
| 153 } | 146 } |
| OLD | NEW |