| 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;
|
| }
|
|
|
| /**
|
|
|