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

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

Issue 2663373003: [Android] Add options in the context menu of CCT to open in a new Chrome tab or incoginto tab (Closed)
Patch Set: Rebase to master branch. Created 3 years, 10 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/customtabs/CustomTabAppMenuPropertiesDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
index e55fee034feab8663b2e77d8d74535fd60a7f408..d4c720db772886bae5d7b6c806d2b319259bda53 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabAppMenuPropertiesDelegate.java
@@ -4,18 +4,13 @@
package org.chromium.chrome.browser.customtabs;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.AsyncTask;
import android.view.Menu;
import android.view.MenuItem;
-import org.chromium.base.BuildInfo;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.DefaultBrowserInfo;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate;
import org.chromium.chrome.browser.banners.AppBannerManager;
@@ -27,7 +22,6 @@ import org.chromium.chrome.browser.tab.Tab;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ExecutionException;
/**
* App menu properties delegate for {@link CustomTabActivity}.
@@ -39,10 +33,10 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
private final boolean mIsMediaViewer;
private final boolean mShowStar;
private final boolean mShowDownload;
+ private final boolean mIsOpenedByChrome;
private final List<String> mMenuEntries;
private final Map<MenuItem, Integer> mItemToIndexMap = new HashMap<MenuItem, Integer>();
- private final AsyncTask<Void, Void, String> mDefaultBrowserFetcher;
private boolean mIsCustomEntryAdded;
@@ -58,29 +52,7 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
mIsMediaViewer = isMediaViewer;
mShowStar = showStar;
mShowDownload = showDownload;
-
- mDefaultBrowserFetcher = new AsyncTask<Void, Void, String>() {
- @Override
- protected String doInBackground(Void... params) {
- String packageLabel = null;
- if (isOpenedByChrome) {
- // If the Custom Tab was created by Chrome, Chrome should open it.
- packageLabel = BuildInfo.getPackageLabel(activity);
- } else {
- // Check if there is a default handler for the Intent. If so, grab its label.
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(SAMPLE_URL));
- PackageManager pm = activity.getPackageManager();
- ResolveInfo info = pm.resolveActivity(intent, 0);
- if (info != null && info.match != 0) {
- packageLabel = info.loadLabel(pm).toString();
- }
- }
-
- return packageLabel == null
- ? activity.getString(R.string.menu_open_in_product_default)
- : activity.getString(R.string.menu_open_in_product, packageLabel);
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ mIsOpenedByChrome = isOpenedByChrome;
}
@Override
@@ -122,13 +94,8 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
menu.findItem(R.id.request_desktop_site_id).setVisible(false);
addToHomeScreenItem.setVisible(false);
} else {
- try {
- openInChromeItem.setTitle(mDefaultBrowserFetcher.get());
- } catch (InterruptedException | ExecutionException e) {
- openInChromeItem.setTitle(
- mActivity.getString(R.string.menu_open_in_product_default));
- }
- updateBookmarkMenuItem(bookmarkItem, currentTab);
+ openInChromeItem.setTitle(
+ DefaultBrowserInfo.getTitleOpenInDefaultBrowser(mIsOpenedByChrome));
}
bookmarkItem.setVisible(mShowStar);
downloadItem.setVisible(mShowDownload);

Powered by Google App Engine
This is Rietveld 408576698