| Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuItem.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java
|
| similarity index 71%
|
| copy from chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuItem.java
|
| copy to chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java
|
| index 1f9763d9ed062919f6747fbf693a145af6d50e7c..422b55b36cdf97304f988aa8df720f29df25db19 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuItem.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java
|
| @@ -17,9 +17,9 @@ import org.chromium.chrome.browser.search_engines.TemplateUrlService;
|
| import org.chromium.chrome.browser.widget.TintedDrawable;
|
|
|
| /**
|
| - * List of all Context Menu Items available in Chrome.
|
| + * List of all predefined Context Menu Items available in Chrome.
|
| */
|
| -public enum ContextMenuItem {
|
| +public enum ChromeContextMenuItem implements ContextMenuItem {
|
| // Custom Tab Group
|
| OPEN_IN_NEW_CHROME_TAB(R.drawable.context_menu_new_tab,
|
| R.string.contextmenu_open_in_new_chrome_tab, R.id.contextmenu_open_in_new_chrome_tab),
|
| @@ -67,13 +67,30 @@ public enum ContextMenuItem {
|
| // Video Group
|
| SAVE_VIDEO(R.drawable.ic_file_download_white_24dp, R.string.contextmenu_save_video,
|
| R.id.contextmenu_save_video),
|
| +
|
| // Other
|
| OPEN_IN_CHROME(R.drawable.context_menu_new_tab, R.string.menu_open_in_chrome,
|
| - R.id.menu_id_open_in_chrome);
|
| + R.id.menu_id_open_in_chrome),
|
| +
|
| + // Browser Action Items
|
| + BROWSER_ACTIONS_OPEN_IN_BACKGROUND(R.drawable.context_menu_new_tab,
|
| + R.string.browser_actions_open_in_background, R.id.browser_actions_open_in_background),
|
| + BROWSER_ACTIONS_OPEN_IN_INCOGNITO_TAB(R.drawable.incognito_statusbar,
|
| + R.string.browser_actions_open_in_incognito_tab,
|
| + R.id.browser_actions_open_in_incognito_tab),
|
| + BROWSER_ACTION_SAVE_LINK_AS(R.drawable.ic_file_download_white_24dp,
|
| + R.string.browser_actions_save_link_as, R.id.browser_actions_save_link_as),
|
| + BROWSER_ACTIONS_COPY_ADDRESS(R.drawable.ic_content_copy, R.string.browser_actions_copy_address,
|
| + R.id.browser_actions_copy_address),
|
| + BROWSER_ACTIONS_SHARE(R.drawable.ic_share_white_24dp, R.string.browser_actions_share,
|
| + R.id.browser_actions_share);
|
|
|
| - @DrawableRes public final int iconId;
|
| - @StringRes public final int stringId;
|
| - @IdRes public final int menuId;
|
| + @DrawableRes
|
| + private final int mIconId;
|
| + @StringRes
|
| + private final int mStringId;
|
| + @IdRes
|
| + private final int mMenuId;
|
|
|
| /**
|
| * A representation of a Context Menu Item. Each item should have a string and an id associated
|
| @@ -82,10 +99,10 @@ public enum ContextMenuItem {
|
| * @param stringId The string that describes the action of the item.
|
| * @param menuId The id found in ids.xml.
|
| */
|
| - ContextMenuItem(@DrawableRes int iconId, @StringRes int stringId, @IdRes int menuId) {
|
| - this.iconId = iconId;
|
| - this.stringId = stringId;
|
| - this.menuId = menuId;
|
| + ChromeContextMenuItem(@DrawableRes int iconId, @StringRes int stringId, @IdRes int menuId) {
|
| + mIconId = iconId;
|
| + mStringId = stringId;
|
| + mMenuId = menuId;
|
| }
|
|
|
| /**
|
| @@ -94,19 +111,20 @@ public enum ContextMenuItem {
|
| * @param context Requires to get the string resource related to the item.
|
| * @return Returns a string for the menu item.
|
| */
|
| - String getString(Context context) {
|
| - if (this == ContextMenuItem.SEARCH_BY_IMAGE) {
|
| + @Override
|
| + public String getTitle(Context context) {
|
| + if (this == ChromeContextMenuItem.SEARCH_BY_IMAGE) {
|
| return context.getString(R.string.contextmenu_search_web_for_image,
|
| TemplateUrlService.getInstance()
|
| .getDefaultSearchEngineTemplateUrl()
|
| .getShortName());
|
| } else if (this == OPEN_IN_BROWSER_ID) {
|
| return DefaultBrowserInfo.getTitleOpenInDefaultBrowser(false);
|
| - } else if (stringId == 0) {
|
| + } else if (mStringId == 0) {
|
| return "";
|
| }
|
|
|
| - return context.getString(stringId);
|
| + return context.getString(mStringId);
|
| }
|
|
|
| /**
|
| @@ -114,16 +132,22 @@ public enum ContextMenuItem {
|
| * drawable is associated with the icon, null is returned for the drawable and the
|
| * iconDescription.
|
| */
|
| - Drawable getDrawableAndDescription(Context context) {
|
| - if (iconId == R.drawable.context_menu_new_tab
|
| - || iconId == R.drawable.context_menu_add_to_contacts
|
| - || iconId == R.drawable.context_menu_load_image) {
|
| - return ApiCompatibilityUtils.getDrawable(context.getResources(), iconId);
|
| - } else if (iconId == 0) {
|
| + @Override
|
| + public Drawable getDrawable(Context context) {
|
| + if (mIconId == R.drawable.context_menu_new_tab
|
| + || mIconId == R.drawable.context_menu_add_to_contacts
|
| + || mIconId == R.drawable.context_menu_load_image) {
|
| + return ApiCompatibilityUtils.getDrawable(context.getResources(), mIconId);
|
| + } else if (mIconId == 0) {
|
| return null;
|
| } else {
|
| return TintedDrawable.constructTintedDrawable(
|
| - context.getResources(), iconId, R.color.light_normal_color);
|
| + context.getResources(), mIconId, R.color.light_normal_color);
|
| }
|
| }
|
| +
|
| + @Override
|
| + public int getMenuId() {
|
| + return mMenuId;
|
| + }
|
| }
|
|
|