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

Side by Side Diff: components/ntp_snippets/ntp_snippets_service.h

Issue 2225753003: Revert of Add per-section clearing and dismissed suggestions to snippets-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_
6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // for requests triggered by the user. 102 // for requests triggered by the user.
103 void FetchSnippets(bool force_request); 103 void FetchSnippets(bool force_request);
104 104
105 // Fetches snippets from the server for specified hosts (overriding 105 // Fetches snippets from the server for specified hosts (overriding
106 // suggestions from the suggestion service) and adds them to the current ones. 106 // suggestions from the suggestion service) and adds them to the current ones.
107 // Only called from chrome://snippets-internals, DO NOT USE otherwise! 107 // Only called from chrome://snippets-internals, DO NOT USE otherwise!
108 // Ignored while |loaded()| is false. 108 // Ignored while |loaded()| is false.
109 void FetchSnippetsFromHosts(const std::set<std::string>& hosts, 109 void FetchSnippetsFromHosts(const std::set<std::string>& hosts,
110 bool force_request); 110 bool force_request);
111 111
112 // Available snippets.
113 const NTPSnippet::PtrVector& snippets() const { return snippets_; }
114
115 // Returns the list of snippets previously dismissed by the user (that are
116 // not expired yet).
117 const NTPSnippet::PtrVector& dismissed_snippets() const {
118 return dismissed_snippets_;
119 }
120
112 const NTPSnippetsFetcher* snippets_fetcher() const { 121 const NTPSnippetsFetcher* snippets_fetcher() const {
113 return snippets_fetcher_.get(); 122 return snippets_fetcher_.get();
114 } 123 }
115 124
116 // Returns a reason why the service is disabled, or DisabledReason::NONE 125 // Returns a reason why the service is disabled, or DisabledReason::NONE
117 // if it's not. 126 // if it's not.
118 DisabledReason disabled_reason() const { 127 DisabledReason disabled_reason() const {
119 return snippets_status_service_->disabled_reason(); 128 return snippets_status_service_->disabled_reason();
120 } 129 }
121 130
122 // (Re)schedules the periodic fetching of snippets. This is necessary because 131 // (Re)schedules the periodic fetching of snippets. This is necessary because
123 // the schedule depends on the time of day. 132 // the schedule depends on the time of day.
124 void RescheduleFetching(); 133 void RescheduleFetching();
125 134
126 // ContentSuggestionsProvider implementation 135 // ContentSuggestionsProvider implementation
136 // TODO(pke): At some point reorder the implementations in the .cc file
137 // accordingly.
127 std::vector<Category> GetProvidedCategories() override; 138 std::vector<Category> GetProvidedCategories() override;
128 CategoryStatus GetCategoryStatus(Category category) override; 139 CategoryStatus GetCategoryStatus(Category category) override;
129 void DismissSuggestion(const std::string& suggestion_id) override; 140 void DismissSuggestion(const std::string& suggestion_id) override;
130 void FetchSuggestionImage(const std::string& suggestion_id, 141 void FetchSuggestionImage(const std::string& suggestion_id,
131 const ImageFetchedCallback& callback) override; 142 const ImageFetchedCallback& callback) override;
132 void ClearCachedSuggestionsForDebugging(Category category) override; 143 void ClearCachedSuggestionsForDebugging() override;
133 std::vector<ContentSuggestion> GetDismissedSuggestionsForDebugging( 144 void ClearDismissedSuggestionsForDebugging() override;
134 Category category) override;
135 void ClearDismissedSuggestionsForDebugging(Category category) override;
136 145
137 // Returns the lists of suggestion hosts the snippets are restricted to. 146 // Returns the lists of suggestion hosts the snippets are restricted to.
138 std::set<std::string> GetSuggestionsHosts() const; 147 std::set<std::string> GetSuggestionsHosts() const;
139 148
140 // Returns the maximum number of snippets that will be shown at once. 149 // Returns the maximum number of snippets that will be shown at once.
141 static int GetMaxSnippetCountForTesting(); 150 static int GetMaxSnippetCountForTesting();
142 151
143 // Available snippets, only for unit tests.
144 const NTPSnippet::PtrVector& GetSnippetsForTesting() const {
145 return snippets_;
146 }
147
148 private: 152 private:
149 friend class NTPSnippetsServiceTest; 153 friend class NTPSnippetsServiceTest;
150 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsServiceTest, StatusChanges); 154 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsServiceTest, StatusChanges);
151 155
152 // Possible state transitions: 156 // Possible state transitions:
153 // NOT_INITED --------+ 157 // NOT_INITED --------+
154 // / \ | 158 // / \ |
155 // v v | 159 // v v |
156 // READY <--> DISABLED | 160 // READY <--> DISABLED |
157 // \ / | 161 // \ / |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 bool fetch_after_load_; 306 bool fetch_after_load_;
303 307
304 const Category provided_category_; 308 const Category provided_category_;
305 309
306 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsService); 310 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsService);
307 }; 311 };
308 312
309 } // namespace ntp_snippets 313 } // namespace ntp_snippets
310 314
311 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ 315 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_service_unittest.cc ('k') | components/ntp_snippets/ntp_snippets_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698