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,7 +81,9 @@ class CustomTabBottomBarDelegate implements FullscreenListener { ...@@ -80,7 +81,9 @@ 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(); List<CustomButtonParams> items = mDataProvider.getCustomButtonsOnBottombar();
if (items.isEmpty()) return; if (items.isEmpty()) return;
LinearLayout layout = new LinearLayout(mActivity); LinearLayout layout = new LinearLayout(mActivity);
...@@ -91,19 +94,13 @@ class CustomTabBottomBarDelegate implements FullscreenListener { ...@@ -91,19 +94,13 @@ class CustomTabBottomBarDelegate implements FullscreenListener {
final PendingIntent pendingIntent = params.getPendingIntent(); final PendingIntent pendingIntent = params.getPendingIntent();
OnClickListener clickListener = null; OnClickListener clickListener = null;
if (pendingIntent != null) { if (pendingIntent != null) {
clickListener = new OnClickListener() { clickListener = v -> sendPendingIntentWithUrl(pendingIntent, null, mActivity);
@Override
public void onClick(View v) {
sendPendingIntentWithUrl(pendingIntent, null, mActivity);
}
};
} }
layout.addView( layout.addView(
params.buildBottomBarButton(mActivity, getBottomBarView(), clickListener)); params.buildBottomBarButton(mActivity, getBottomBarView(), clickListener));
} }
getBottomBarView().addView(layout); getBottomBarView().addView(layout);
} }
}
/** /**
* Updates the custom buttons on bottom bar area. * Updates the custom buttons on bottom bar area.
...@@ -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