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

Unified Diff: chrome/android/java/src/android/support/customtabs/CustomTabsIntent.java

Issue 1303023002: Use third_party/custom_tabs_client as the src for customtabs library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/android/support/customtabs/CustomTabsIntent.java
diff --git a/chrome/android/java/src/android/support/customtabs/CustomTabsIntent.java b/chrome/android/java/src/android/support/customtabs/CustomTabsIntent.java
deleted file mode 100644
index cb33ff719187d87afe8cb516419cc95fa51af527..0000000000000000000000000000000000000000
--- a/chrome/android/java/src/android/support/customtabs/CustomTabsIntent.java
+++ /dev/null
@@ -1,132 +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 android.support.customtabs;
-
-import android.app.Activity;
-import android.app.ActivityOptions;
-import android.app.PendingIntent;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.IBinder;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Constants and utilities that will be used for low level control on customizing the UI and
- * functionality of a tab.
- */
-public class CustomTabsIntent {
-
- /**
- * Extra used to match the session. This has to be included in the intent to open in
- * a custom tab. This is the same IBinder that gets passed to ICustomTabsService#newSession.
- * Null if there is no need to match any service side sessions with the intent.
- */
- public static final String EXTRA_SESSION = "android.support.customtabs.extra.SESSION";
-
- /**
- * Extra that changes the background color for the toolbar. colorRes is an int that specifies a
- * {@link Color}, not a resource id.
- */
- public static final String EXTRA_TOOLBAR_COLOR =
- "android.support.customtabs.extra.TOOLBAR_COLOR";
-
- /**
- * Boolean extra that enables the url bar to hide as the user scrolls down the page
- */
- public static final String EXTRA_ENABLE_URLBAR_HIDING =
- "android.support.customtabs.extra.ENABLE_URLBAR_HIDING";
-
- /**
- * Bundle used for adding a custom action button to the custom tab toolbar. The client can
- * provide an icon {@link Bitmap} and a {@link PendingIntent} for the button.
- */
- public static final String EXTRA_ACTION_BUTTON_BUNDLE =
- "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE";
-
- /**
- * Key that specifies the {@link Bitmap} to be used as the image source for the action button.
- */
- public static final String KEY_ICON = "android.support.customtabs.customaction.ICON";
-
- /**
- * Key that specifies the content description for the custom action button.
- */
- public static final String KEY_DESCRIPTION =
- "android.support.customtabs.customaction.DESCRIPTION";
-
- /**
- * Key that specifies the PendingIntent to launch when the action button or menu item was
- * clicked. The custom tab will be calling {@link PendingIntent#send()} on clicks after adding
- * the url as data. The client app can call {@link Intent#getDataString()} to get the url.
- */
- public static final String KEY_PENDING_INTENT =
- "android.support.customtabs.customaction.PENDING_INTENT";
-
- /**
- * Use an {@code ArrayList<Bundle>} for specifying menu related params. There should be a
- * separate {@link Bundle} for each custom menu item.
- */
- public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
-
- /**
- * Key for specifying the title of a menu item.
- */
- public static final String KEY_MENU_ITEM_TITLE =
- "android.support.customtabs.customaction.MENU_ITEM_TITLE";
-
- /**
- * Bundle constructed out of {@link ActivityOptions} that will be running when the
- * {@link Activity} that holds the custom tab gets finished. A similar ActivityOptions
- * for creation should be constructed and given to the startActivity() call that
- * launches the custom tab.
- */
- public static final String EXTRA_EXIT_ANIMATION_BUNDLE =
- "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
-
- /**
- * Convenience method to create a VIEW intent without a session for the given package.
- * @param packageName The package name to set in the intent.
- * @param data The data {@link Uri} to be used in the intent.
- * @return The intent with the given package, data and the right session extra.
- */
- public static Intent getViewIntentWithNoSession(String packageName, Uri data) {
- Intent intent = new Intent(Intent.ACTION_VIEW, data);
- intent.setPackage(packageName);
- Bundle extras = new Bundle();
- if (!safePutBinder(extras, EXTRA_SESSION, null)) return null;
- intent.putExtras(extras);
- return intent;
- }
-
- /**
- * A convenience method to handle putting an {@link IBinder} inside a {@link Bundle} for all
- * Android version.
- * @param bundle The bundle to insert the {@link IBinder}.
- * @param key The key to use while putting the {@link IBinder}.
- * @param binder The {@link IBinder} to put.
- * @return Whether the operation was successful.
- */
- static boolean safePutBinder(Bundle bundle, String key, IBinder binder) {
- try {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- bundle.putBinder(key, binder);
- } else {
- Method putBinderMethod =
- Bundle.class.getMethod("putIBinder", String.class, IBinder.class);
- putBinderMethod.invoke(bundle, key, binder);
- }
- } catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException
- | NoSuchMethodException e) {
- return false;
- }
- return true;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698