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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java

Issue 1291083004: [Custom Tabs]Add API for updating action button in service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make updateToolbarUrl return boolean Created 5 years, 4 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
Index: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
index 045aef059bd1ec91fbbf1d01033d8bd8ceddde3f..cae75f069da2037d2448286e883d4f5abacda9ad 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java
@@ -12,6 +12,7 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.graphics.Bitmap;
import android.graphics.Point;
import android.net.ConnectivityManager;
import android.net.Uri;
@@ -23,6 +24,8 @@ import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.support.customtabs.CustomTabsCallback;
Yusuf 2015/08/21 00:07:37 why is this one needed?
Ian Wen 2015/08/21 17:01:24 Removed.
+import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.ICustomTabsService;
import android.text.TextUtils;
@@ -44,6 +47,7 @@ import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.init.ChromeBrowserInitializer;
import org.chromium.chrome.browser.prerender.ExternalPrerenderHandler;
import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.content.browser.ChildProcessLauncher;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.common.Referrer;
@@ -320,6 +324,30 @@ public class CustomTabsConnection extends ICustomTabsService.Stub {
return null;
}
+ @Override
+ public boolean updateToolbarUI(final ICustomTabsCallback callback, Bundle bundle) {
+ final Bundle actionButtonBundle = IntentUtils.safeGetBundle(bundle,
+ CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE);
+ if (actionButtonBundle == null) return false;
+
+ final Bitmap bitmap = ActionButtonParams.tryParseBitmapFromBundle(mApplication,
Benoit L 2015/08/21 11:31:15 Can't you do: final ActionButtonParams actionButt
Ian Wen 2015/08/21 17:01:24 The reason that I cannot construct an actionButton
+ actionButtonBundle);
+ final String description = ActionButtonParams
+ .tryParseDescriptionFromBundle(actionButtonBundle);
+ if (bitmap == null || description == null) return false;
+
+ final boolean[] didSucceed = {true};
Yusuf 2015/08/21 00:07:37 use a Callable<Boolean> instead of this.
Benoit L 2015/08/21 11:31:15 Better suggestion than mine, indeed. Sorry about t
Ian Wen 2015/08/21 17:01:24 Done.
+
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ didSucceed[0] = CustomTabActivity.updateActionButton(callback.asBinder(), bitmap,
+ description);
+ }
+ });
+ return didSucceed[0];
+ }
+
/**
* Registers a launch of a |url| for a given |session|.
*

Powered by Google App Engine
This is Rietveld 408576698