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

Side by Side Diff: customtabs/src/android/support/customtabs/CustomTabsSessionToken.java

Issue 2438103002: Add postMessage APIs to the support lib (Closed)
Patch Set: lizeb@ comments Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2015 The Android Open Source Project 2 * Copyright (C) 2015 The Android Open Source Project
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 * http://www.apache.org/licenses/LICENSE-2.0 8 * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 package android.support.customtabs; 17 package android.support.customtabs;
18 18
19 import android.content.Intent; 19 import android.content.Intent;
20 import android.net.Uri;
20 import android.os.Bundle; 21 import android.os.Bundle;
21 import android.os.IBinder; 22 import android.os.IBinder;
22 import android.os.RemoteException; 23 import android.os.RemoteException;
23 import android.support.v4.app.BundleCompat; 24 import android.support.v4.app.BundleCompat;
24 import android.util.Log; 25 import android.util.Log;
25 26
26 /** 27 /**
27 * Wrapper class that can be used as a unique identifier for a session. Also con tains an accessor 28 * Wrapper class that can be used as a unique identifier for a session. Also con tains an accessor
28 * for the {@link CustomTabsCallback} for the session if there was any. 29 * for the {@link CustomTabsCallback} for the session if there was any.
29 */ 30 */
30 public class CustomTabsSessionToken { 31 public class CustomTabsSessionToken {
31 private static final String TAG = "CustomTabsSessionToken"; 32 private static final String TAG = "CustomTabsSessionToken";
32 private final ICustomTabsCallback mCallbackBinder; 33 private final ICustomTabsCallback mCallbackBinder;
33 private final CustomTabsCallback mCallback; 34 private final CustomTabsCallback mCallback;
34 35
35 /* package */ static class DummyCallback extends ICustomTabsCallback.Stub { 36 /* package */ static class DummyCallback extends ICustomTabsCallback.Stub {
36 @Override 37 @Override
37 public void onNavigationEvent(int navigationEvent, Bundle extras) {} 38 public void onNavigationEvent(int navigationEvent, Bundle extras) {}
38 39
39 @Override 40 @Override
41 public void onMessageChannelReady(Uri origin, Bundle extras) {}
42
43 @Override
44 public void onPostMessage(String message, Bundle extras) {}
45
46 @Override
40 public void extraCallback(String callbackName, Bundle args) {} 47 public void extraCallback(String callbackName, Bundle args) {}
41 48
42 @Override 49 @Override
43 public IBinder asBinder() { 50 public IBinder asBinder() {
44 return this; 51 return this;
45 } 52 }
46 } 53 }
47 54
48 /** 55 /**
49 * Obtain a {@link CustomTabsSessionToken} from an intent. See {@link Custom TabsIntent.Builder} 56 * Obtain a {@link CustomTabsSessionToken} from an intent. See {@link Custom TabsIntent.Builder}
(...skipping 27 matching lines...) Expand all
77 @Override 84 @Override
78 public void onNavigationEvent(int navigationEvent, Bundle extras) { 85 public void onNavigationEvent(int navigationEvent, Bundle extras) {
79 try { 86 try {
80 mCallbackBinder.onNavigationEvent(navigationEvent, extras); 87 mCallbackBinder.onNavigationEvent(navigationEvent, extras);
81 } catch (RemoteException e) { 88 } catch (RemoteException e) {
82 Log.e(TAG, "RemoteException during ICustomTabsCallback trans action"); 89 Log.e(TAG, "RemoteException during ICustomTabsCallback trans action");
83 } 90 }
84 } 91 }
85 92
86 @Override 93 @Override
94 public void onMessageChannelReady(Uri origin, Bundle extras) {
Benoit L 2016/11/08 16:27:07 If we do need the extra synchronization for this m
95 try {
96 mCallbackBinder.onMessageChannelReady(origin, extras);
97 } catch (RemoteException e) {
98 Log.e(TAG, "RemoteException during ICustomTabsCallback trans action");
99 }
100 }
101
102 @Override
103 public synchronized void onPostMessage(String message, Bundle extras ) {
104 try {
105 mCallbackBinder.onPostMessage(message, extras);
106 } catch (RemoteException e) {
107 Log.e(TAG, "RemoteException during ICustomTabsCallback trans action");
108 }
109 }
110
111 @Override
87 public void extraCallback(String callbackName, Bundle args) { 112 public void extraCallback(String callbackName, Bundle args) {
88 try { 113 try {
89 mCallbackBinder.extraCallback(callbackName, args); 114 mCallbackBinder.extraCallback(callbackName, args);
90 } catch (RemoteException e) { 115 } catch (RemoteException e) {
91 Log.e(TAG, "RemoteException during ICustomTabsCallback trans action"); 116 Log.e(TAG, "RemoteException during ICustomTabsCallback trans action");
92 } 117 }
93 } 118 }
94 }; 119 };
95 } 120 }
96 121
(...skipping 15 matching lines...) Expand all
112 } 137 }
113 138
114 /** 139 /**
115 * @return {@link CustomTabsCallback} corresponding to this session if there was any non-null 140 * @return {@link CustomTabsCallback} corresponding to this session if there was any non-null
116 * callbacks passed by the client. 141 * callbacks passed by the client.
117 */ 142 */
118 public CustomTabsCallback getCallback() { 143 public CustomTabsCallback getCallback() {
119 return mCallback; 144 return mCallback;
120 } 145 }
121 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698