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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java

Issue 2307733003: WebShare: Fixed the API occasionally breaking on a particular page. (Closed)
Patch Set: Begrudgingly use American spelling for 'canceled'. Created 4 years, 3 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webshare/ShareServiceImpl.java » ('j') | 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/share/ShareHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java
index 2ede3ccfebdad6c423071c2dd654f84c5033723a..75df69b1dfcbb7068edc10f3064616d316273bbd 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java
@@ -100,6 +100,13 @@ public class ShareHelper {
* Note that if the user cancels the share dialog, this callback is never called.
*/
public void onTargetChosen(ComponentName chosenComponent);
+
+ /**
+ * Called when the user cancels the share dialog.
+ *
+ * Guaranteed that either this, or onTargetChosen (but not both) will be called, eventually.
+ */
+ public void onCancel();
}
/**
@@ -137,6 +144,11 @@ public class ShareHelper {
Context context = activity.getApplicationContext();
if (sLastRegisteredReceiver != null) {
context.unregisterReceiver(sLastRegisteredReceiver);
+ // Must cancel the callback (to satisfy guarantee that exactly one method of
+ // TargetChosenCallback is called).
+ // TODO(mgiuca): This should be called immediately upon cancelling the chooser,
+ // not just when the next share takes place (https://crbug.com/636274).
+ sLastRegisteredReceiver.cancel();
}
sLastRegisteredReceiver = new TargetChosenReceiver(saveLastUsed, callback);
context.registerReceiver(
@@ -174,6 +186,12 @@ public class ShareHelper {
setLastShareComponentName(target);
}
}
+
+ private void cancel() {
+ if (mCallback != null) {
+ mCallback.onCancel();
+ }
+ }
}
/**
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/webshare/ShareServiceImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698