Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[Offline pages] Filter out offline pages without matching bookmarks i…
Browse files Browse the repository at this point in the history
…n UI

Making sure that when offline page filter is applied, all of the
bookmark IDs are checked against the bookmark model, before being
used by UI.

BUG=537806

Review URL: https://codereview.chromium.org/1470403002

Cr-Commit-Position: refs/heads/master@{#362185}
(cherry picked from commit f2d8e24)

Review URL: https://codereview.chromium.org/1486753005 .

Cr-Commit-Position: refs/branch-heads/2564@{#186}
Cr-Branched-From: 1283eca-refs/heads/master@{#359700}
  • Loading branch information
fgorski committed Dec 1, 2015
1 parent 30cf9cc commit 2f936d9
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -327,9 +328,17 @@ public List<BookmarkId> getBookmarkIDsByFilter(EnhancedBookmarkFilter filter) {

List<OfflinePageItem> offlinePages = mOfflinePageBridge.getAllPages();
Collections.sort(offlinePages, sOfflinePageComparator);

// We are going to filter out all of the offline pages without a matching bookmark.
// http://crbug.com/537806
HashSet<BookmarkId> existingBookmarks =
new HashSet<BookmarkId>(getAllBookmarkIDsOrderedByCreationDate());

List<BookmarkId> bookmarkIds = new ArrayList<BookmarkId>();
for (OfflinePageItem offlinePage : offlinePages) {
bookmarkIds.add(offlinePage.getBookmarkId());
if (existingBookmarks.contains(offlinePage.getBookmarkId())) {
bookmarkIds.add(offlinePage.getBookmarkId());
}
}
return bookmarkIds;
}
Expand Down

0 comments on commit 2f936d9

Please sign in to comment.