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/breaking_news/breaking_news_suggestions_provid er.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "components/ntp_snippets/breaking_news/content_suggestions_gcm_app_hand ler.h" | |
9 #include "components/ntp_snippets/category.h" | |
10 #include "components/ntp_snippets/pref_names.h" | |
11 #include "components/strings/grit/components_strings.h" | |
12 | |
13 namespace ntp_snippets { | |
14 | |
15 BreakingNewsSuggestionsProvider::BreakingNewsSuggestionsProvider( | |
16 ContentSuggestionsProvider::Observer* observer, | |
17 std::unique_ptr<ContentSuggestionsGCMAppHandler> gcm_app_handler) | |
18 : ContentSuggestionsProvider(observer), | |
19 gcm_app_handler_(std::move(gcm_app_handler)), | |
20 provided_category_( | |
21 Category::FromKnownCategory(KnownCategories::BREAKING_NEWS)) {} | |
sfiera
2017/06/08 13:37:15
Please initialize category_status_ here.
mamir
2017/06/08 15:20:06
Done.
| |
22 | |
23 BreakingNewsSuggestionsProvider::~BreakingNewsSuggestionsProvider() { | |
24 gcm_app_handler_->StopListening(); | |
25 } | |
26 | |
27 void BreakingNewsSuggestionsProvider::Start() { | |
28 // TDOD(mamir): Is unretained the correct method to use? | |
sfiera
2017/06/08 13:37:15
Yes. I would add a comment like:
// Unretained b
mamir
2017/06/08 15:20:06
Done.
| |
29 gcm_app_handler_->StartListening( | |
30 base::Bind(&BreakingNewsSuggestionsProvider::OnNewContentSuggestion, | |
31 base::Unretained(this))); | |
32 } | |
33 | |
34 void BreakingNewsSuggestionsProvider::OnNewContentSuggestion( | |
35 const std::string& content) {} | |
36 | |
37 //////////////////////////////////////////////////////////////////////////////// | |
38 // Private methods | |
39 | |
40 CategoryStatus BreakingNewsSuggestionsProvider::GetCategoryStatus( | |
41 Category category) { | |
42 DCHECK_EQ(category, provided_category_); | |
43 return category_status_; | |
44 } | |
45 | |
46 CategoryInfo BreakingNewsSuggestionsProvider::GetCategoryInfo( | |
47 Category category) { | |
48 // TODO(mamir): needs to be corrected, just a placeholer | |
49 return CategoryInfo(base::string16(), | |
50 ContentSuggestionsCardLayout::MINIMAL_CARD, | |
51 ContentSuggestionsAdditionalAction::VIEW_ALL, | |
52 /*show_if_empty=*/false, base::string16()); | |
53 } | |
54 | |
55 void BreakingNewsSuggestionsProvider::DismissSuggestion( | |
56 const ContentSuggestion::ID& suggestion_id) {} | |
57 | |
58 void BreakingNewsSuggestionsProvider::FetchSuggestionImage( | |
59 const ContentSuggestion::ID& suggestion_id, | |
60 const ImageFetchedCallback& callback) {} | |
61 | |
62 void BreakingNewsSuggestionsProvider::Fetch( | |
63 const Category& category, | |
64 const std::set<std::string>& known_suggestion_ids, | |
65 const FetchDoneCallback& callback) {} | |
66 | |
67 void BreakingNewsSuggestionsProvider::ClearHistory( | |
68 base::Time begin, | |
69 base::Time end, | |
70 const base::Callback<bool(const GURL& url)>& filter) {} | |
sfiera
2017/06/08 13:37:15
Should have a TODO(mamir) to clear the provider (I
mamir
2017/06/08 15:20:06
Done.
| |
71 | |
72 void BreakingNewsSuggestionsProvider::ClearCachedSuggestions( | |
73 Category category) { | |
74 DCHECK_EQ(category, provided_category_); | |
75 // Ignored. | |
sfiera
2017/06/08 13:37:15
Likewise?
mamir
2017/06/08 15:20:06
Done.
| |
76 } | |
77 | |
78 void BreakingNewsSuggestionsProvider::GetDismissedSuggestionsForDebugging( | |
79 Category category, | |
80 const DismissedSuggestionsCallback& callback) {} | |
81 | |
82 void BreakingNewsSuggestionsProvider::ClearDismissedSuggestionsForDebugging( | |
83 Category category) {} | |
84 | |
85 } // namespace ntp_snippets | |
OLD | NEW |