| OLD | NEW |
| 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" | |
| 14 #include "chrome/browser/favicon/favicon_service_factory.h" | 13 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 15 #include "chrome/browser/favicon/large_icon_service_factory.h" | |
| 16 #include "chrome/browser/history/top_sites_factory.h" | 14 #include "chrome/browser/history/top_sites_factory.h" |
| 17 #include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h" | 15 #include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/search/instant_io_context.h" | 17 #include "chrome/browser/search/instant_io_context.h" |
| 20 #include "chrome/browser/search/instant_service_observer.h" | 18 #include "chrome/browser/search/instant_service_observer.h" |
| 21 #include "chrome/browser/search/most_visited_iframe_source.h" | 19 #include "chrome/browser/search/most_visited_iframe_source.h" |
| 22 #include "chrome/browser/search/search.h" | 20 #include "chrome/browser/search/search.h" |
| 23 #include "chrome/browser/search/suggestions/image_decoder_impl.h" | 21 #include "chrome/browser/search/suggestions/image_decoder_impl.h" |
| 24 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" | 22 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
| 25 #include "chrome/browser/search/thumbnail_source.h" | 23 #include "chrome/browser/search/thumbnail_source.h" |
| 26 #include "chrome/browser/search_engines/template_url_service_factory.h" | 24 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 27 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 25 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 28 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 26 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
| 29 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 27 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 30 #include "chrome/browser/ui/webui/fallback_icon_source.h" | |
| 31 #include "chrome/browser/ui/webui/favicon_source.h" | 28 #include "chrome/browser/ui/webui/favicon_source.h" |
| 32 #include "chrome/browser/ui/webui/large_icon_source.h" | |
| 33 #include "chrome/browser/ui/webui/theme_source.h" | 29 #include "chrome/browser/ui/webui/theme_source.h" |
| 34 #include "chrome/common/render_messages.h" | 30 #include "chrome/common/render_messages.h" |
| 35 #include "chrome/grit/theme_resources.h" | 31 #include "chrome/grit/theme_resources.h" |
| 36 #include "components/favicon/core/fallback_icon_service.h" | 32 #include "components/favicon/core/fallback_icon_service.h" |
| 37 #include "components/favicon/core/large_icon_service.h" | |
| 38 #include "components/history/core/browser/top_sites.h" | 33 #include "components/history/core/browser/top_sites.h" |
| 39 #include "components/image_fetcher/core/image_fetcher_impl.h" | 34 #include "components/image_fetcher/core/image_fetcher_impl.h" |
| 40 #include "components/keyed_service/core/service_access_type.h" | 35 #include "components/keyed_service/core/service_access_type.h" |
| 41 #include "components/ntp_tiles/icon_cacher.h" | 36 #include "components/ntp_tiles/icon_cacher.h" |
| 42 #include "components/search/search.h" | 37 #include "components/search/search.h" |
| 43 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 44 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 45 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
| 46 #include "content/public/browser/render_process_host.h" | 41 #include "content/public/browser/render_process_host.h" |
| 47 #include "content/public/browser/url_data_source.h" | 42 #include "content/public/browser/url_data_source.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 content::Source<ThemeService>( | 122 content::Source<ThemeService>( |
| 128 ThemeServiceFactory::GetForProfile(profile_))); | 123 ThemeServiceFactory::GetForProfile(profile_))); |
| 129 | 124 |
| 130 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); | 125 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); |
| 131 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); | 126 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); |
| 132 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); | 127 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); |
| 133 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); | 128 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); |
| 134 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); | 129 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); |
| 135 #endif // !defined(OS_ANDROID) | 130 #endif // !defined(OS_ANDROID) |
| 136 | 131 |
| 137 favicon::FallbackIconService* fallback_icon_service = | |
| 138 FallbackIconServiceFactory::GetForBrowserContext(profile_); | |
| 139 favicon::LargeIconService* large_icon_service = | |
| 140 LargeIconServiceFactory::GetForBrowserContext(profile_); | |
| 141 content::URLDataSource::Add( | |
| 142 profile_, new FallbackIconSource(fallback_icon_service)); | |
| 143 content::URLDataSource::Add(profile_, new FaviconSource(profile_)); | 132 content::URLDataSource::Add(profile_, new FaviconSource(profile_)); |
| 144 content::URLDataSource::Add( | |
| 145 profile_, new LargeIconSource(fallback_icon_service, large_icon_service)); | |
| 146 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); | 133 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); |
| 147 } | 134 } |
| 148 | 135 |
| 149 InstantService::~InstantService() = default; | 136 InstantService::~InstantService() = default; |
| 150 | 137 |
| 151 void InstantService::AddInstantProcess(int process_id) { | 138 void InstantService::AddInstantProcess(int process_id) { |
| 152 process_ids_.insert(process_id); | 139 process_ids_.insert(process_id); |
| 153 | 140 |
| 154 if (instant_io_context_.get()) { | 141 if (instant_io_context_.get()) { |
| 155 content::BrowserThread::PostTask( | 142 content::BrowserThread::PostTask( |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 void InstantService::ResetInstantSearchPrerendererIfNecessary() { | 461 void InstantService::ResetInstantSearchPrerendererIfNecessary() { |
| 475 if (!search::IsInstantExtendedAPIEnabled()) | 462 if (!search::IsInstantExtendedAPIEnabled()) |
| 476 return; | 463 return; |
| 477 | 464 |
| 478 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); | 465 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); |
| 479 if (!instant_prerenderer_ || instant_prerenderer_->prerender_url() != url) { | 466 if (!instant_prerenderer_ || instant_prerenderer_->prerender_url() != url) { |
| 480 instant_prerenderer_.reset( | 467 instant_prerenderer_.reset( |
| 481 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : nullptr); | 468 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : nullptr); |
| 482 } | 469 } |
| 483 } | 470 } |
| OLD | NEW |