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

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

Issue 2872353004: [Android] Implement copy and open in background of Browser Actions (Closed)
Patch Set: Rebase. Created 3 years, 7 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a3fa31f1f084fab4cd4d3fc1bfbb03fb4f6f2f15..ba7bb632728674b5bf8595751588e66a9c7a60cc 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
@@ -20,6 +20,7 @@ import android.support.v4.app.BundleCompat;
import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
+import java.io.Serializable;
import java.util.ArrayList;
/**
@@ -265,6 +266,23 @@ public class IntentUtils {
}
/**
+ * Just like {@link Intent#getSerializableExtra(String)} but doesn't throw exceptions.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends Serializable> T safeGetSerializableExtra(Intent intent, String name) {
+ try {
+ return (T) intent.getSerializableExtra(name);
+ } catch (ClassCastException ex) {
+ Log.e(TAG, "Invalide class for Serializable: " + name, ex);
+ return null;
+ } catch (Throwable t) {
+ // Catches un-serializable exceptions.
+ Log.e(TAG, "getSerializableExtra failed on intent " + intent);
+ return null;
+ }
+ }
+
+ /**
* Just like {@link BundleCompat#getBinder()}, but doesn't throw exceptions.
*/
public static IBinder safeGetBinder(Bundle bundle, String name) {
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698