Commit f0469558 authored by aurimas's avatar aurimas Committed by Commit bot

Start displaying title text for HTML elements without links.

This CL depends on Blink change https://chromiumcodereview.appspot.com/1128933011

BUG=487782

Review URL: https://codereview.chromium.org/1126203011

Cr-Commit-Position: refs/heads/master@{#330282}
parent 81e56b92
......@@ -41,6 +41,8 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
public void buildContextMenu(ContextMenu menu, Context context, ContextMenuParams params) {
if (!TextUtils.isEmpty(params.getLinkUrl()) && !params.getLinkUrl().equals(BLANK_URL)) {
menu.setHeaderTitle(params.getLinkUrl());
} else if (!TextUtils.isEmpty(params.getTitleText())) {
menu.setHeaderTitle(params.getTitleText());
}
if (mMenuInflater == null) mMenuInflater = new MenuInflater(context);
......
......@@ -42,6 +42,7 @@ public class ContextMenuParams {
private final String mPageUrl;
private final String mLinkUrl;
private final String mLinkText;
private final String mTitleText;
private final String mUnfilteredLinkUrl;
private final String mSrcUrl;
private final boolean mImageWasFetchedLoFi;
......@@ -110,6 +111,13 @@ public class ContextMenuParams {
return mLinkText;
}
/**
* @return The title or alt attribute (if title is not available).
*/
public String getTitleText() {
return mTitleText;
}
/**
* @return The unfiltered link URL, if any.
*/
......@@ -174,11 +182,12 @@ public class ContextMenuParams {
}
private ContextMenuParams(int mediaType, String pageUrl, String linkUrl, String linkText,
String unfilteredLinkUrl, String srcUrl, String selectionText,
String unfilteredLinkUrl, String srcUrl, String selectionText, String titleText,
boolean imageWasFetchedLoFi, boolean isEditable, Referrer referrer) {
mPageUrl = pageUrl;
mLinkUrl = linkUrl;
mLinkText = linkText;
mTitleText = titleText;
mUnfilteredLinkUrl = unfilteredLinkUrl;
mSrcUrl = srcUrl;
mImageWasFetchedLoFi = imageWasFetchedLoFi;
......@@ -194,12 +203,12 @@ public class ContextMenuParams {
@CalledByNative
private static ContextMenuParams create(int mediaType, String pageUrl, String linkUrl,
String linkText, String unfilteredLinkUrl, String srcUrl, String selectionText,
boolean imageWasFetchedLoFi, boolean isEditable, String sanitizedReferrer,
int referrerPolicy) {
String titleText, boolean imageWasFetchedLoFi, boolean isEditable,
String sanitizedReferrer, int referrerPolicy) {
Referrer referrer = TextUtils.isEmpty(sanitizedReferrer)
? null : new Referrer(sanitizedReferrer, referrerPolicy);
return new ContextMenuParams(mediaType, pageUrl, linkUrl, linkText, unfilteredLinkUrl,
srcUrl, selectionText, imageWasFetchedLoFi, isEditable, referrer);
srcUrl, selectionText, titleText, imageWasFetchedLoFi, isEditable, referrer);
}
@CalledByNative
......
......@@ -93,6 +93,7 @@ ContextMenuHelper::CreateJavaContextMenuParams(
ConvertUTF8ToJavaString(env, params.unfiltered_link_url.spec()).obj(),
ConvertUTF8ToJavaString(env, params.src_url.spec()).obj(),
ConvertUTF16ToJavaString(env, params.selection_text).obj(),
ConvertUTF16ToJavaString(env, params.title_text).obj(),
image_was_fetched_lo_fi,
params.is_editable,
ConvertUTF8ToJavaString(env, sanitizedReferrer.spec()).obj(),
......
......@@ -68,6 +68,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::ContextMenuParams)
IPC_STRUCT_TRAITS_MEMBER(frame_page_state)
IPC_STRUCT_TRAITS_MEMBER(media_flags)
IPC_STRUCT_TRAITS_MEMBER(selection_text)
IPC_STRUCT_TRAITS_MEMBER(title_text)
IPC_STRUCT_TRAITS_MEMBER(suggested_filename)
IPC_STRUCT_TRAITS_MEMBER(misspelled_word)
IPC_STRUCT_TRAITS_MEMBER(misspelling_hash)
......
......@@ -105,6 +105,10 @@ struct CONTENT_EXPORT ContextMenuParams {
// This is the text of the selection that the context menu was invoked on.
base::string16 selection_text;
// This is the title or alt (if title not available) text of the selection
// that the context menu was invoked on.
base::string16 title_text;
// This is the suggested filename to be used when saving file through "Save
// Link As" option of context menu.
base::string16 suggested_filename;
......
......@@ -32,6 +32,7 @@ ContextMenuParams ContextMenuParamsBuilder::Build(
params.frame_url = data.frameURL;
params.media_flags = data.mediaFlags;
params.selection_text = data.selectedText;
params.title_text = data.titleText;
params.misspelled_word = data.misspelledWord;
params.misspelling_hash = data.misspellingHash;
params.spellcheck_enabled = data.isSpellCheckingEnabled;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment