Commit 1bb67aa7 authored by dfalcantara's avatar dfalcantara Committed by Commit bot

Remove requirement for an error message for showing Intents

There are situations where we really don't mind if firing a
[Pending]Intent doesn't return to Chrome.  In these cases,
alerting the user about Chrome dying is unnecessary.

BUG=453170

Review URL: https://codereview.chromium.org/907593002

Cr-Commit-Position: refs/heads/master@{#315178}
parent 660e2d46
...@@ -28,15 +28,15 @@ import org.chromium.ui.base.ActivityWindowAndroid; ...@@ -28,15 +28,15 @@ import org.chromium.ui.base.ActivityWindowAndroid;
*/ */
public class SelectFileDialogTest extends ChromeShellTestBase { public class SelectFileDialogTest extends ChromeShellTestBase {
private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( private static final String DATA_URL = UrlUtils.encodeHtmlDataUri(
"<html><head><meta name=\"viewport\"" + "<html><head><meta name=\"viewport\""
"content=\"width=device-width, initial-scale=2.0, maximum-scale=2.0\" /></head>" + + "content=\"width=device-width, initial-scale=2.0, maximum-scale=2.0\" /></head>"
"<body><form action=\"about:blank\">" + + "<body><form action=\"about:blank\">"
"<input id=\"input_file\" type=\"file\" /><br/>" + + "<input id=\"input_file\" type=\"file\" /><br/>"
"<input id=\"input_file_multiple\" type=\"file\" multiple /><br />" + + "<input id=\"input_file_multiple\" type=\"file\" multiple /><br />"
"<input id=\"input_image\" type=\"file\" accept=\"image/*\" capture /><br/>" + + "<input id=\"input_image\" type=\"file\" accept=\"image/*\" capture /><br/>"
"<input id=\"input_audio\" type=\"file\" accept=\"audio/*\" capture />" + + "<input id=\"input_audio\" type=\"file\" accept=\"audio/*\" capture />"
"</form>" + + "</form>"
"</body></html>"); + "</body></html>");
private ContentViewCore mContentViewCore; private ContentViewCore mContentViewCore;
private ActivityWindowAndroidForTest mActivityWindowAndroidForTest; private ActivityWindowAndroidForTest mActivityWindowAndroidForTest;
...@@ -52,7 +52,7 @@ public class SelectFileDialogTest extends ChromeShellTestBase { ...@@ -52,7 +52,7 @@ public class SelectFileDialogTest extends ChromeShellTestBase {
} }
@Override @Override
public int showCancelableIntent(Intent intent, IntentCallback callback, int errorId) { public int showCancelableIntent(Intent intent, IntentCallback callback, Integer errorId) {
lastIntent = intent; lastIntent = intent;
lastCallback = callback; lastCallback = callback;
return 1; return 1;
......
...@@ -32,7 +32,8 @@ public class ActivityWindowAndroid extends WindowAndroid { ...@@ -32,7 +32,8 @@ public class ActivityWindowAndroid extends WindowAndroid {
} }
@Override @Override
public int showCancelableIntent(PendingIntent intent, IntentCallback callback, int errorId) { public int showCancelableIntent(
PendingIntent intent, IntentCallback callback, Integer errorId) {
Activity activity = mActivityRef.get(); Activity activity = mActivityRef.get();
if (activity == null) return START_INTENT_FAILURE; if (activity == null) return START_INTENT_FAILURE;
...@@ -50,7 +51,7 @@ public class ActivityWindowAndroid extends WindowAndroid { ...@@ -50,7 +51,7 @@ public class ActivityWindowAndroid extends WindowAndroid {
} }
@Override @Override
public int showCancelableIntent(Intent intent, IntentCallback callback, int errorId) { public int showCancelableIntent(Intent intent, IntentCallback callback, Integer errorId) {
Activity activity = mActivityRef.get(); Activity activity = mActivityRef.get();
if (activity == null) return START_INTENT_FAILURE; if (activity == null) return START_INTENT_FAILURE;
...@@ -104,8 +105,9 @@ public class ActivityWindowAndroid extends WindowAndroid { ...@@ -104,8 +105,9 @@ public class ActivityWindowAndroid extends WindowAndroid {
return requestCode; return requestCode;
} }
private void storeCallbackData(int requestCode, IntentCallback callback, int errorId) { private void storeCallbackData(int requestCode, IntentCallback callback, Integer errorId) {
mOutstandingIntents.put(requestCode, callback); mOutstandingIntents.put(requestCode, callback);
mIntentErrors.put(requestCode, mApplicationContext.getString(errorId)); mIntentErrors.put(
requestCode, errorId == null ? null : mApplicationContext.getString(errorId));
} }
} }
...@@ -91,10 +91,10 @@ public class WindowAndroid { ...@@ -91,10 +91,10 @@ public class WindowAndroid {
* @param intent The PendingIntent that needs to be shown. * @param intent The PendingIntent that needs to be shown.
* @param callback The object that will receive the results for the intent. * @param callback The object that will receive the results for the intent.
* @param errorId The ID of error string to be show if activity is paused before intent * @param errorId The ID of error string to be show if activity is paused before intent
* results. * results, or null if no message is required.
* @return Whether the intent was shown. * @return Whether the intent was shown.
*/ */
public boolean showIntent(PendingIntent intent, IntentCallback callback, int errorId) { public boolean showIntent(PendingIntent intent, IntentCallback callback, Integer errorId) {
return showCancelableIntent(intent, callback, errorId) >= 0; return showCancelableIntent(intent, callback, errorId) >= 0;
} }
...@@ -103,10 +103,10 @@ public class WindowAndroid { ...@@ -103,10 +103,10 @@ public class WindowAndroid {
* @param intent The intent that needs to be shown. * @param intent The intent that needs to be shown.
* @param callback The object that will receive the results for the intent. * @param callback The object that will receive the results for the intent.
* @param errorId The ID of error string to be show if activity is paused before intent * @param errorId The ID of error string to be show if activity is paused before intent
* results. * results, or null if no message is required.
* @return Whether the intent was shown. * @return Whether the intent was shown.
*/ */
public boolean showIntent(Intent intent, IntentCallback callback, int errorId) { public boolean showIntent(Intent intent, IntentCallback callback, Integer errorId) {
return showCancelableIntent(intent, callback, errorId) >= 0; return showCancelableIntent(intent, callback, errorId) >= 0;
} }
...@@ -115,11 +115,12 @@ public class WindowAndroid { ...@@ -115,11 +115,12 @@ public class WindowAndroid {
* @param intent The PendingIntent that needs to be shown. * @param intent The PendingIntent that needs to be shown.
* @param callback The object that will receive the results for the intent. * @param callback The object that will receive the results for the intent.
* @param errorId The ID of error string to be show if activity is paused before intent * @param errorId The ID of error string to be show if activity is paused before intent
* results. * results, or null if no message is required.
* @return A non-negative request code that could be used for finishActivity, or * @return A non-negative request code that could be used for finishActivity, or
* START_INTENT_FAILURE if failed. * START_INTENT_FAILURE if failed.
*/ */
public int showCancelableIntent(PendingIntent intent, IntentCallback callback, int errorId) { public int showCancelableIntent(
PendingIntent intent, IntentCallback callback, Integer errorId) {
Log.d(TAG, "Can't show intent as context is not an Activity: " + intent); Log.d(TAG, "Can't show intent as context is not an Activity: " + intent);
return START_INTENT_FAILURE; return START_INTENT_FAILURE;
} }
...@@ -129,11 +130,11 @@ public class WindowAndroid { ...@@ -129,11 +130,11 @@ public class WindowAndroid {
* @param intent The intent that needs to be showed. * @param intent The intent that needs to be showed.
* @param callback The object that will receive the results for the intent. * @param callback The object that will receive the results for the intent.
* @param errorId The ID of error string to be show if activity is paused before intent * @param errorId The ID of error string to be show if activity is paused before intent
* results. * results, or null if no message is required.
* @return A non-negative request code that could be used for finishActivity, or * @return A non-negative request code that could be used for finishActivity, or
* START_INTENT_FAILURE if failed. * START_INTENT_FAILURE if failed.
*/ */
public int showCancelableIntent(Intent intent, IntentCallback callback, int errorId) { public int showCancelableIntent(Intent intent, IntentCallback callback, Integer errorId) {
Log.d(TAG, "Can't show intent as context is not an Activity: " + intent); Log.d(TAG, "Can't show intent as context is not an Activity: " + intent);
return START_INTENT_FAILURE; return START_INTENT_FAILURE;
} }
......
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