Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3166)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsCustomContextMenuItem.java

Issue 2815453002: [Android] Show Browser Actions dialog in Chrome (Closed)
Patch Set: Fix tests fail. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bd820159ed048a3284ef43a71ca7fb40a3810a38
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/browseractions/BrowserActionsCustomContextMenuItem.java
@@ -0,0 +1,50 @@
+// 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;
+
+ /**
+ * Constructor to build a custom context menu item from {@link BrowserActionItem}.
+ * @param id The {@link IdRes} of the custom context menu item.
+ * @param item The {@link BrowserActionItem} specifies the title and action of the menu item.
+ */
+ BrowserActionsCustomContextMenuItem(@IdRes int id, BrowserActionItem item) {
+ 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 getDrawable(Context context) {
+ return new BitmapDrawable(context.getResources(), mIcon);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698