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

Side by Side Diff: components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc

Issue 2755113002: Create ReadingListSuggestionsProvider (Closed)
Patch Set: Fix strings Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/ntp_snippets/reading_list/reading_list_suggestions_provider .h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/threading/thread_task_runner_handle.h"
11 #include "components/ntp_snippets/category.h"
12 #include "components/reading_list/core/reading_list_entry.h"
13 #include "components/reading_list/core/reading_list_model.h"
14 #include "components/strings/grit/components_strings.h"
15 #include "ui/base/l10n/l10n_util.h"
16
17 namespace ntp_snippets {
18
19 ReadingListSuggestionsProvider::ReadingListSuggestionsProvider(
20 ContentSuggestionsProvider::Observer* observer,
21 ReadingListModel* reading_list_model)
22 : ContentSuggestionsProvider(observer),
23 category_status_(CategoryStatus::AVAILABLE_LOADING),
24 provided_category_(
25 Category::FromKnownCategory(KnownCategories::READING_LIST)),
26 reading_list_model_(reading_list_model) {
27 observer->OnCategoryStatusChanged(this, provided_category_, category_status_);
28 reading_list_model->AddObserver(this);
29 if (reading_list_model_->loaded()) {
30 FetchReadingListInternal();
31 }
32 }
33
34 ReadingListSuggestionsProvider::~ReadingListSuggestionsProvider() {
35 reading_list_model_->RemoveObserver(this);
36 }
37
38 CategoryStatus ReadingListSuggestionsProvider::GetCategoryStatus(
39 Category category) {
40 DCHECK_EQ(category, provided_category_);
41 return category_status_;
42 }
43
44 CategoryInfo ReadingListSuggestionsProvider::GetCategoryInfo(
45 Category category) {
46 DCHECK_EQ(category, provided_category_);
47
48 return CategoryInfo(l10n_util::GetStringUTF16(
49 IDS_NTP_READING_LIST_SUGGESTIONS_SECTION_HEADER),
50 ContentSuggestionsCardLayout::FULL_CARD,
51 ContentSuggestionsAdditionalAction::VIEW_ALL,
52 /*show_if_empty=*/false,
53 l10n_util::GetStringUTF16(
54 IDS_NTP_READING_LIST_SUGGESTIONS_SECTION_EMPTY));
55 }
56
57 void ReadingListSuggestionsProvider::DismissSuggestion(
58 const ContentSuggestion::ID& suggestion_id) {
59 // TODO(crbug.com/702241): Implement this method.
60 }
61
62 void ReadingListSuggestionsProvider::FetchSuggestionImage(
63 const ContentSuggestion::ID& suggestion_id,
64 const ImageFetchedCallback& callback) {
65 // TODO(crbug.com/702241): Implement this method.
66 }
67
68 void ReadingListSuggestionsProvider::Fetch(
69 const Category& category,
70 const std::set<std::string>& known_suggestion_ids,
71 const FetchDoneCallback& callback) {
72 LOG(DFATAL) << "ReadingListSuggestionsProvider has no |Fetch| functionality!";
Bernhard Bauer 2017/03/27 15:15:02 DFATAL smells a bit like trying to handle a DCHECK
Marc Treib 2017/03/27 15:19:29 This is a pattern we have in all the providers - t
73 base::ThreadTaskRunnerHandle::Get()->PostTask(
74 FROM_HERE,
75 base::Bind(callback,
76 Status(StatusCode::PERMANENT_ERROR,
77 "ReadingListSuggestionsProvider has no |Fetch| "
78 "functionality!"),
79 base::Passed(std::vector<ContentSuggestion>())));
80 }
81
82 void ReadingListSuggestionsProvider::ClearHistory(
83 base::Time begin,
84 base::Time end,
85 const base::Callback<bool(const GURL& url)>& filter) {
86 // TODO(crbug.com/702241): Implement this method.
87 }
88
89 void ReadingListSuggestionsProvider::ClearCachedSuggestions(Category category) {
90 DCHECK_EQ(category, provided_category_);
91 // Ignored.
92 }
93
94 void ReadingListSuggestionsProvider::GetDismissedSuggestionsForDebugging(
95 Category category,
96 const DismissedSuggestionsCallback& callback) {
97 // TODO(crbug.com/702241): Implement this method.
98 }
99 void ReadingListSuggestionsProvider::ClearDismissedSuggestionsForDebugging(
100 Category category) {
101 // TODO(crbug.com/702241): Implement this method.
102 }
103
104 void ReadingListSuggestionsProvider::ReadingListModelLoaded(
105 const ReadingListModel* model) {
106 DCHECK(model == reading_list_model_);
107 FetchReadingListInternal();
108 }
109
110 void ReadingListSuggestionsProvider::FetchReadingListInternal() {
111 // TODO(crbug.com/702241): Implement this method.
112 }
113
114 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698