Skip to content

Commit

Permalink
[PriceTracking] Get subscriptions manager on menu item select
Browse files Browse the repository at this point in the history
Now we get the subscription manager on Chrome activity initialization
and use it on menu item select. If user enables MSBB or signs in after
Chrome starts and then goes to a PDP, the menu item is visible but no
response on click because subscription manager is null. We should get
the manager at that time instead to fix it.

(cherry picked from commit ab65547)

Bug: 1319271
Change-Id: I6427b7017a8f8643332742e472d754fee4498d2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3635145
Auto-Submit: Zhiyuan Cai <zhiyuancai@chromium.org>
Commit-Queue: David Trainor <dtrainor@chromium.org>
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1003859}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3652599
Owners-Override: Krishna Govind <govind@chromium.org>
Commit-Queue: Zhiyuan Cai <zhiyuancai@chromium.org>
Reviewed-by: Krishna Govind <govind@chromium.org>
Commit-Queue: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/5060@{#60}
Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
  • Loading branch information
Zhiyuan Cai authored and Chromium LUCI CQ committed May 17, 2022
1 parent 34f09c4 commit 2aa3e11
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
// {@link onPictureInPictureModeChanged} from the platform. This might disagree with the value
// returned by {@link isInPictureInPictureMode}.
private boolean mLastPictureInPictureModeForTesting;
private SubscriptionsManager mSubscriptionsManager;

protected BackPressManager mBackPressManager = new BackPressManager();
private TextBubbleBackPressHandler mTextBubbleBackPressHandler;
Expand Down Expand Up @@ -1735,12 +1734,6 @@ private void maybeOnScreenSizeChange() {
};
display.addObserver(mDisplayAndroidObserver);

CommerceSubscriptionsServiceFactory factory = new CommerceSubscriptionsServiceFactory();

if (ShoppingFeatures.isShoppingListEnabled()) {
mSubscriptionsManager = factory.getForLastUsedProfile().getSubscriptionsManager();
}

// Make sure the user is reporting into one of the feed spinner groups, so that we can
// analyze daily power impact for a typical Chrome user. The flag only has an effect if the
// spinner is shown, but our earlier UMA analysis shows that it may have a side-effect on
Expand Down Expand Up @@ -2569,7 +2562,13 @@ public boolean onMenuOrKeyboardAction(int id, boolean fromMenu) {
List<BookmarkId> bookmarkIds =
PowerBookmarkUtils.getBookmarkIdsWithSharedClusterIdForTab(
currentTab, mBookmarkBridgeSupplier.get());
PowerBookmarkUtils.setPriceTrackingEnabledWithSnackbars(mSubscriptionsManager,
SubscriptionsManager subscriptionsManager = null;
if (ShoppingFeatures.isShoppingListEnabled()) {
subscriptionsManager = new CommerceSubscriptionsServiceFactory()
.getForLastUsedProfile()
.getSubscriptionsManager();
}
PowerBookmarkUtils.setPriceTrackingEnabledWithSnackbars(subscriptionsManager,
mBookmarkBridgeSupplier.get(), bookmarkIds,
/*enabled=*/false, mSnackbarManager, getResources());
RecordUserAction.record("MobileMenuDisablePriceTracking");
Expand Down

0 comments on commit 2aa3e11

Please sign in to comment.