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

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

Issue 2438103002: Add postMessage APIs to the support lib (Closed)
Patch Set: Overridden callback in CustomTabsSessionToken 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
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 169
170 /** 170 /**
171 * Creates a new session through an ICustomTabsService with the optional cal lback. This session 171 * Creates a new session through an ICustomTabsService with the optional cal lback. This session
172 * can be used to associate any related communication through the service wi th an intent and 172 * can be used to associate any related communication through the service wi th an intent and
173 * then later with a Custom Tab. The client can then send later service call s or intents to 173 * then later with a Custom Tab. The client can then send later service call s or intents to
174 * through same session-intent-Custom Tab association. 174 * through same session-intent-Custom Tab association.
175 * @param callback The callback through which the client will receive update s about the created 175 * @param callback The callback through which the client will receive update s about the created
176 * session. Can be null. 176 * session. Can be null.
177 * @return The session object that was created as a result of the transactio n. The client can 177 * @return The session object that was created as a result of the transactio n. The client can
178 * use this to relay {@link CustomTabsSession#mayLaunchUrl(Uri, Bund le, List)} calls. 178 * use this to relay session specific calls.
179 * Null on error. 179 * Null on error.
180 */ 180 */
181 public CustomTabsSession newSession(final CustomTabsCallback callback) { 181 public CustomTabsSession newSession(final CustomTabsCallback callback) {
182 ICustomTabsCallback.Stub wrapper = new ICustomTabsCallback.Stub() { 182 ICustomTabsCallback.Stub wrapper = new ICustomTabsCallback.Stub() {
Benoit L 2016/11/07 17:50:38 What about a proxy class: /** Posts the callb
Yusuf 2016/11/07 18:56:41 Done.
183 @Override 183 @Override
184 public void onNavigationEvent(int navigationEvent, Bundle extras) { 184 public void onNavigationEvent(int navigationEvent, Bundle extras) {
185 if (callback != null) callback.onNavigationEvent(navigationEvent , extras); 185 if (callback != null) callback.onNavigationEvent(navigationEvent , extras);
186 } 186 }
187 187
188 @Override 188 @Override
189 public void onMessageChannelReady(Uri origin, Bundle extras) {
190 if (callback != null) callback.onMessageChannelReady(origin, ext ras);
191 }
192
193 @Override
194 public void onPostMessage(String message, Bundle extras) {
195 if (callback != null) callback.onPostMessage(message, extras);
196 }
197
198 @Override
189 public void extraCallback(String callbackName, Bundle args) throws R emoteException { 199 public void extraCallback(String callbackName, Bundle args) throws R emoteException {
190 if (callback != null) callback.extraCallback(callbackName, args) ; 200 if (callback != null) callback.extraCallback(callbackName, args) ;
191 } 201 }
192 }; 202 };
193 203
194 try { 204 try {
195 if (!mService.newSession(wrapper)) return null; 205 if (!mService.newSession(wrapper)) return null;
196 } catch (RemoteException e) { 206 } catch (RemoteException e) {
197 return null; 207 return null;
198 } 208 }
199 return new CustomTabsSession(mService, wrapper, mServiceComponentName); 209 return new CustomTabsSession(mService, wrapper, mServiceComponentName);
200 } 210 }
201 211
202 public Bundle extraCommand(String commandName, Bundle args) { 212 public Bundle extraCommand(String commandName, Bundle args) {
203 try { 213 try {
204 return mService.extraCommand(commandName, args); 214 return mService.extraCommand(commandName, args);
205 } catch (RemoteException e) { 215 } catch (RemoteException e) {
206 return null; 216 return null;
207 } 217 }
208 } 218 }
209 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698