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

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.cc

Issue 2223073002: Add per-section clearing and dismissed suggestions to snippets-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix non-Debug builds Created 4 years, 4 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
« no previous file with comments | « components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h" 5 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide r.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 //////////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////////
44 // Private methods 44 // Private methods
45 45
46 std::vector<Category> OfflinePageSuggestionsProvider::GetProvidedCategories() { 46 std::vector<Category> OfflinePageSuggestionsProvider::GetProvidedCategories() {
47 return std::vector<Category>({provided_category_}); 47 return std::vector<Category>({provided_category_});
48 } 48 }
49 49
50 CategoryStatus OfflinePageSuggestionsProvider::GetCategoryStatus( 50 CategoryStatus OfflinePageSuggestionsProvider::GetCategoryStatus(
51 Category category) { 51 Category category) {
52 DCHECK_EQ(category, provided_category_);
52 return category_status_; 53 return category_status_;
53 } 54 }
54 55
55 void OfflinePageSuggestionsProvider::DismissSuggestion( 56 void OfflinePageSuggestionsProvider::DismissSuggestion(
56 const std::string& suggestion_id) { 57 const std::string& suggestion_id) {
57 // TODO(pke): Implement some "dont show on NTP anymore" behaviour, 58 // TODO(pke): Implement some "dont show on NTP anymore" behaviour,
58 // then also implement ClearDismissedSuggestionsForDebugging. 59 // then also implement ClearDismissedSuggestionsForDebugging.
59 } 60 }
60 61
61 void OfflinePageSuggestionsProvider::FetchSuggestionImage( 62 void OfflinePageSuggestionsProvider::FetchSuggestionImage(
62 const std::string& suggestion_id, 63 const std::string& suggestion_id,
63 const ImageFetchedCallback& callback) { 64 const ImageFetchedCallback& callback) {
64 // TODO(pke): Fetch proper thumbnail from OfflinePageModel once it's available 65 // TODO(pke): Fetch proper thumbnail from OfflinePageModel once it's available
65 // there. 66 // there.
66 base::ThreadTaskRunnerHandle::Get()->PostTask( 67 base::ThreadTaskRunnerHandle::Get()->PostTask(
67 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image())); 68 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image()));
68 } 69 }
69 70
70 void OfflinePageSuggestionsProvider::ClearCachedSuggestionsForDebugging() { 71 void OfflinePageSuggestionsProvider::ClearCachedSuggestionsForDebugging(
72 Category category) {
73 DCHECK_EQ(category, provided_category_);
71 // Ignored. 74 // Ignored.
72 } 75 }
73 76
74 void OfflinePageSuggestionsProvider::ClearDismissedSuggestionsForDebugging() { 77 std::vector<ContentSuggestion>
78 OfflinePageSuggestionsProvider::GetDismissedSuggestionsForDebugging(
79 Category category) {
80 DCHECK_EQ(category, provided_category_);
81 // TODO(pke): Implement when dismissed suggestions are supported.
82 return std::vector<ContentSuggestion>();
83 }
84
85 void OfflinePageSuggestionsProvider::ClearDismissedSuggestionsForDebugging(
86 Category category) {
87 DCHECK_EQ(category, provided_category_);
75 // TODO(pke): Implement when dismissed suggestions are supported. 88 // TODO(pke): Implement when dismissed suggestions are supported.
76 } 89 }
77 90
78 void OfflinePageSuggestionsProvider::OfflinePageModelLoaded( 91 void OfflinePageSuggestionsProvider::OfflinePageModelLoaded(
79 OfflinePageModel* model) { 92 OfflinePageModel* model) {
80 DCHECK_EQ(offline_page_model_, model); 93 DCHECK_EQ(offline_page_model_, model);
81 } 94 }
82 95
83 void OfflinePageSuggestionsProvider::OfflinePageModelChanged( 96 void OfflinePageSuggestionsProvider::OfflinePageModelChanged(
84 OfflinePageModel* model) { 97 OfflinePageModel* model) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void OfflinePageSuggestionsProvider::NotifyStatusChanged( 143 void OfflinePageSuggestionsProvider::NotifyStatusChanged(
131 CategoryStatus new_status) { 144 CategoryStatus new_status) {
132 if (category_status_ == new_status) 145 if (category_status_ == new_status)
133 return; 146 return;
134 category_status_ = new_status; 147 category_status_ = new_status;
135 148
136 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 149 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
137 } 150 }
138 151
139 } // namespace ntp_snippets 152 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/offline_pages/offline_page_suggestions_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698