Commit 02ae8f5f authored by Bernhard Bauer's avatar Bernhard Bauer Committed by Commit Bot

Catch Resources.NotFoundException when inflating Remote Views for Custom Tab bottom toolbar.

Bug: 827326
Change-Id: Ifdbb8ded6b7d3f7571e40d24178a840c304eabe5
Reviewed-on: https://chromium-review.googlesource.com/992034Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Commit-Queue: Bernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547682}
parent 718e2ab2
...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.customtabs; ...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.customtabs;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException; import android.app.PendingIntent.CanceledException;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsIntent; import android.support.customtabs.CustomTabsIntent;
...@@ -80,29 +81,25 @@ class CustomTabBottomBarDelegate implements FullscreenListener { ...@@ -80,29 +81,25 @@ class CustomTabBottomBarDelegate implements FullscreenListener {
mClickableIDs = mDataProvider.getClickableViewIDs(); mClickableIDs = mDataProvider.getClickableViewIDs();
mClickPendingIntent = mDataProvider.getRemoteViewsPendingIntent(); mClickPendingIntent = mDataProvider.getRemoteViewsPendingIntent();
showRemoteViews(remoteViews); showRemoteViews(remoteViews);
} else { return;
List<CustomButtonParams> items = mDataProvider.getCustomButtonsOnBottombar(); }
if (items.isEmpty()) return;
LinearLayout layout = new LinearLayout(mActivity); List<CustomButtonParams> items = mDataProvider.getCustomButtonsOnBottombar();
layout.setId(R.id.custom_tab_bottom_bar_wrapper); if (items.isEmpty()) return;
layout.setBackgroundColor(mDataProvider.getBottomBarColor()); LinearLayout layout = new LinearLayout(mActivity);
for (CustomButtonParams params : items) { layout.setId(R.id.custom_tab_bottom_bar_wrapper);
if (params.showOnToolbar()) continue; layout.setBackgroundColor(mDataProvider.getBottomBarColor());
final PendingIntent pendingIntent = params.getPendingIntent(); for (CustomButtonParams params : items) {
OnClickListener clickListener = null; if (params.showOnToolbar()) continue;
if (pendingIntent != null) { final PendingIntent pendingIntent = params.getPendingIntent();
clickListener = new OnClickListener() { OnClickListener clickListener = null;
@Override if (pendingIntent != null) {
public void onClick(View v) { clickListener = v -> sendPendingIntentWithUrl(pendingIntent, null, mActivity);
sendPendingIntentWithUrl(pendingIntent, null, mActivity);
}
};
}
layout.addView(
params.buildBottomBarButton(mActivity, getBottomBarView(), clickListener));
} }
getBottomBarView().addView(layout); layout.addView(
params.buildBottomBarButton(mActivity, getBottomBarView(), clickListener));
} }
getBottomBarView().addView(layout);
} }
/** /**
...@@ -230,6 +227,9 @@ class CustomTabBottomBarDelegate implements FullscreenListener { ...@@ -230,6 +227,9 @@ class CustomTabBottomBarDelegate implements FullscreenListener {
} catch (RemoteViews.ActionException e) { } catch (RemoteViews.ActionException e) {
Log.e(TAG, "Failed to inflate the RemoteViews", e); Log.e(TAG, "Failed to inflate the RemoteViews", e);
return false; return false;
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Failed to inflate the RemoteViews", e);
return false;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment