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

Unified Diff: ios/chrome/browser/reading_list/reading_list_model_impl.cc

Issue 2352973002: Method to call a method with an entry based on its url (Closed)
Patch Set: Add tests Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/reading_list/reading_list_model_impl.cc
diff --git a/ios/chrome/browser/reading_list/reading_list_model_impl.cc b/ios/chrome/browser/reading_list/reading_list_model_impl.cc
index 6059c11eea3c99012e2f90fc68cc9a528b38eacb..c3e068d65f0249a30a6ce1c36dbd381cdf56d260 100644
--- a/ios/chrome/browser/reading_list/reading_list_model_impl.cc
+++ b/ios/chrome/browser/reading_list/reading_list_model_impl.cc
@@ -67,6 +67,25 @@ const ReadingListEntry& ReadingListModelImpl::GetReadEntryAtIndex(
return read_[index];
}
+bool ReadingListModelImpl::CallbackEntryURL(
+ const GURL& url,
+ base::Callback<void(const ReadingListEntry&)> callback) const {
+ DCHECK(loaded());
+ ReadingListEntry entry(url, std::string());
+ auto resultUnread = std::find(unread_.begin(), unread_.end(), entry);
+ if (resultUnread != unread_.end()) {
+ callback.Run(*resultUnread);
+ return true;
+ }
+
+ auto resultRead = std::find(read_.begin(), read_.end(), entry);
+ if (resultRead != read_.end()) {
+ callback.Run(*resultRead);
+ return true;
+ }
+ return false;
+}
+
void ReadingListModelImpl::RemoveEntryByUrl(const GURL& url) {
DCHECK(loaded());
const ReadingListEntry entry(url, std::string());

Powered by Google App Engine
This is Rietveld 408576698