Index: components/ntp_snippets/ios/reading_list_suggestions_provider.cc |
diff --git a/components/ntp_snippets/ios/reading_list_suggestions_provider.cc b/components/ntp_snippets/ios/reading_list_suggestions_provider.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e02e66b14dd03b379bb85a70b1829ee1bbf2a18e |
--- /dev/null |
+++ b/components/ntp_snippets/ios/reading_list_suggestions_provider.cc |
@@ -0,0 +1,97 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/ntp_snippets/ios/reading_list_suggestions_provider.h" |
+ |
+#include <vector> |
+ |
+#include "base/bind.h" |
+#include "base/threading/thread_task_runner_handle.h" |
+#include "components/ntp_snippets/category.h" |
+#include "components/reading_list/ios/reading_list_entry.h" |
+#include "components/reading_list/ios/reading_list_model.h" |
+#include "components/strings/grit/components_strings.h" |
+#include "ui/base/l10n/l10n_util.h" |
+ |
+namespace ntp_snippets { |
+ |
+ReadingListSuggestionsProvider::ReadingListSuggestionsProvider( |
+ ContentSuggestionsProvider::Observer* observer, |
+ ReadingListModel* reading_list_model) |
+ : ContentSuggestionsProvider(observer), |
+ category_status_(CategoryStatus::AVAILABLE_LOADING), |
+ provided_category_( |
+ Category::FromKnownCategory(KnownCategories::READING_LIST)), |
+ reading_list_model_(reading_list_model) { |
+ observer->OnCategoryStatusChanged(this, provided_category_, category_status_); |
+ if (reading_list_model_->loaded()) { |
+ FetchReadingListInternal(); |
+ } |
Marc Treib
2017/03/17 14:44:01
Do we need to register as a ReadingListObserver or
gambard
2017/03/20 08:32:39
Done.
|
+} |
+ |
+CategoryStatus ReadingListSuggestionsProvider::GetCategoryStatus( |
+ Category category) { |
+ DCHECK_EQ(category, provided_category_); |
+ return category_status_; |
+}; |
+ |
+CategoryInfo ReadingListSuggestionsProvider::GetCategoryInfo( |
+ Category category) { |
+ DCHECK_EQ(category, provided_category_); |
+ |
+ return CategoryInfo(l10n_util::GetStringUTF16( |
+ IDS_NTP_READING_LIST_SUGGESTIONS_SECTION_HEADER), |
+ ContentSuggestionsCardLayout::FULL_CARD, |
+ /*has_fetch_action=*/false, |
+ /*has_view_all_action=*/true, |
+ /*show_if_empty=*/false, |
+ l10n_util::GetStringUTF16( |
+ IDS_NTP_READING_LIST_SUGGESTIONS_SECTION_EMPTY)); |
+}; |
+ |
+void ReadingListSuggestionsProvider::DismissSuggestion( |
+ const ContentSuggestion::ID& suggestion_id){}; |
Marc Treib
2017/03/17 14:44:01
This should probably get implemented? (doesn't hav
gambard
2017/03/20 08:32:39
Done.
|
+void ReadingListSuggestionsProvider::FetchSuggestionImage( |
+ const ContentSuggestion::ID& suggestion_id, |
+ const ImageFetchedCallback& callback){}; |
Marc Treib
2017/03/17 14:44:01
Also here
gambard
2017/03/20 08:32:40
Done.
|
+ |
+void ReadingListSuggestionsProvider::Fetch( |
+ const Category& category, |
+ const std::set<std::string>& known_suggestion_ids, |
+ const FetchDoneCallback& callback) { |
+ LOG(DFATAL) << "ReadingListSuggestionsProvider has no |Fetch| functionality!"; |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, |
+ base::Bind( |
+ callback, |
+ Status( |
+ StatusCode::PERMANENT_ERROR, |
+ "ReadingListSuggestionsProvider has no |Fetch| functionality!"), |
+ base::Passed(std::vector<ContentSuggestion>()))); |
+}; |
+ |
+void ReadingListSuggestionsProvider::ClearHistory( |
+ base::Time begin, |
+ base::Time end, |
+ const base::Callback<bool(const GURL& url)>& filter){}; |
Marc Treib
2017/03/17 14:44:01
Also here
gambard
2017/03/20 08:32:39
Done.
|
+ |
+void ReadingListSuggestionsProvider::ClearCachedSuggestions(Category category) { |
+ DCHECK_EQ(category, provided_category_); |
+ // Ignored. |
+}; |
+ |
+void ReadingListSuggestionsProvider::GetDismissedSuggestionsForDebugging( |
+ Category category, |
+ const DismissedSuggestionsCallback& callback){}; |
+void ReadingListSuggestionsProvider::ClearDismissedSuggestionsForDebugging( |
+ Category category){}; |
Marc Treib
2017/03/17 14:44:01
And here :)
gambard
2017/03/20 08:32:39
Done.
|
+ |
+void ReadingListSuggestionsProvider::ReadingListModelLoaded( |
+ const ReadingListModel* model) { |
+ FetchReadingListInternal(); |
Marc Treib
2017/03/17 14:44:00
nit: DCHECK_EQ(reading_list_model_, model);
(thoug
gambard
2017/03/20 08:32:39
I don't know :) It looks like a standard iOS deleg
|
+} |
+ |
+void ReadingListSuggestionsProvider::FetchReadingListInternal() {} |
+ |
+} // namespace ntp_snippets |