Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsCustomContextMenuItem.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsCustomContextMenuItem.java b/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsCustomContextMenuItem.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..36a3ccd65abd76b35abd89ecd9a499380e8977bd |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsCustomContextMenuItem.java |
| @@ -0,0 +1,45 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.browseractions; |
| + |
| +import android.content.Context; |
| +import android.graphics.Bitmap; |
| +import android.graphics.drawable.BitmapDrawable; |
| +import android.graphics.drawable.Drawable; |
| +import android.support.annotation.IdRes; |
| +import android.support.customtabs.browseractions.BrowserActionItem; |
| + |
| +import org.chromium.chrome.browser.contextmenu.ContextMenuItem; |
| + |
| +/** |
| + * A class represents Browser Actions context menu with custom title and icon. |
| + */ |
| +public class BrowserActionsCustomContextMenuItem implements ContextMenuItem { |
| + @IdRes |
| + private final int mMenuId; |
| + private final String mTitle; |
| + private final Bitmap mIcon; |
| + |
| + BrowserActionsCustomContextMenuItem(@IdRes int id, BrowserActionItem item) { |
|
Ted C
2017/04/19 19:58:41
javadoc for this
ltian
2017/04/21 05:10:54
Done.
|
| + mMenuId = id; |
| + mTitle = item.getTitle(); |
| + mIcon = item.getIcon(); |
| + } |
| + |
| + @Override |
| + public int getMenuId() { |
| + return mMenuId; |
| + } |
| + |
| + @Override |
| + public String getTitle(Context context) { |
| + return mTitle; |
| + } |
| + |
| + @Override |
| + public Drawable getDrawableAndDescription(Context context) { |
| + return new BitmapDrawable(context.getResources(), mIcon); |
|
Ted C
2017/04/19 19:58:41
I "think" we might want to cache this drawable. C
ltian
2017/04/21 05:10:54
Sorry I am not sure how should we cache this drawa
ltian
2017/04/26 23:44:40
Looks like the BitmapDrawable stores the reference
|
| + } |
| +} |