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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java

Issue 1206673003: Merge java_staging/src into java/src. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 6 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_staging/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
deleted file mode 100644
index 90d238222af3d61933a4b785e311c112e88ee7c7..0000000000000000000000000000000000000000
--- a/chrome/android/java_staging/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2015 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.customtabs;
-
-import android.view.Menu;
-import android.view.MenuItem;
-
-import org.chromium.base.VisibleForTesting;
-import org.chromium.chrome.R;
-import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.Tab;
-import org.chromium.chrome.browser.appmenu.ChromeAppMenuPropertiesDelegate;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * App menu properties delegate for {@link CustomTabActivity}.
- */
-public class CustomTabAppMenuPropertiesDelegate extends ChromeAppMenuPropertiesDelegate {
- private boolean mIsCustomEntryAdded;
- private List<String> mMenuEntries;
- private Map<MenuItem, Integer> mItemToIndexMap = new HashMap<MenuItem, Integer>();
- /**
- * Creates an {@link CustomTabAppMenuPropertiesDelegate} instance.
- */
- public CustomTabAppMenuPropertiesDelegate(ChromeActivity activity,
- List<String> menuEntries) {
- super(activity);
- mMenuEntries = menuEntries;
- }
-
- @Override
- public void prepareMenu(Menu menu) {
- Tab currentTab = mActivity.getActivityTab();
- if (currentTab != null) {
- MenuItem forwardMenuItem = menu.findItem(R.id.forward_menu_id);
- forwardMenuItem.setEnabled(currentTab.canGoForward());
-
- mReloadMenuItem = menu.findItem(R.id.reload_menu_id);
- mReloadMenuItem.setIcon(R.drawable.btn_reload_stop);
- loadingStateChanged(currentTab.isLoading());
-
- MenuItem openInChromeItem = menu.findItem(R.id.open_in_chrome_id);
- openInChromeItem.setTitle(mActivity.getString(R.string.menu_open_in_product,
- mActivity.getString(R.string.app_name)));
-
- // Add custom menu items. Make sure they are only added once.
- if (!mIsCustomEntryAdded) {
- mIsCustomEntryAdded = true;
- for (int i = 0; i < mMenuEntries.size(); i++) {
- MenuItem item = menu.add(0, 0, 1, mMenuEntries.get(i));
- mItemToIndexMap.put(item, i);
- }
- }
- }
- }
-
- /**
- * @return The index that the given menu item should appear in the result of
- * {@link CustomTabIntentDataProvider#getMenuTitles()}. Returns -1 if item not found.
- */
- public int getIndexOfMenuItem(MenuItem menuItem) {
- if (!mItemToIndexMap.containsKey(menuItem)) {
- return -1;
- }
- return mItemToIndexMap.get(menuItem).intValue();
- }
-
- /**
- * Get the {@link MenuItem} object associated with the given title. If multiple menu items have
- * the same title, a random one will be returned. This method is for testing purpose _only_.
- */
- @VisibleForTesting
- MenuItem getMenuItemForTitle(String title) {
- for (MenuItem item : mItemToIndexMap.keySet()) {
- if (item.getTitle().equals(title)) return item;
- }
- return null;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698