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

Side by Side Diff: chrome/browser/search/instant_service.cc

Issue 2572533002: Add ChromeMostVisitedSitesFactory (Closed)
Patch Set: Use factory for webui Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/search/instant_service.h" 5 #include "chrome/browser/search/instant_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/favicon/fallback_icon_service_factory.h" 13 #include "chrome/browser/favicon/fallback_icon_service_factory.h"
14 #include "chrome/browser/favicon/favicon_service_factory.h" 14 #include "chrome/browser/favicon/favicon_service_factory.h"
15 #include "chrome/browser/favicon/large_icon_service_factory.h" 15 #include "chrome/browser/favicon/large_icon_service_factory.h"
16 #include "chrome/browser/history/top_sites_factory.h" 16 #include "chrome/browser/history/top_sites_factory.h"
17 #include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/search/instant_io_context.h" 19 #include "chrome/browser/search/instant_io_context.h"
19 #include "chrome/browser/search/instant_service_observer.h" 20 #include "chrome/browser/search/instant_service_observer.h"
20 #include "chrome/browser/search/most_visited_iframe_source.h" 21 #include "chrome/browser/search/most_visited_iframe_source.h"
21 #include "chrome/browser/search/search.h" 22 #include "chrome/browser/search/search.h"
22 #include "chrome/browser/search/suggestions/image_decoder_impl.h" 23 #include "chrome/browser/search/suggestions/image_decoder_impl.h"
23 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" 24 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
24 #include "chrome/browser/search/thumbnail_source.h" 25 #include "chrome/browser/search/thumbnail_source.h"
25 #include "chrome/browser/search_engines/template_url_service_factory.h" 26 #include "chrome/browser/search_engines/template_url_service_factory.h"
26 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 27 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ResetInstantSearchPrerendererIfNecessary(); 94 ResetInstantSearchPrerendererIfNecessary();
94 95
95 registrar_.Add(this, 96 registrar_.Add(this,
96 content::NOTIFICATION_RENDERER_PROCESS_CREATED, 97 content::NOTIFICATION_RENDERER_PROCESS_CREATED,
97 content::NotificationService::AllSources()); 98 content::NotificationService::AllSources());
98 registrar_.Add(this, 99 registrar_.Add(this,
99 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 100 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
100 content::NotificationService::AllSources()); 101 content::NotificationService::AllSources());
101 102
102 if (base::FeatureList::IsEnabled(kNtpTilesFeature)) { 103 if (base::FeatureList::IsEnabled(kNtpTilesFeature)) {
103 most_visited_sites_ = base::MakeUnique<ntp_tiles::MostVisitedSites>( 104 most_visited_sites_ =
104 profile_->GetPrefs(), TopSitesFactory::GetForProfile(profile_), 105 ChromeMostVisitedSitesFactory::NewForProfile(profile_);
105 suggestions::SuggestionsServiceFactory::GetForProfile(profile_),
106 /*popular_sites=*/nullptr,
107 base::MakeUnique<ntp_tiles::IconCacher>(
108 FaviconServiceFactory::GetForProfile(
109 profile, ServiceAccessType::IMPLICIT_ACCESS),
110 base::MakeUnique<image_fetcher::ImageFetcherImpl>(
111 base::MakeUnique<suggestions::ImageDecoderImpl>(),
112 profile->GetRequestContext())),
113 /*supervisor=*/nullptr);
114 // TODO(treib): Add supervisor.
115 // TODO(sfiera): Share this with Android in a factory.
116
117 most_visited_sites_->SetMostVisitedURLsObserver(this, 8); 106 most_visited_sites_->SetMostVisitedURLsObserver(this, 8);
118 } else { 107 } else {
119 top_sites_ = TopSitesFactory::GetForProfile(profile_); 108 top_sites_ = TopSitesFactory::GetForProfile(profile_);
120 if (top_sites_) { 109 if (top_sites_) {
121 top_sites_->AddObserver(this); 110 top_sites_->AddObserver(this);
122 // Immediately query the TopSites state. 111 // Immediately query the TopSites state.
123 TopSitesChanged(top_sites_.get(), 112 TopSitesChanged(top_sites_.get(),
124 history::TopSitesObserver::ChangeReason::MOST_VISITED); 113 history::TopSitesObserver::ChangeReason::MOST_VISITED);
125 } 114 }
126 } 115 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 void InstantService::ResetInstantSearchPrerendererIfNecessary() { 504 void InstantService::ResetInstantSearchPrerendererIfNecessary() {
516 if (!search::ShouldPrefetchSearchResults()) 505 if (!search::ShouldPrefetchSearchResults())
517 return; 506 return;
518 507
519 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); 508 GURL url(search::GetSearchResultPrefetchBaseURL(profile_));
520 if (!instant_prerenderer_ || instant_prerenderer_->prerender_url() != url) { 509 if (!instant_prerenderer_ || instant_prerenderer_->prerender_url() != url) {
521 instant_prerenderer_.reset( 510 instant_prerenderer_.reset(
522 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : nullptr); 511 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : nullptr);
523 } 512 }
524 } 513 }
OLDNEW
« no previous file with comments | « chrome/browser/ntp_tiles/chrome_popular_sites_factory.cc ('k') | chrome/browser/ui/webui/ntp_tiles_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698