Skip to content

Commit

Permalink
[Downloads location] Temp fix for surplus offline pages notifications.
Browse files Browse the repository at this point in the history
There were surplus offline pages notifications (unintended prefetch
notifications and double offline pages notifications) because of a
doubled pathway when OfflineContentAggregatorNotificationBridgeUi is
activated. Temporarily disable OCANBUi for offline pages until a more
long-term fix is in place that can filter out notifications.

Bug: 831083,832282
Change-Id: I49095de6cb9138c2081147342fa76aab9fc8c857
Reviewed-on: https://chromium-review.googlesource.com/1011227
Commit-Queue: Joy Ming <jming@chromium.org>
Reviewed-by: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550428}
  • Loading branch information
Joy Ming authored and Commit Bot committed Apr 13, 2018
1 parent b8e4792 commit 9ef2aa8
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.chromium.chrome.browser.download.DownloadNotifier;
import org.chromium.chrome.browser.download.DownloadServiceDelegate;
import org.chromium.components.offline_items_collection.ContentId;
import org.chromium.components.offline_items_collection.LegacyHelpers;
import org.chromium.components.offline_items_collection.OfflineContentProvider;
import org.chromium.components.offline_items_collection.OfflineItem;
import org.chromium.components.offline_items_collection.OfflineItemState;
Expand Down Expand Up @@ -147,6 +148,8 @@ private void getVisualsAndUpdateItem(OfflineItem item) {
}

private void pushItemToUi(OfflineItem item, OfflineItemVisuals visuals) {
if (!shouldShowNotification(item)) return;

DownloadInfo info = DownloadInfo.fromOfflineItem(item, visuals);
switch (item.state) {
case OfflineItemState.IN_PROGRESS:
Expand Down Expand Up @@ -220,4 +223,10 @@ private boolean shouldCacheVisuals(OfflineItem item) {
return false;
}
}

private boolean shouldShowNotification(OfflineItem item) {
// Temporarily return immediately to prevent unnecessary notifications for offline pages
// until https://crbug.com/831083 and https://crbug.com/832282 are fixed.
return !item.isTransient && !LegacyHelpers.isLegacyOfflinePage(item.id);
}
}

0 comments on commit 9ef2aa8

Please sign in to comment.