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

Side by Side Diff: components/search_provider_logos/logo_tracker.h

Issue 2760003002: [Home] Use white doodle background when Chrome Home is enabled (Closed)
Patch Set: [Home] Use white doodle background when Chrome Home is enabled Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SEARCH_PROVIDER_LOGOS_LOGO_TRACKER_H_ 5 #ifndef COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_TRACKER_H_
6 #define COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_TRACKER_H_ 6 #define COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_TRACKER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const std::unique_ptr<std::string>& response, 73 const std::unique_ptr<std::string>& response,
74 base::Time response_time, 74 base::Time response_time,
75 bool* parsing_failed)> 75 bool* parsing_failed)>
76 ParseLogoResponse; 76 ParseLogoResponse;
77 77
78 // Encodes the fingerprint of the cached logo in the logo URL. This enables the 78 // Encodes the fingerprint of the cached logo in the logo URL. This enables the
79 // server to verify whether the cached logo is up to date. 79 // server to verify whether the cached logo is up to date.
80 typedef base::Callback<GURL(const GURL& logo_url, 80 typedef base::Callback<GURL(const GURL& logo_url,
81 const std::string& fingerprint, 81 const std::string& fingerprint,
82 bool wants_cta, 82 bool wants_cta,
83 bool transparent)> AppendQueryparamsToLogoURL; 83 bool gray_background)>
84 AppendQueryparamsToLogoURL;
84 85
85 // This class provides the logo for a search provider. Logos are downloaded from 86 // This class provides the logo for a search provider. Logos are downloaded from
86 // the search provider's logo URL and cached on disk. 87 // the search provider's logo URL and cached on disk.
87 // 88 //
88 // Call SetServerAPI() at least once to specify how to get the logo from the 89 // Call SetServerAPI() at least once to specify how to get the logo from the
89 // server. Then call GetLogo() to trigger retrieval of the logo and receive 90 // server. Then call GetLogo() to trigger retrieval of the logo and receive
90 // updates once the cached and/or fresh logos are available. 91 // updates once the cached and/or fresh logos are available.
91 class LogoTracker : public net::URLFetcherDelegate { 92 class LogoTracker : public net::URLFetcherDelegate {
92 public: 93 public:
93 // Constructs a LogoTracker with the given LogoDelegate. Takes ownership of 94 // Constructs a LogoTracker with the given LogoDelegate. Takes ownership of
(...skipping 23 matching lines...) Expand all
117 // called at least once before calling GetLogo(). 118 // called at least once before calling GetLogo().
118 // 119 //
119 // |logo_url| is the URL from which the logo will be downloaded. If |logo_url| 120 // |logo_url| is the URL from which the logo will be downloaded. If |logo_url|
120 // is different than the current logo URL, any pending LogoObservers will be 121 // is different than the current logo URL, any pending LogoObservers will be
121 // canceled. 122 // canceled.
122 // 123 //
123 // |parse_logo_response_func| is a callback that will be used to parse the 124 // |parse_logo_response_func| is a callback that will be used to parse the
124 // server's response into a EncodedLogo object. |append_queryparams_func| is a 125 // server's response into a EncodedLogo object. |append_queryparams_func| is a
125 // callback that will return the URL from which to download the logo. 126 // callback that will return the URL from which to download the logo.
126 // |wants_cta| determines if the url should return a call to action image. 127 // |wants_cta| determines if the url should return a call to action image.
127 // |transparent| determines whether to request a transparent logo. 128 // |gray_background| determines whether to request a logo with a gray
129 // background. The gray will match the NTP background color.
128 // Note: |parse_logo_response_func| and |append_queryparams_func| must be 130 // Note: |parse_logo_response_func| and |append_queryparams_func| must be
129 // suitable for running multiple times, concurrently, and on multiple threads. 131 // suitable for running multiple times, concurrently, and on multiple threads.
130 // TODO(ianwen): remove wants_cta from parameter. 132 // TODO(ianwen): remove wants_cta from parameter.
131 void SetServerAPI(const GURL& logo_url, 133 void SetServerAPI(const GURL& logo_url,
132 const ParseLogoResponse& parse_logo_response_func, 134 const ParseLogoResponse& parse_logo_response_func,
133 const AppendQueryparamsToLogoURL& append_queryparams_func, 135 const AppendQueryparamsToLogoURL& append_queryparams_func,
134 bool wants_cta, 136 bool wants_cta,
135 bool transparent); 137 bool gray_background);
136 138
137 // Retrieves the current search provider's logo from the local cache and/or 139 // Retrieves the current search provider's logo from the local cache and/or
138 // over the network, and registers |observer| to be called when the cached 140 // over the network, and registers |observer| to be called when the cached
139 // and/or fresh logos are available. 141 // and/or fresh logos are available.
140 void GetLogo(LogoObserver* observer); 142 void GetLogo(LogoObserver* observer);
141 143
142 // Prevents |observer| from receiving future updates. This is safe to call 144 // Prevents |observer| from receiving future updates. This is safe to call
143 // even when the observer is being notified of an update. 145 // even when the observer is being notified of an update.
144 void RemoveObserver(LogoObserver* observer); 146 void RemoveObserver(LogoObserver* observer);
145 147
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // The function used to parse the logo response from the server. 215 // The function used to parse the logo response from the server.
214 ParseLogoResponse parse_logo_response_func_; 216 ParseLogoResponse parse_logo_response_func_;
215 217
216 // The function used to include the cached logo's fingerprint and call to 218 // The function used to include the cached logo's fingerprint and call to
217 // action request in the logo URL. 219 // action request in the logo URL.
218 AppendQueryparamsToLogoURL append_queryparams_func_; 220 AppendQueryparamsToLogoURL append_queryparams_func_;
219 221
220 // If |true| request call to action in server API. 222 // If |true| request call to action in server API.
221 bool wants_cta_; 223 bool wants_cta_;
222 224
223 // If |true| request transparent doodle. 225 // If |true| request a doodle with a gray background.
224 bool transparent_; 226 bool gray_background_;
225 227
226 // False if an asynchronous task is currently running. 228 // False if an asynchronous task is currently running.
227 bool is_idle_; 229 bool is_idle_;
228 230
229 // The logo that's been read from the cache, or NULL if the cache is empty. 231 // The logo that's been read from the cache, or NULL if the cache is empty.
230 // Meaningful only if is_cached_logo_valid_ is true; NULL otherwise. 232 // Meaningful only if is_cached_logo_valid_ is true; NULL otherwise.
231 std::unique_ptr<Logo> cached_logo_; 233 std::unique_ptr<Logo> cached_logo_;
232 234
233 // Whether the value of |cached_logo_| reflects the actual cached logo. 235 // Whether the value of |cached_logo_| reflects the actual cached logo.
234 // This will be false if the logo hasn't been read from the cache yet. 236 // This will be false if the logo hasn't been read from the cache yet.
(...skipping 29 matching lines...) Expand all
264 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 266 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
265 267
266 base::WeakPtrFactory<LogoTracker> weak_ptr_factory_; 268 base::WeakPtrFactory<LogoTracker> weak_ptr_factory_;
267 269
268 DISALLOW_COPY_AND_ASSIGN(LogoTracker); 270 DISALLOW_COPY_AND_ASSIGN(LogoTracker);
269 }; 271 };
270 272
271 } // namespace search_provider_logos 273 } // namespace search_provider_logos
272 274
273 #endif // COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_TRACKER_H_ 275 #endif // COMPONENTS_SEARCH_PROVIDER_LOGOS_LOGO_TRACKER_H_
OLDNEW
« no previous file with comments | « components/search_provider_logos/google_logo_api.cc ('k') | components/search_provider_logos/logo_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698