| 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 40952d5cb02d28a8a561b094b7ef413893a1ed13..747512875899808e9514402555b8449187d228f1 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
|
| @@ -7,6 +7,7 @@ package org.chromium.chrome.browser.util;
|
| import android.content.ActivityNotFoundException;
|
| import android.content.Context;
|
| import android.content.Intent;
|
| +import android.os.BadParcelableException;
|
| import android.os.Binder;
|
| import android.os.Bundle;
|
| import android.os.IBinder;
|
| @@ -337,4 +338,24 @@ public class IntentUtils {
|
| public static boolean isIntentTooLarge(Intent intent) {
|
| return getParceledIntentSize(intent) > MAX_INTENT_SIZE_THRESHOLD;
|
| }
|
| +
|
| + /**
|
| + * Adds a long extra to an intent (if possible)
|
| + * In case unmarshalling fails, this will return a safe to use Intent containing the same
|
| + * action and data.
|
| + */
|
| + public static Intent safePutExtra(final Intent incomingIntent, final String extraName,
|
| + final long extraValue) {
|
| + try {
|
| + incomingIntent.putExtra(extraName, extraValue);
|
| + return incomingIntent;
|
| + } catch (BadParcelableException e) {
|
| + Log.e(TAG, "Invalid incoming intent.");
|
| + // Those two methods do not trigger unmarshalling, as they do not access extras.
|
| + final Intent safeIntent = new Intent(incomingIntent.getAction(),
|
| + incomingIntent.getData());
|
| + safeIntent.putExtra(extraName, extraValue);
|
| + return safeIntent;
|
| + }
|
| + }
|
| }
|
|
|