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

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: cr.->cr_ Created 5 years, 3 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 a3cd9d92308fd0a280050a98af7381d9ce560f98..8fc3825cd5c841492f018a5497761dd9f94ce4bd 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,7 @@ import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.ICustomTabsService;
import android.text.TextUtils;
@@ -45,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.LoadUrlParams;
import org.chromium.content_public.browser.WebContents;
@@ -58,6 +61,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -374,6 +379,31 @@ public class CustomTabsConnection extends ICustomTabsService.Stub {
return result;
}
+ @Override
+ public boolean updateVisuals(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,
+ actionButtonBundle);
+ final String description = ActionButtonParams
+ .tryParseDescriptionFromBundle(actionButtonBundle);
+ if (bitmap == null || description == null) return false;
+
+ try {
+ return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return CustomTabActivity.updateActionButton(callback.asBinder(), bitmap,
+ description);
+ }
+ });
+ } catch (ExecutionException e) {
+ return false;
+ }
+ }
+
/**
* Registers a launch of a |url| for a given |session|.
*

Powered by Google App Engine
This is Rietveld 408576698