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

Unified Diff: chrome/browser/search/instant_service.cc

Issue 2660883002: Introduce a Doodle Fetcher for NTP (Closed)
Patch Set: Tests work. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search/instant_service.cc
diff --git a/chrome/browser/search/instant_service.cc b/chrome/browser/search/instant_service.cc
index 4a1c3b142c8ca4076e58b0b8ee88481487c72826..666a2bf277c1e37d5afaef61207072f274c9583f 100644
--- a/chrome/browser/search/instant_service.cc
+++ b/chrome/browser/search/instant_service.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/search/instant_service.h"
#include <stddef.h>
+#include <string>
+#include <utility>
#include "base/bind.h"
#include "base/feature_list.h"
@@ -33,6 +35,7 @@
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/render_messages.h"
#include "chrome/grit/theme_resources.h"
+#include "components/doodle/doodle_fetcher.h"
#include "components/favicon/core/fallback_icon_service.h"
#include "components/favicon/core/large_icon_service.h"
#include "components/history/core/browser/top_sites.h"
@@ -57,6 +60,10 @@
#include "chrome/browser/themes/theme_service_factory.h"
#endif
+using doodle::DoodleState;
+using doodle::DoodleFetcher;
+using doodle::DoodleConfig;
+
namespace {
const base::Feature kNtpTilesFeature{"NTPTilesInInstantService",
@@ -148,6 +155,28 @@ InstantService::InstantService(Profile* profile)
content::URLDataSource::Add(
profile_, new LargeIconSource(fallback_icon_service, large_icon_service));
content::URLDataSource::Add(profile_, new MostVisitedIframeSource());
+
+ doodle_fetcher_ = base::MakeUnique<DoodleFetcher>(
+ profile_->GetRequestContext(),
+ GURL(UIThreadSearchTermsData(profile_).GoogleBaseURLValue()));
+ doodle_fetcher_->FetchDoodle(base::Bind([](const DoodleConfig& config) {
+ if (config.state != DoodleState::AVAILABLE) {
+ LOG(ERROR) << "DEBUG DoodleFetcher: Doodle wasn't fetched.";
+ return;
+ }
+ LOG(ERROR)
+ << "DEBUG DoodleFetcher: Fetching and parsing the JSON succeeded.";
+ LOG(ERROR) << "DEBUG DoodleFetcher: config.TTL(ms)="
+ << config.time_to_live_ms;
+ LOG(ERROR) << "DEBUG DoodleFetcher: config.doodle_type="
+ << config.doodle_type;
+ LOG(ERROR) << "DEBUG DoodleFetcher: config.search_url="
+ << config.search_url.spec();
+ LOG(ERROR) << "DEBUG DoodleFetcher: config.large_image.url="
+ << config.large_image.url.spec();
+ LOG(ERROR) << "DEBUG DoodleFetcher: config.large_image.width="
+ << config.large_image.width;
+ }));
}
InstantService::~InstantService() {

Powered by Google App Engine
This is Rietveld 408576698