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

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

Issue 1716683002: [Custom Tabs] Allow clients to display RemoteViews on the bottom bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 5fcec5db02908136a8cb2c31b35643c0db31b090..7d0b681a3e28caaf4678651d1984c2711fd289fc 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
@@ -26,6 +26,7 @@ import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.ICustomTabsService;
import android.text.TextUtils;
import android.view.WindowManager;
+import android.widget.RemoteViews;
import org.chromium.base.CommandLine;
import org.chromium.base.FieldTrialList;
@@ -383,27 +384,50 @@ public class CustomTabsConnection extends ICustomTabsService.Stub {
@Override
public boolean updateVisuals(final ICustomTabsCallback callback, Bundle bundle) {
+ boolean updateRemoteView, updateCustomButtons = false;
+
+ final RemoteViews remoteViews = IntentUtils.safeGetParcelable(bundle,
+ CustomTabsIntent.EXTRA_SECONDARY_TOOLBAR_REMOTEVIEWS);
+ updateRemoteView = remoteViews != null;
+
final Bundle actionButtonBundle = IntentUtils.safeGetBundle(bundle,
CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE);
- if (actionButtonBundle == null) return false;
- final int id = actionButtonBundle.getInt(CustomTabsIntent.KEY_ID,
+ if (actionButtonBundle == null) updateCustomButtons = false;
+ final int id = IntentUtils.safeGetInt(actionButtonBundle, CustomTabsIntent.KEY_ID,
CustomTabsIntent.TOOLBAR_ACTION_BUTTON_ID);
final Bitmap bitmap = CustomButtonParams.parseBitmapFromBundle(actionButtonBundle);
final String description = CustomButtonParams
.parseDescriptionFromBundle(actionButtonBundle);
- if (bitmap == null || description == null) return false;
+ if (bitmap == null || description == null) updateCustomButtons = false;
- try {
- return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- return CustomTabActivity.updateCustomButton(callback.asBinder(), id, bitmap,
- description);
- }
- });
- } catch (ExecutionException e) {
- return false;
+ boolean result = true;
+ if (updateCustomButtons) {
+ try {
+ result &= ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return CustomTabActivity.updateCustomButton(callback.asBinder(), id, bitmap,
+ description);
+ }
+ });
+ } catch (ExecutionException e) {
+ result = false;
+ }
}
+ if (updateRemoteView) {
+ try {
+ result &= ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return CustomTabActivity.updateRemoteViews(callback.asBinder(),
+ remoteViews);
+ }
+ });
+ } catch (ExecutionException e) {
+ result = false;
+ }
+ }
+ return result;
}
/**

Powered by Google App Engine
This is Rietveld 408576698