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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java

Issue 1305253006: [Custom Tabs]Add API for updating action button as ContentProvider (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/org/chromium/chrome/browser/util/IntentUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
index a66722fbb97b993774db422ae11a334216a4972f..7fe591657bbfdf47366c46b83982d891c3c4006c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
@@ -24,7 +24,7 @@ import java.util.List;
* Utilities dealing with extracting information from intents.
*/
public class IntentUtils {
- private static final String TAG = "IntentUtils";
+ private static final String TAG = "cr.IntentUtils";
/**
* Retrieves a list of components that would handle the given intent.
@@ -120,6 +120,19 @@ public class IntentUtils {
}
/**
+ * Just like {@link Bundle#getBundle(String)} but doesn't throw exceptions.
+ */
+ public static Bundle safeGetBundle(Bundle bundle, String name) {
+ try {
+ return bundle.getBundle(name);
+ } catch (Throwable t) {
+ // Catches un-parceling exceptions.
+ Log.e(TAG, "getBundle failed on bundle " + bundle);
+ return null;
+ }
+ }
+
+ /**
* Just like {@link Bundle#getParcelable(String)} but doesn't throw exceptions.
*/
public static <T extends Parcelable> T safeGetParcelable(Bundle bundle, String name) {
@@ -193,20 +206,28 @@ public class IntentUtils {
*/
public static IBinder safeGetBinderExtra(Intent intent, String name) {
if (!intent.hasExtra(name)) return null;
+ Bundle extras = intent.getExtras();
+ return safeGetBinder(extras, name);
+
+ }
+
+ /**
+ * @return A binder from a {@link Bundle}, or null;
+ */
+ public static IBinder safeGetBinder(Bundle bundle, String name) {
try {
- Bundle extras = intent.getExtras();
// Bundle#getBinder() is public starting at API level 18, but exists
// in previous SDKs as a hidden method named "getIBinder" (which
// still exists as of L MR1 but is hidden and deprecated).
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- return extras.getBinder(name);
+ return bundle.getBinder(name);
} else {
Method getBinderMethod = Bundle.class.getMethod("getIBinder", String.class);
- return (IBinder) getBinderMethod.invoke(extras, name);
+ return (IBinder) getBinderMethod.invoke(bundle, name);
}
} catch (Throwable t) {
// Catches un-parceling exceptions.
- Log.e(TAG, "getBinder failed on intent " + intent);
+ Log.e(TAG, "getBinder failed on bundle " + bundle);
return null;
}
}

Powered by Google App Engine
This is Rietveld 408576698