Commit ec7832af authored by Piotr Swigon's avatar Piotr Swigon Committed by Commit Bot

[CustomTab] First step of a refactoring introducing CustomTabsUiType.

This should be a no-op functionality wise.

This patch introduces CustomTabsUiType as a better way to specify the
look&feel of the UI. In this and following patches I will aim to
minimize number of intent EXTRAs and replace multiple booleans
indicating visibility of various UI elements with a single value
specifying a UI type.

This patch takes care of only few low hanging fruits to make it easy to
review. I plan to make a few more code structure and readability
improvements on top of this later on.

This refactoring is considered a prerequisite to introducing Minimal-UI
PWA display mode, which is yet another UI type for Custom Tab.

Bug: 604390
Change-Id: Ifa75e341dd1f7ac64cfa70c4dbb507b3df9c7f6c
Reviewed-on: https://chromium-review.googlesource.com/567789
Commit-Queue: Piotr Swigon <piotrs@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486681}
parent 2f67c627
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
package org.chromium.chrome.browser.customtabs; package org.chromium.chrome.browser.customtabs;
import static org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider.CUSTOM_TABS_UI_TYPE_DEFAULT;
import static org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider.CUSTOM_TABS_UI_TYPE_INFO_PAGE;
import android.app.Activity; import android.app.Activity;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
...@@ -803,12 +806,13 @@ public class CustomTabActivity extends ChromeActivity { ...@@ -803,12 +806,13 @@ public class CustomTabActivity extends ChromeActivity {
@Override @Override
protected AppMenuPropertiesDelegate createAppMenuPropertiesDelegate() { protected AppMenuPropertiesDelegate createAppMenuPropertiesDelegate() {
return new CustomTabAppMenuPropertiesDelegate(this, mIntentDataProvider.getMenuTitles(), return new CustomTabAppMenuPropertiesDelegate(this,
mIntentDataProvider.getUiType(),
mIntentDataProvider.getMenuTitles(),
mIntentDataProvider.isOpenedByChrome(),
mIntentDataProvider.shouldShowShareMenuItem(), mIntentDataProvider.shouldShowShareMenuItem(),
mIntentDataProvider.isOpenedByChrome(), mIntentDataProvider.isMediaViewer(),
mIntentDataProvider.shouldShowStarButton(), mIntentDataProvider.shouldShowStarButton(),
mIntentDataProvider.shouldShowDownloadButton(), mIntentDataProvider.shouldShowDownloadButton());
mIntentDataProvider.isPaymentRequestUI());
} }
@Override @Override
...@@ -1185,7 +1189,7 @@ public class CustomTabActivity extends ChromeActivity { ...@@ -1185,7 +1189,7 @@ public class CustomTabActivity extends ChromeActivity {
Intent intent = ChromeLauncherActivity.createCustomTabActivityIntent( Intent intent = ChromeLauncherActivity.createCustomTabActivityIntent(
context, customTabIntent.intent, false); context, customTabIntent.intent, false);
intent.setPackage(context.getPackageName()); intent.setPackage(context.getPackageName());
intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_INFO_PAGE, true); intent.putExtra(CustomTabIntentDataProvider.EXTRA_UI_TYPE, CUSTOM_TABS_UI_TYPE_INFO_PAGE);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
if (!(context instanceof Activity)) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (!(context instanceof Activity)) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
IntentHandler.addTrustedIntentExtras(intent); IntentHandler.addTrustedIntentExtras(intent);
...@@ -1197,8 +1201,8 @@ public class CustomTabActivity extends ChromeActivity { ...@@ -1197,8 +1201,8 @@ public class CustomTabActivity extends ChromeActivity {
protected boolean requiresFirstRunToBeCompleted(Intent intent) { protected boolean requiresFirstRunToBeCompleted(Intent intent) {
// Custom Tabs can be used to open Chrome help pages before the ToS has been accepted. // Custom Tabs can be used to open Chrome help pages before the ToS has been accepted.
if (IntentHandler.isIntentChromeOrFirstParty(intent) if (IntentHandler.isIntentChromeOrFirstParty(intent)
&& IntentUtils.safeGetBooleanExtra( && IntentUtils.safeGetIntExtra(intent, CustomTabIntentDataProvider.EXTRA_UI_TYPE,
intent, CustomTabIntentDataProvider.EXTRA_IS_INFO_PAGE, false)) { CUSTOM_TABS_UI_TYPE_DEFAULT) == CUSTOM_TABS_UI_TYPE_INFO_PAGE) {
return false; return false;
} }
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
package org.chromium.chrome.browser.customtabs; package org.chromium.chrome.browser.customtabs;
import static org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider.CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER;
import static org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider.CUSTOM_TABS_UI_TYPE_PAYMENT_REQUEST;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
...@@ -13,6 +16,7 @@ import org.chromium.chrome.browser.ChromeActivity; ...@@ -13,6 +16,7 @@ import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.DefaultBrowserInfo; import org.chromium.chrome.browser.DefaultBrowserInfo;
import org.chromium.chrome.browser.UrlConstants; import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate; import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate;
import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider.CustomTabsUiType;
import org.chromium.chrome.browser.download.DownloadUtils; import org.chromium.chrome.browser.download.DownloadUtils;
import org.chromium.chrome.browser.firstrun.FirstRunStatus; import org.chromium.chrome.browser.firstrun.FirstRunStatus;
import org.chromium.chrome.browser.share.ShareHelper; import org.chromium.chrome.browser.share.ShareHelper;
...@@ -26,14 +30,11 @@ import java.util.Map; ...@@ -26,14 +30,11 @@ import java.util.Map;
* App menu properties delegate for {@link CustomTabActivity}. * App menu properties delegate for {@link CustomTabActivity}.
*/ */
public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegate { public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegate {
private static final String SAMPLE_URL = "https://www.google.com"; private final @CustomTabsUiType int mUiType;
private final boolean mShowShare; private final boolean mShowShare;
private final boolean mIsMediaViewer;
private final boolean mShowStar; private final boolean mShowStar;
private final boolean mShowDownload; private final boolean mShowDownload;
private final boolean mIsOpenedByChrome; private final boolean mIsOpenedByChrome;
private final boolean mIsPaymentRequestUI;
private final List<String> mMenuEntries; private final List<String> mMenuEntries;
private final Map<MenuItem, Integer> mItemToIndexMap = new HashMap<MenuItem, Integer>(); private final Map<MenuItem, Integer> mItemToIndexMap = new HashMap<MenuItem, Integer>();
...@@ -44,17 +45,15 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat ...@@ -44,17 +45,15 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
* Creates an {@link CustomTabAppMenuPropertiesDelegate} instance. * Creates an {@link CustomTabAppMenuPropertiesDelegate} instance.
*/ */
public CustomTabAppMenuPropertiesDelegate(final ChromeActivity activity, public CustomTabAppMenuPropertiesDelegate(final ChromeActivity activity,
List<String> menuEntries, boolean showShare, final boolean isOpenedByChrome, @CustomTabsUiType final int uiType, List<String> menuEntries, boolean isOpenedByChrome,
final boolean isMediaViewer, boolean showStar, boolean showDownload, boolean showShare, boolean showStar, boolean showDownload) {
final boolean isPaymentRequestUI) {
super(activity); super(activity);
mUiType = uiType;
mMenuEntries = menuEntries; mMenuEntries = menuEntries;
mIsOpenedByChrome = isOpenedByChrome;
mShowShare = showShare; mShowShare = showShare;
mIsMediaViewer = isMediaViewer;
mShowStar = showStar; mShowStar = showStar;
mShowDownload = showDownload; mShowDownload = showDownload;
mIsOpenedByChrome = isOpenedByChrome;
mIsPaymentRequestUI = isPaymentRequestUI;
} }
@Override @Override
...@@ -84,25 +83,29 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat ...@@ -84,25 +83,29 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
boolean addToHomeScreenVisible = true; boolean addToHomeScreenVisible = true;
updateRequestDesktopSiteMenuItem(menu, currentTab); updateRequestDesktopSiteMenuItem(menu, currentTab);
if (mIsMediaViewer) { if (mUiType == CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER) {
// Most of the menu items don't make sense when viewing media. // Most of the menu items don't make sense when viewing media.
iconRow.setVisible(false); iconRow.setVisible(false);
openInChromeItem.setVisible(false); openInChromeItem.setVisible(false);
menu.findItem(R.id.find_in_page_id).setVisible(false); menu.findItem(R.id.find_in_page_id).setVisible(false);
menu.findItem(R.id.request_desktop_site_row_menu_id).setVisible(false); menu.findItem(R.id.request_desktop_site_row_menu_id).setVisible(false);
addToHomeScreenVisible = false; addToHomeScreenVisible = false;
} else if (mIsPaymentRequestUI) { } else if (mUiType == CUSTOM_TABS_UI_TYPE_PAYMENT_REQUEST) {
// Only the icon row and 'find in page' are shown for openning payment request UI // Only the icon row and 'find in page' are shown for openning payment request UI
// from Chrome. // from Chrome.
openInChromeItem.setVisible(false); openInChromeItem.setVisible(false);
menu.findItem(R.id.request_desktop_site_id).setVisible(false); menu.findItem(R.id.request_desktop_site_id).setVisible(false);
addToHomeScreenVisible = false; addToHomeScreenVisible = false;
downloadItem.setVisible(false);
bookmarkItem.setVisible(false);
} else { } else {
openInChromeItem.setTitle( openInChromeItem.setTitle(
DefaultBrowserInfo.getTitleOpenInDefaultBrowser(mIsOpenedByChrome)); DefaultBrowserInfo.getTitleOpenInDefaultBrowser(mIsOpenedByChrome));
updateBookmarkMenuItem(bookmarkItem, currentTab); updateBookmarkMenuItem(bookmarkItem, currentTab);
} }
bookmarkItem.setVisible(mShowStar); if (!mShowStar) {
bookmarkItem.setVisible(false);
}
downloadItem.setVisible(mShowDownload); downloadItem.setVisible(mShowDownload);
if (!FirstRunStatus.getFirstRunFlowComplete()) { if (!FirstRunStatus.getFirstRunFlowComplete()) {
openInChromeItem.setVisible(false); openInChromeItem.setVisible(false);
...@@ -146,7 +149,7 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat ...@@ -146,7 +149,7 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
@Override @Override
public int getFooterResourceId() { public int getFooterResourceId() {
return mIsMediaViewer ? 0 : R.layout.powered_by_chrome_footer; return mUiType == CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER ? 0 : R.layout.powered_by_chrome_footer;
} }
/** /**
......
...@@ -16,6 +16,7 @@ import android.graphics.drawable.Drawable; ...@@ -16,6 +16,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.IntDef;
import android.support.customtabs.CustomTabsIntent; import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.CustomTabsSessionToken; import android.support.customtabs.CustomTabsSessionToken;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -33,6 +34,8 @@ import org.chromium.chrome.browser.IntentHandler; ...@@ -33,6 +34,8 @@ import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.util.IntentUtils; import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.browser.widget.TintedDrawable; import org.chromium.chrome.browser.widget.TintedDrawable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -43,6 +46,20 @@ import java.util.List; ...@@ -43,6 +46,20 @@ import java.util.List;
public class CustomTabIntentDataProvider { public class CustomTabIntentDataProvider {
private static final String TAG = "CustomTabIntentData"; private static final String TAG = "CustomTabIntentData";
// The type of UI for Custom Tab to use.
@Retention(RetentionPolicy.SOURCE)
@IntDef({
CUSTOM_TABS_UI_TYPE_DEFAULT,
CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER,
CUSTOM_TABS_UI_TYPE_PAYMENT_REQUEST,
CUSTOM_TABS_UI_TYPE_INFO_PAGE,
})
public @interface CustomTabsUiType {}
public static final int CUSTOM_TABS_UI_TYPE_DEFAULT = 0;
public static final int CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER = 1;
public static final int CUSTOM_TABS_UI_TYPE_PAYMENT_REQUEST = 2;
public static final int CUSTOM_TABS_UI_TYPE_INFO_PAGE = 3;
/** /**
* Extra used to keep the caller alive. Its value is an Intent. * Extra used to keep the caller alive. Its value is an Intent.
*/ */
...@@ -55,10 +72,6 @@ public class CustomTabIntentDataProvider { ...@@ -55,10 +72,6 @@ public class CustomTabIntentDataProvider {
public static final String EXTRA_IS_OPENED_BY_CHROME = public static final String EXTRA_IS_OPENED_BY_CHROME =
"org.chromium.chrome.browser.customtabs.IS_OPENED_BY_CHROME"; "org.chromium.chrome.browser.customtabs.IS_OPENED_BY_CHROME";
/** Indicates that the Custom Tab should style itself as a media viewer. */
public static final String EXTRA_IS_MEDIA_VIEWER =
"org.chromium.chrome.browser.customtabs.IS_MEDIA_VIEWER";
/** URL that should be loaded in place of the URL passed along in the data. */ /** URL that should be loaded in place of the URL passed along in the data. */
public static final String EXTRA_MEDIA_VIEWER_URL = public static final String EXTRA_MEDIA_VIEWER_URL =
"org.chromium.chrome.browser.customtabs.MEDIA_VIEWER_URL"; "org.chromium.chrome.browser.customtabs.MEDIA_VIEWER_URL";
...@@ -67,13 +80,9 @@ public class CustomTabIntentDataProvider { ...@@ -67,13 +80,9 @@ public class CustomTabIntentDataProvider {
public static final String EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE = public static final String EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE =
"org.chromium.chrome.browser.customtabs.EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE"; "org.chromium.chrome.browser.customtabs.EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE";
/** Indicates that the Custom Tab should style itself as payment request UI. */ /** Indicates the type of UI Custom Tab should use. */
public static final String EXTRA_IS_PAYMENT_REQUEST_UI = public static final String EXTRA_UI_TYPE =
"org.chromium.chrome.browser.customtabs.EXTRA_IS_PAYMENT_REQUEST_UI"; "org.chromium.chrome.browser.customtabs.EXTRA_UI_TYPE";
/** Indicates that the Custom Tab should style itself as an info page. */
public static final String EXTRA_IS_INFO_PAGE =
"org.chromium.chrome.browser.customtabs.IS_INFO_PAGE";
/** Extra that defines the initial background color (RGB color stored as an integer). */ /** Extra that defines the initial background color (RGB color stored as an integer). */
public static final String EXTRA_INITIAL_BACKGROUND_COLOR = public static final String EXTRA_INITIAL_BACKGROUND_COLOR =
...@@ -104,12 +113,10 @@ public class CustomTabIntentDataProvider { ...@@ -104,12 +113,10 @@ public class CustomTabIntentDataProvider {
private final CustomTabsSessionToken mSession; private final CustomTabsSessionToken mSession;
private final boolean mIsTrustedIntent; private final boolean mIsTrustedIntent;
private final Intent mKeepAliveServiceIntent; private final Intent mKeepAliveServiceIntent;
private final int mUiType;
private final int mTitleVisibilityState; private final int mTitleVisibilityState;
private final boolean mIsMediaViewer;
private final String mMediaViewerUrl; private final String mMediaViewerUrl;
private final boolean mEnableEmbeddedMediaExperience; private final boolean mEnableEmbeddedMediaExperience;
private final boolean mIsPaymentRequestUI;
private final boolean mIsInfoPage;
private final int mInitialBackgroundColor; private final int mInitialBackgroundColor;
private final boolean mDisableStar; private final boolean mDisableStar;
private final boolean mDisableDownload; private final boolean mDisableDownload;
...@@ -137,10 +144,8 @@ public class CustomTabIntentDataProvider { ...@@ -137,10 +144,8 @@ public class CustomTabIntentDataProvider {
* Add extras to customize menu items for openning payment request UI custom tab from Chrome. * Add extras to customize menu items for openning payment request UI custom tab from Chrome.
*/ */
public static void addPaymentRequestUIExtras(Intent intent) { public static void addPaymentRequestUIExtras(Intent intent) {
intent.putExtra(EXTRA_IS_PAYMENT_REQUEST_UI, true); intent.putExtra(EXTRA_UI_TYPE, CUSTOM_TABS_UI_TYPE_PAYMENT_REQUEST);
intent.putExtra(EXTRA_IS_OPENED_BY_CHROME, true); intent.putExtra(EXTRA_IS_OPENED_BY_CHROME, true);
intent.putExtra(EXTRA_DISABLE_STAR_BUTTON, true);
intent.putExtra(EXTRA_DISABLE_DOWNLOAD_BUTTON, true);
IntentHandler.addTrustedIntentExtras(intent); IntentHandler.addTrustedIntentExtras(intent);
} }
...@@ -191,6 +196,19 @@ public class CustomTabIntentDataProvider { ...@@ -191,6 +196,19 @@ public class CustomTabIntentDataProvider {
mIsOpenedByChrome = mIsOpenedByChrome =
IntentUtils.safeGetBooleanExtra(intent, EXTRA_IS_OPENED_BY_CHROME, false); IntentUtils.safeGetBooleanExtra(intent, EXTRA_IS_OPENED_BY_CHROME, false);
final int requestedUiType =
IntentUtils.safeGetIntExtra(intent, EXTRA_UI_TYPE, CUSTOM_TABS_UI_TYPE_DEFAULT);
if (requestedUiType == CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER && mIsTrustedIntent) {
mUiType = CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER;
} else if (requestedUiType == CUSTOM_TABS_UI_TYPE_PAYMENT_REQUEST && mIsTrustedIntent
&& mIsOpenedByChrome) {
mUiType = CUSTOM_TABS_UI_TYPE_PAYMENT_REQUEST;
} else if (requestedUiType == CUSTOM_TABS_UI_TYPE_INFO_PAGE && mIsTrustedIntent) {
mUiType = CUSTOM_TABS_UI_TYPE_INFO_PAGE;
} else {
mUiType = CUSTOM_TABS_UI_TYPE_DEFAULT;
}
mAnimationBundle = IntentUtils.safeGetBundleExtra( mAnimationBundle = IntentUtils.safeGetBundleExtra(
intent, CustomTabsIntent.EXTRA_EXIT_ANIMATION_BUNDLE); intent, CustomTabsIntent.EXTRA_EXIT_ANIMATION_BUNDLE);
mTitleVisibilityState = IntentUtils.safeGetIntExtra(intent, mTitleVisibilityState = IntentUtils.safeGetIntExtra(intent,
...@@ -203,17 +221,12 @@ public class CustomTabIntentDataProvider { ...@@ -203,17 +221,12 @@ public class CustomTabIntentDataProvider {
CustomTabsIntent.EXTRA_REMOTEVIEWS_VIEW_IDS); CustomTabsIntent.EXTRA_REMOTEVIEWS_VIEW_IDS);
mRemoteViewsPendingIntent = IntentUtils.safeGetParcelableExtra(intent, mRemoteViewsPendingIntent = IntentUtils.safeGetParcelableExtra(intent,
CustomTabsIntent.EXTRA_REMOTEVIEWS_PENDINGINTENT); CustomTabsIntent.EXTRA_REMOTEVIEWS_PENDINGINTENT);
mIsMediaViewer = mIsTrustedIntent mMediaViewerUrl = isMediaViewer()
&& IntentUtils.safeGetBooleanExtra(intent, EXTRA_IS_MEDIA_VIEWER, false); ? IntentUtils.safeGetStringExtra(intent, EXTRA_MEDIA_VIEWER_URL)
mMediaViewerUrl = mIsMediaViewer : null;
? IntentUtils.safeGetStringExtra(intent, EXTRA_MEDIA_VIEWER_URL) : null;
mEnableEmbeddedMediaExperience = mIsTrustedIntent mEnableEmbeddedMediaExperience = mIsTrustedIntent
&& IntentUtils.safeGetBooleanExtra( && IntentUtils.safeGetBooleanExtra(
intent, EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE, false); intent, EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE, false);
mIsPaymentRequestUI = mIsTrustedIntent && mIsOpenedByChrome
&& IntentUtils.safeGetBooleanExtra(intent, EXTRA_IS_PAYMENT_REQUEST_UI, false);
mIsInfoPage = mIsTrustedIntent
&& IntentUtils.safeGetBooleanExtra(intent, EXTRA_IS_INFO_PAGE, false);
mDisableStar = IntentUtils.safeGetBooleanExtra(intent, EXTRA_DISABLE_STAR_BUTTON, false); mDisableStar = IntentUtils.safeGetBooleanExtra(intent, EXTRA_DISABLE_STAR_BUTTON, false);
mDisableDownload = IntentUtils.safeGetBooleanExtra(intent, EXTRA_DISABLE_DOWNLOAD_BUTTON, mDisableDownload = IntentUtils.safeGetBooleanExtra(intent, EXTRA_DISABLE_DOWNLOAD_BUTTON,
false); false);
...@@ -518,10 +531,15 @@ public class CustomTabIntentDataProvider { ...@@ -518,10 +531,15 @@ public class CustomTabIntentDataProvider {
} }
/** /**
* @return See {@link #EXTRA_IS_MEDIA_VIEWER}. * @return See {@link #EXTRA_UI_TYPE}.
*/ */
boolean isMediaViewer() { boolean isMediaViewer() {
return mIsMediaViewer; return mUiType == CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER;
}
@CustomTabsUiType
int getUiType() {
return mUiType;
} }
/** /**
...@@ -538,20 +556,12 @@ public class CustomTabIntentDataProvider { ...@@ -538,20 +556,12 @@ public class CustomTabIntentDataProvider {
return mEnableEmbeddedMediaExperience; return mEnableEmbeddedMediaExperience;
} }
/**
* @return true If the Custom Tab is opened as payment request UI.
* @See {@link #EXTRA_IS_PAYMENT_REQUEST_UI}.
*/
boolean isPaymentRequestUI() {
return mIsPaymentRequestUI;
}
/** /**
* @return If the Custom Tab is an info page. * @return If the Custom Tab is an info page.
* See {@link #EXTRA_IS_INFO_PAGE}. * See {@link #EXTRA_UI_TYPE}.
*/ */
boolean isInfoPage() { boolean isInfoPage() {
return mIsInfoPage; return mUiType == CUSTOM_TABS_UI_TYPE_INFO_PAGE;
} }
/** /**
......
...@@ -487,7 +487,8 @@ public class DownloadUtils { ...@@ -487,7 +487,8 @@ public class DownloadUtils {
Intent intent = builder.build().intent; Intent intent = builder.build().intent;
intent.setPackage(context.getPackageName()); intent.setPackage(context.getPackageName());
intent.setData(contentUri); intent.setData(contentUri);
intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_MEDIA_VIEWER, true); intent.putExtra(CustomTabIntentDataProvider.EXTRA_UI_TYPE,
CustomTabIntentDataProvider.CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER);
intent.putExtra(CustomTabIntentDataProvider.EXTRA_MEDIA_VIEWER_URL, fileUri.toString()); intent.putExtra(CustomTabIntentDataProvider.EXTRA_MEDIA_VIEWER_URL, fileUri.toString());
intent.putExtra(CustomTabIntentDataProvider.EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE, true); intent.putExtra(CustomTabIntentDataProvider.EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE, true);
intent.putExtra( intent.putExtra(
......
...@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.customtabs; ...@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.customtabs;
import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE; import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_END_DEVICE;
import static org.chromium.chrome.browser.customtabs.CustomTabActivityTestRule.LONG_TIMEOUT_MS; import static org.chromium.chrome.browser.customtabs.CustomTabActivityTestRule.LONG_TIMEOUT_MS;
import static org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider.CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER;
import android.app.Activity; import android.app.Activity;
import android.app.Instrumentation; import android.app.Instrumentation;
...@@ -548,7 +549,8 @@ public class CustomTabActivityTest { ...@@ -548,7 +549,8 @@ public class CustomTabActivityTest {
@RetryOnFailure @RetryOnFailure
public void testAppMenuForMediaViewer() throws InterruptedException { public void testAppMenuForMediaViewer() throws InterruptedException {
Intent intent = createMinimalCustomTabIntent(); Intent intent = createMinimalCustomTabIntent();
intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_MEDIA_VIEWER, true); intent.putExtra(
CustomTabIntentDataProvider.EXTRA_UI_TYPE, CUSTOM_TABS_UI_TYPE_MEDIA_VIEWER);
IntentHandler.addTrustedIntentExtras(intent); IntentHandler.addTrustedIntentExtras(intent);
mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent); mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment