Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkModel.java

Issue 1694093003: Rename EnhancedBookmarks to Bookmarks, part 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rewrapped a few lines Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.bookmarks; 5 package org.chromium.chrome.browser.bookmarks;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 8
9 import org.chromium.base.ObserverList; 9 import org.chromium.base.ObserverList;
10 import org.chromium.base.VisibleForTesting; 10 import org.chromium.base.VisibleForTesting;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 * Called when the bookmark has been added. 49 * Called when the bookmark has been added.
50 * @param bookmarkId ID of the bookmark that has been added. 50 * @param bookmarkId ID of the bookmark that has been added.
51 * @param result of saving an offline copy of the bookmarked page. 51 * @param result of saving an offline copy of the bookmarked page.
52 */ 52 */
53 void onBookmarkAdded(BookmarkId bookmarkId, int saveResult); 53 void onBookmarkAdded(BookmarkId bookmarkId, int saveResult);
54 } 54 }
55 55
56 /** 56 /**
57 * Observer that listens to delete event. This interface is used by undo con trollers to know 57 * Observer that listens to delete event. This interface is used by undo con trollers to know
58 * which bookmarks were deleted. Note this observer only listens to events t hat go through 58 * which bookmarks were deleted. Note this observer only listens to events t hat go through
59 * enhanced bookmark model. 59 * bookmark model.
60 */ 60 */
61 public interface BookmarkDeleteObserver { 61 public interface BookmarkDeleteObserver {
62 62
63 /** 63 /**
64 * Callback being triggered immediately before bookmarks are deleted. 64 * Callback being triggered immediately before bookmarks are deleted.
65 * @param titles All titles of the bookmarks to be deleted. 65 * @param titles All titles of the bookmarks to be deleted.
66 * @param isUndoable Whether the deletion is undoable. 66 * @param isUndoable Whether the deletion is undoable.
67 */ 67 */
68 void onDeleteBookmarks(String[] titles, boolean isUndoable); 68 void onDeleteBookmarks(String[] titles, boolean isUndoable);
69 } 69 }
(...skipping 12 matching lines...) Expand all
82 } 82 }
83 } 83 }
84 }; 84 };
85 85
86 private ObserverList<BookmarkDeleteObserver> mDeleteObservers = new Observer List<>(); 86 private ObserverList<BookmarkDeleteObserver> mDeleteObservers = new Observer List<>();
87 private OfflinePageBridge mOfflinePageBridge; 87 private OfflinePageBridge mOfflinePageBridge;
88 private boolean mIsOfflinePageModelLoaded; 88 private boolean mIsOfflinePageModelLoaded;
89 private OfflinePageModelObserver mOfflinePageModelObserver; 89 private OfflinePageModelObserver mOfflinePageModelObserver;
90 90
91 /** 91 /**
92 * Initialize enhanced bookmark model for last used non-incognito profile. 92 * Initialize bookmark model for last used non-incognito profile.
93 */ 93 */
94 public BookmarkModel() { 94 public BookmarkModel() {
95 this(Profile.getLastUsedProfile().getOriginalProfile()); 95 this(Profile.getLastUsedProfile().getOriginalProfile());
96 } 96 }
97 97
98 @VisibleForTesting 98 @VisibleForTesting
99 public BookmarkModel(Profile profile) { 99 public BookmarkModel(Profile profile) {
100 super(profile); 100 super(profile);
101 101
102 // Note: we check if mOfflinePageBridge is null after this to determine if offline pages 102 // Note: we check if mOfflinePageBridge is null after this to determine if offline pages
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 super.destroy(); 135 super.destroy();
136 } 136 }
137 137
138 @Override 138 @Override
139 public boolean isBookmarkModelLoaded() { 139 public boolean isBookmarkModelLoaded() {
140 return super.isBookmarkModelLoaded() 140 return super.isBookmarkModelLoaded()
141 && (mOfflinePageBridge == null || mIsOfflinePageModelLoaded); 141 && (mOfflinePageBridge == null || mIsOfflinePageModelLoaded);
142 } 142 }
143 143
144 /** 144 /**
145 * Add an observer that listens to delete events that go through enhanced bo okmark model. 145 * Add an observer that listens to delete events that go through bookmark mo del.
Ian Wen 2016/02/16 22:15:43 the bookmark model?
newt (away) 2016/02/16 23:49:50 Done.
146 * @param observer The observer to add. 146 * @param observer The observer to add.
147 */ 147 */
148 public void addDeleteObserver(BookmarkDeleteObserver observer) { 148 public void addDeleteObserver(BookmarkDeleteObserver observer) {
149 mDeleteObservers.addObserver(observer); 149 mDeleteObservers.addObserver(observer);
150 } 150 }
151 151
152 /** 152 /**
153 * Remove the observer from listening to bookmark deleting events. 153 * Remove the observer from listening to bookmark deleting events.
154 * @param observer The observer to remove. 154 * @param observer The observer to remove.
155 */ 155 */
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 * @param index The position where the bookmark will be placed in parent fol der 208 * @param index The position where the bookmark will be placed in parent fol der
209 * @param title Title of the new bookmark. 209 * @param title Title of the new bookmark.
210 * @param url Url of the new bookmark 210 * @param url Url of the new bookmark
211 * @param webContents A {@link WebContents} object for saving the offline co py. If null, the 211 * @param webContents A {@link WebContents} object for saving the offline co py. If null, the
212 * saving should be skipped. 212 * saving should be skipped.
213 * @param callback The callback to be invoked when the bookmark is added. 213 * @param callback The callback to be invoked when the bookmark is added.
214 */ 214 */
215 public void addBookmarkAsync(BookmarkId parent, int index, String title, Str ing url, 215 public void addBookmarkAsync(BookmarkId parent, int index, String title, Str ing url,
216 WebContents webContents, final AddBookmarkCallb ack callback) { 216 WebContents webContents, final AddBookmarkCallb ack callback) {
217 url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url); 217 url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
218 final BookmarkId enhancedId = addBookmark(parent, index, title, url); 218 final BookmarkId bookmarkId = addBookmark(parent, index, title, url);
219 219
220 // If there is no need to save offline page, return now. 220 // If there is no need to save offline page, return now.
221 if (mOfflinePageBridge == null || webContents == null) { 221 if (mOfflinePageBridge == null || webContents == null) {
222 callback.onBookmarkAdded(enhancedId, AddBookmarkCallback.SKIPPED); 222 callback.onBookmarkAdded(bookmarkId, AddBookmarkCallback.SKIPPED);
223 return; 223 return;
224 } 224 }
225 225
226 saveOfflinePage(enhancedId, webContents, callback); 226 saveOfflinePage(bookmarkId, webContents, callback);
227 } 227 }
228 228
229 /** 229 /**
230 * Save an offline copy for the bookmarked page asynchronously. 230 * Save an offline copy for the bookmarked page asynchronously.
231 * 231 *
232 * @param bookmarkId The ID of the page to save an offline copy. 232 * @param bookmarkId The ID of the page to save an offline copy.
233 * @param webContents A {@link WebContents} object. 233 * @param webContents A {@link WebContents} object.
234 * @param callback The callback to be invoked when the offline copy is saved. 234 * @param callback The callback to be invoked when the offline copy is saved.
235 */ 235 */
236 public void saveOfflinePage(final BookmarkId bookmarkId, WebContents webCont ents, 236 public void saveOfflinePage(final BookmarkId bookmarkId, WebContents webCont ents,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return bookmarkIds; 313 return bookmarkIds;
314 } 314 }
315 315
316 /** 316 /**
317 * @return Offline page bridge. 317 * @return Offline page bridge.
318 */ 318 */
319 public OfflinePageBridge getOfflinePageBridge() { 319 public OfflinePageBridge getOfflinePageBridge() {
320 return mOfflinePageBridge; 320 return mOfflinePageBridge;
321 } 321 }
322 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698