Chromium Code Reviews| Index: customtabs/src/android/support/customtabs/CustomTabsClient.java |
| diff --git a/customtabs/src/android/support/customtabs/CustomTabsClient.java b/customtabs/src/android/support/customtabs/CustomTabsClient.java |
| index f743c7dde92ee3f73648368dc239181506af09e7..3abde9b7cea92bd377be9825f8e2c7e9aec0d5fb 100644 |
| --- a/customtabs/src/android/support/customtabs/CustomTabsClient.java |
| +++ b/customtabs/src/android/support/customtabs/CustomTabsClient.java |
| @@ -24,6 +24,8 @@ import android.content.pm.PackageManager; |
| import android.content.pm.ResolveInfo; |
| import android.net.Uri; |
| import android.os.Bundle; |
| +import android.os.Handler; |
| +import android.os.Looper; |
| import android.os.RemoteException; |
| import android.support.annotation.Nullable; |
| import android.text.TextUtils; |
| @@ -173,21 +175,57 @@ public class CustomTabsClient { |
| * then later with a Custom Tab. The client can then send later service calls or intents to |
| * through same session-intent-Custom Tab association. |
| * @param callback The callback through which the client will receive updates about the created |
| - * session. Can be null. |
| + * session. Can be null. All the callbacks will be received on the UI thread. |
| * @return The session object that was created as a result of the transaction. The client can |
| - * use this to relay {@link CustomTabsSession#mayLaunchUrl(Uri, Bundle, List)} calls. |
| + * use this to relay session specific calls. |
| * Null on error. |
| */ |
| public CustomTabsSession newSession(final CustomTabsCallback callback) { |
|
Benoit L
2016/11/08 16:27:06
nit: Can be deferred to a subsequent CL, but we ar
Yusuf
2016/11/08 18:59:10
Acknowledged.
|
| ICustomTabsCallback.Stub wrapper = new ICustomTabsCallback.Stub() { |
| + Handler mHandler = new Handler(Looper.getMainLooper()); |
| + |
| @Override |
| public void onNavigationEvent(int navigationEvent, Bundle extras) { |
|
Benoit L
2016/11/08 16:27:06
Does it compile?
I would expect that the parameter
Yusuf
2016/11/08 18:59:10
Caught me! No, it doesn't.
|
| - if (callback != null) callback.onNavigationEvent(navigationEvent, extras); |
| + if (callback = null) return; |
| + mHandler.post(new Runnable() { |
| + @Override |
| + public void run() { |
| + callback.onNavigationEvent(navigationEvent, extras); |
| + } |
| + }); |
| + } |
| + |
| + @Override |
| + public void onMessageChannelReady(Uri origin, Bundle extras) { |
| + if (callback = null) return; |
| + mHandler.post(new Runnable() { |
| + @Override |
| + public void run() { |
| + callback.onMessageChannelReady(origin, extras); |
| + } |
| + }); |
| + } |
| + |
| + @Override |
| + public void onPostMessage(String message, Bundle extras) { |
| + if (callback = null) return; |
| + mHandler.post(new Runnable() { |
| + @Override |
| + public void run() { |
| + callback.onPostMessage(message, extras); |
| + } |
| + }); |
| } |
| @Override |
| public void extraCallback(String callbackName, Bundle args) throws RemoteException { |
| - if (callback != null) callback.extraCallback(callbackName, args); |
| + if (callback = null) return; |
| + mHandler.post(new Runnable() { |
| + @Override |
| + public void run() { |
| + callback.extraCallback(callbackName, args); |
| + } |
| + }); |
| } |
| }; |