Commit 8ca32105 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

[Android] Make getBundleForMenuItem not return null.

This change of function contract is the by-product of a
discussion on fixing issue 1130909, where we decided to
do a bit of additional cleanup as well.

Bug: 1130909
Change-Id: I28d0e244ead44b8f6525bf1e0d86633256d06281
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2456786Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarGang Wu <gangwu@chromium.org>
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816119}
parent 0d36df6f
......@@ -658,12 +658,11 @@ public class AppMenuPropertiesDelegateImpl implements AppMenuPropertiesDelegate
@Override
public Bundle getBundleForMenuItem(MenuItem item) {
Bundle bundle = new Bundle();
if (item.getItemId() == R.id.add_to_homescreen_id) {
Bundle payload = new Bundle();
payload.putInt(AppBannerManager.MENU_TITLE_KEY, mAddAppTitleShown);
return payload;
bundle.putInt(AppBannerManager.MENU_TITLE_KEY, mAddAppTitleShown);
}
return null;
return bundle;
}
/**
......
......@@ -240,16 +240,13 @@ public class CustomTabAppMenuPropertiesDelegate extends AppMenuPropertiesDelegat
}
@Override
public @Nullable Bundle getBundleForMenuItem(MenuItem item) {
public Bundle getBundleForMenuItem(MenuItem item) {
Bundle itemBundle = super.getBundleForMenuItem(item);
if (!mItemToIndexMap.containsKey(item)) {
return itemBundle;
}
if (itemBundle == null) {
itemBundle = new Bundle();
}
itemBundle.putInt(CUSTOM_MENU_ITEM_ID_KEY, mItemToIndexMap.get(item).intValue());
return itemBundle;
}
......
......@@ -44,12 +44,11 @@ public interface AppMenuPropertiesDelegate {
void prepareMenu(Menu menu, AppMenuHandler handler);
/**
* Gets an optional bundle of extra data associated with the provided MenuItem.
* Gets a bundle of (optional) extra data associated with the provided MenuItem.
*
* @param item The {@link MenuItem} for which to return the Bundle.
* @return A {@link Bundle} for the provided MenuItem containing extra data, or null.
* @return A {@link Bundle} for the provided MenuItem containing extra data, if any.
*/
@Nullable
Bundle getBundleForMenuItem(MenuItem item);
/**
......
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