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

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

Issue 1509713004: Add a default share button to the menu of Custom Tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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/CustomTabIntentDataProvider.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
index 0ce31ff5fe2ce49382896b117e33fac8e3983def..d459ccc1d953758a39a6c0e7950d4a4c301520d7 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabIntentDataProvider.java
@@ -25,6 +25,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.browser.widget.TintedDrawable;
@@ -91,6 +92,7 @@ public class CustomTabIntentDataProvider {
private Drawable mCloseButtonIcon;
private List<Pair<String, PendingIntent>> mMenuEntries = new ArrayList<>();
private Bundle mAnimationBundle;
+ private boolean mShowShareItem;
// OnFinished listener for PendingIntents. Used for testing only.
private PendingIntent.OnFinished mOnFinished;
@@ -144,6 +146,8 @@ public class CustomTabIntentDataProvider {
intent, CustomTabsIntent.EXTRA_EXIT_ANIMATION_BUNDLE);
mTitleVisibilityState =
IntentUtils.safeGetIntExtra(intent, EXTRA_TITLE_VISIBILITY_STATE, NO_TITLE);
+ mShowShareItem = IntentUtils.safeGetBooleanExtra(intent,
+ CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM, false);
}
/**
@@ -211,6 +215,13 @@ public class CustomTabIntentDataProvider {
}
/**
+ * @return Whether the default share item should be shown in the menu.
+ */
+ public boolean shouldShowShareMenuItem() {
+ return mShowShareItem;
+ }
+
+ /**
* @return Whether the client app has provided sufficient info for the toolbar to show the
* action button.
*/
@@ -241,12 +252,12 @@ public class CustomTabIntentDataProvider {
* @param menuIndex The index that the menu item is shown in the result of
* {@link #getMenuTitles()}
*/
- public void clickMenuItemWithUrl(Context context, int menuIndex, String url) {
+ public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, String url) {
Intent addedIntent = new Intent();
addedIntent.setData(Uri.parse(url));
try {
PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second;
- pendingIntent.send(context, 0, addedIntent, mOnFinished, null);
+ pendingIntent.send(activity, 0, addedIntent, mOnFinished, null);
} catch (CanceledException e) {
Log.e(TAG, "Custom tab in Chrome failed to send pending intent.");
}

Powered by Google App Engine
This is Rietveld 408576698