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

Commit 2f936d9

Browse files
committed
[Offline pages] Filter out offline pages without matching bookmarks in 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}
1 parent 30cf9cc commit 2f936d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarksModel.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Calendar;
2828
import java.util.Collections;
2929
import java.util.Comparator;
30+
import java.util.HashSet;
3031
import java.util.List;
3132
import java.util.concurrent.TimeUnit;
3233

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

328329
List<OfflinePageItem> offlinePages = mOfflinePageBridge.getAllPages();
329330
Collections.sort(offlinePages, sOfflinePageComparator);
331+
332+
// We are going to filter out all of the offline pages without a matching bookmark.
333+
// http://crbug.com/537806
334+
HashSet<BookmarkId> existingBookmarks =
335+
new HashSet<BookmarkId>(getAllBookmarkIDsOrderedByCreationDate());
336+
330337
List<BookmarkId> bookmarkIds = new ArrayList<BookmarkId>();
331338
for (OfflinePageItem offlinePage : offlinePages) {
332-
bookmarkIds.add(offlinePage.getBookmarkId());
339+
if (existingBookmarks.contains(offlinePage.getBookmarkId())) {
340+
bookmarkIds.add(offlinePage.getBookmarkId());
341+
}
333342
}
334343
return bookmarkIds;
335344
}

0 commit comments

Comments
 (0)