Commit 41f25f66 authored by Alexandre Frechette's avatar Alexandre Frechette Committed by Commit Bot

[Translate Manual Trigger] Made `prepareTranslateMenuItem` inline.

Bug: 883456
Change-Id: I990f680aeb7cb7c18571abc63c09573bcc6f3b1c
Reviewed-on: https://chromium-review.googlesource.com/c/1297486
Commit-Queue: Alexandre Frechette <frechette@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602414}
parent bfad347c
...@@ -177,7 +177,20 @@ public class AppMenuPropertiesDelegate { ...@@ -177,7 +177,20 @@ public class AppMenuPropertiesDelegate {
menu.findItem(R.id.find_in_page_id).setVisible( menu.findItem(R.id.find_in_page_id).setVisible(
!currentTab.isNativePage() && currentTab.getWebContents() != null); !currentTab.isNativePage() && currentTab.getWebContents() != null);
prepareTranslateMenuItem(menu, currentTab); // Prepare translate menu button.
boolean isTranslateVisible = !isChromeScheme && !isFileScheme && !isContentScheme
&& !TextUtils.isEmpty(url) && currentTab.getWebContents() != null
&& ChromeFeatureList.isInitialized()
&& ChromeFeatureList.isEnabled(
ChromeFeatureList.TRANSLATE_ANDROID_MANUAL_TRIGGER)
&& TranslateBridge.canManuallyTranslate(currentTab);
if (ChromeFeatureList.isInitialized()
&& ChromeFeatureList.isEnabled(
ChromeFeatureList.TRANSLATE_ANDROID_MANUAL_TRIGGER)) {
RecordHistogram.recordBooleanHistogram(
"Translate.MobileMenuTranslate.Shown", isTranslateVisible);
}
menu.findItem(R.id.translate_id).setVisible(isTranslateVisible);
// Hide 'Add to homescreen' for the following: // Hide 'Add to homescreen' for the following:
// * chrome:// pages - Android doesn't know how to direct those URLs. // * chrome:// pages - Android doesn't know how to direct those URLs.
...@@ -286,30 +299,6 @@ public class AppMenuPropertiesDelegate { ...@@ -286,30 +299,6 @@ public class AppMenuPropertiesDelegate {
} }
} }
/**
* Sets the visibility of the 'Translate' menu item.
*/
private void prepareTranslateMenuItem(Menu menu, Tab currentTab) {
String url = currentTab.getUrl();
boolean isChromeScheme = url.startsWith(UrlConstants.CHROME_URL_PREFIX)
|| url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX);
boolean isFileScheme = url.startsWith(UrlConstants.FILE_URL_PREFIX);
boolean isContentScheme = url.startsWith(UrlConstants.CONTENT_URL_PREFIX);
boolean isVisible = !isChromeScheme && !isFileScheme && !isContentScheme
&& !TextUtils.isEmpty(url) && currentTab.getWebContents() != null
&& ChromeFeatureList.isInitialized()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.TRANSLATE_ANDROID_MANUAL_TRIGGER)
&& TranslateBridge.canManuallyTranslate(currentTab);
if (ChromeFeatureList.isInitialized()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.TRANSLATE_ANDROID_MANUAL_TRIGGER))
RecordHistogram.recordBooleanHistogram(
"Translate.MobileMenuTranslate.Shown", isVisible);
menu.findItem(R.id.translate_id).setVisible(isVisible);
}
/** /**
* Notify the delegate that the load state changed. * Notify the delegate that the load state changed.
* @param isLoading Whether the page is currently loading. * @param isLoading Whether the page is currently loading.
......
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