Chromium Code Reviews| Index: customtabs/src/android/support/customtabs/CustomTabsService.java |
| diff --git a/customtabs/src/android/support/customtabs/CustomTabsService.java b/customtabs/src/android/support/customtabs/CustomTabsService.java |
| index 25697c5e3bdb35c3e411e670ee4456a16a5dcd46..b7b2f6d30e995283be25513033e810956520ed06 100644 |
| --- a/customtabs/src/android/support/customtabs/CustomTabsService.java |
| +++ b/customtabs/src/android/support/customtabs/CustomTabsService.java |
| @@ -50,6 +50,11 @@ import java.util.NoSuchElementException; |
| public static final String KEY_URL = |
| "android.support.customtabs.otherurls.URL"; |
| + public static final int RESULT_SUCCESS = 1; |
|
Benoit L
2016/11/07 17:50:38
nit: These error codes are a bit weird.
In the UN
Yusuf
2016/11/07 18:56:42
Done.
|
| + public static final int RESULT_FAILURE_DISALLOWED = 0; |
|
Benoit L
2016/11/07 17:50:38
Can you use @IntDef here?
https://developer.androi
Yusuf
2016/11/07 18:56:42
Done.
|
| + public static final int RESULT_FAILURE_REMOTE_ERROR = -1; |
| + public static final int RESULT_FAILURE_MESSAGING_ERROR = -2; |
| + |
| private final Map<IBinder, DeathRecipient> mDeathRecipientMap = new ArrayMap<>(); |
| private ICustomTabsService.Stub mBinder = new ICustomTabsService.Stub() { |
| @@ -96,6 +101,18 @@ import java.util.NoSuchElementException; |
| return CustomTabsService.this.updateVisuals( |
| new CustomTabsSessionToken(callback), bundle); |
| } |
| + |
| + @Override |
| + public boolean validatePostMessageOrigin(ICustomTabsCallback callback) { |
| + return CustomTabsService.this.validatePostMessageOrigin( |
| + new CustomTabsSessionToken(callback)); |
| + } |
| + |
| + @Override |
| + public int postMessage(ICustomTabsCallback callback, String message, Bundle extras) { |
| + return CustomTabsService.this.postMessage( |
| + new CustomTabsSessionToken(callback), message, extras); |
| + } |
| }; |
| @Override |
| @@ -193,4 +210,31 @@ import java.util.NoSuchElementException; |
| */ |
| protected abstract boolean updateVisuals(CustomTabsSessionToken sessionToken, |
| Bundle bundle); |
| + |
| + /** |
| + * Sends a request to the implementation for validate and assign a postMessage origin for the |
|
Benoit L
2016/11/07 17:50:38
nit: s/for/to/ ?
Yusuf
2016/11/07 18:56:41
Done.
|
| + * related {@link CustomTabsSession}. |
| + * |
| + * <p>This also acts a trigger to setup a postMessage communication channel. |
| + * |
| + * @param sessionToken The unique identifier for the session. Can not be null. |
| + * @return Whether the implementation accepted the validation request. Note that returning true |
| + * here doesn't mean an origin has already been assigned as the validation can be |
|
Benoit L
2016/11/07 17:50:38
nit: s/can be/is/
Yusuf
2016/11/07 18:56:41
Done.
|
| + * asynchronous. |
| + */ |
| + protected abstract boolean validatePostMessageOrigin(CustomTabsSessionToken sessionToken); |
| + |
| + /** |
| + * Sends a postMessage request using the origin that has been validated and communicated via |
| + * {@link CustomTabsCallback#onMessageChannelReady(String, Bundle)}. Returns false when called |
| + * without a preceding |
| + * {@link CustomTabsService#validatePostMessageOrigin(CustomTabsSessionToken)}. |
| + * |
| + * @param sessionToken The unique identifier for the session. Can not be null. |
| + * @param message The message that is being sent. |
| + * @param extras Reserved for future use. |
| + * @return An integer constant about the postMessage request result. |
| + */ |
| + protected abstract int postMessage( |
|
Benoit L
2016/11/07 17:50:38
Ditto, @IntDef and friends would make the return "
Yusuf
2016/11/07 18:56:41
Done.
|
| + CustomTabsSessionToken sessionToken, String message, Bundle extras); |
| } |