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

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

Issue 1974483002: Allow getting _only_ personalized snippets for NTP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes Created 4 years, 7 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 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 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_
6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const std::string& last_json() const { 92 const std::string& last_json() const {
93 return last_fetch_json_; 93 return last_fetch_json_;
94 } 94 }
95 95
96 // Overrides internal clock for testing purposes. 96 // Overrides internal clock for testing purposes.
97 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock) { 97 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock) {
98 tick_clock_ = std::move(tick_clock); 98 tick_clock_ = std::move(tick_clock);
99 } 99 }
100 100
101 private: 101 private:
102 enum class Variant { kRestrictedPersonalized, kRestricted, kPersonalized }; 102 enum class Variant { kPersonalized, kNonPersonalized, kAll };
Marc Treib 2016/05/12 08:59:16 Can we rename "Variant" to something more meaningf
jkrcal 2016/05/12 09:57:29 Done. I did not like kYes, kNo, kBoth - Yes and No
Marc Treib 2016/05/12 10:06:15 Yup, yours are better, thanks!
103 103
104 void FetchSnippetsImpl(const GURL& url, 104 void FetchSnippetsImpl(const GURL& url,
105 const std::string& auth_header, 105 const std::string& auth_header,
106 const std::string& request); 106 const std::string& request);
107 std::string GetHostRestricts() const; 107 std::string GetHostRestricts() const;
108 bool UseHostRestriction() const; 108 bool UseHostRestriction() const;
109 bool UseAuthentication() const; 109 bool UseAuthentication() const;
110 void FetchSnippetsNonAuthenticated(); 110 void FetchSnippetsNonAuthenticated();
111 void FetchSnippetsAuthenticated(const std::string& account_id, 111 void FetchSnippetsAuthenticated(const std::string& account_id,
112 const std::string& oauth_access_token); 112 const std::string& oauth_access_token);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 // The fetcher for downloading the snippets. 157 // The fetcher for downloading the snippets.
158 std::unique_ptr<net::URLFetcher> url_fetcher_; 158 std::unique_ptr<net::URLFetcher> url_fetcher_;
159 159
160 // The callback to notify when new snippets get fetched. 160 // The callback to notify when new snippets get fetched.
161 SnippetsAvailableCallback snippets_available_callback_; 161 SnippetsAvailableCallback snippets_available_callback_;
162 162
163 // Flag for picking the right (stable/non-stable) API key for Chrome Reader. 163 // Flag for picking the right (stable/non-stable) API key for Chrome Reader.
164 bool is_stable_channel_; 164 bool is_stable_channel_;
165 165
166 // The variant of the fetching to use. 166 // The variant of the fetching to use, loaded from variation parameters.
167 Variant variant_; 167 Variant variant_;
168 // Should we apply host restriction? It is loaded from variation parameters.
169 bool use_host_restriction_;
168 170
169 // Allow for an injectable tick clock for testing. 171 // Allow for an injectable tick clock for testing.
170 std::unique_ptr<base::TickClock> tick_clock_; 172 std::unique_ptr<base::TickClock> tick_clock_;
171 173
172 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; 174 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_;
173 175
174 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); 176 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher);
175 }; 177 };
176 } // namespace ntp_snippets 178 } // namespace ntp_snippets
177 179
178 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ 180 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher.cc » ('j') | components/ntp_snippets/ntp_snippets_fetcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698