OLD | NEW |
---|---|
(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/ios/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 }; | |
Marc Treib
2017/03/23 17:12:21
nit: no semicolon after method, also in lots more
gambard
2017/03/23 17:49:39
Done.
| |
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 void ReadingListSuggestionsProvider::FetchSuggestionImage( | |
Marc Treib
2017/03/23 17:12:21
nit: empty line before
gambard
2017/03/23 17:49:39
Done.
| |
62 const ContentSuggestion::ID& suggestion_id, | |
63 const ImageFetchedCallback& callback){ | |
64 // TODO(crbug.com/702241): Implement this method. | |
65 }; | |
66 | |
67 void ReadingListSuggestionsProvider::Fetch( | |
68 const Category& category, | |
69 const std::set<std::string>& known_suggestion_ids, | |
70 const FetchDoneCallback& callback) { | |
71 LOG(DFATAL) << "ReadingListSuggestionsProvider has no |Fetch| functionality!"; | |
72 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
73 FROM_HERE, | |
74 base::Bind(callback, | |
75 Status(StatusCode::PERMANENT_ERROR, | |
76 "ReadingListSuggestionsProvider has no |Fetch| " | |
77 "functionality!"), | |
78 base::Passed(std::vector<ContentSuggestion>()))); | |
79 }; | |
80 | |
81 void ReadingListSuggestionsProvider::ClearHistory( | |
82 base::Time begin, | |
83 base::Time end, | |
84 const base::Callback<bool(const GURL& url)>& filter){ | |
85 // TODO(crbug.com/702241): Implement this method. | |
86 }; | |
87 | |
88 void ReadingListSuggestionsProvider::ClearCachedSuggestions(Category category) { | |
89 DCHECK_EQ(category, provided_category_); | |
90 // Ignored. | |
91 }; | |
92 | |
93 void ReadingListSuggestionsProvider::GetDismissedSuggestionsForDebugging( | |
94 Category category, | |
95 const DismissedSuggestionsCallback& callback){ | |
96 // TODO(crbug.com/702241): Implement this method. | |
97 }; | |
98 void ReadingListSuggestionsProvider::ClearDismissedSuggestionsForDebugging( | |
99 Category category){ | |
100 // TODO(crbug.com/702241): Implement this method. | |
101 }; | |
102 | |
103 void ReadingListSuggestionsProvider::ReadingListModelLoaded( | |
104 const ReadingListModel* model) { | |
105 DCHECK(model == reading_list_model_); | |
106 FetchReadingListInternal(); | |
107 } | |
108 | |
109 void ReadingListSuggestionsProvider::FetchReadingListInternal() { | |
110 // TODO(crbug.com/702241): Implement this method. | |
111 } | |
112 | |
113 } // namespace ntp_snippets | |
OLD | NEW |