| 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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/favicon/fallback_icon_service_factory.h" | 15 #include "chrome/browser/favicon/fallback_icon_service_factory.h" |
| 16 #include "chrome/browser/favicon/large_icon_service_factory.h" | 16 #include "chrome/browser/favicon/large_icon_service_factory.h" |
| 17 #include "chrome/browser/history/top_sites_factory.h" | 17 #include "chrome/browser/history/top_sites_factory.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/search/instant_io_context.h" | 19 #include "chrome/browser/search/instant_io_context.h" |
| 20 #include "chrome/browser/search/instant_service_observer.h" | 20 #include "chrome/browser/search/instant_service_observer.h" |
| 21 #include "chrome/browser/search/most_visited_iframe_source.h" | 21 #include "chrome/browser/search/most_visited_iframe_source.h" |
| 22 #include "chrome/browser/search/search.h" | 22 #include "chrome/browser/search/search.h" |
| 23 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" | 23 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
| 24 #include "chrome/browser/search/suggestions/suggestions_source.h" | |
| 25 #include "chrome/browser/search/thumbnail_source.h" | 24 #include "chrome/browser/search/thumbnail_source.h" |
| 26 #include "chrome/browser/search_engines/template_url_service_factory.h" | 25 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 27 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 26 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 28 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 27 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
| 29 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 28 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 30 #include "chrome/browser/ui/webui/fallback_icon_source.h" | 29 #include "chrome/browser/ui/webui/fallback_icon_source.h" |
| 31 #include "chrome/browser/ui/webui/favicon_source.h" | 30 #include "chrome/browser/ui/webui/favicon_source.h" |
| 32 #include "chrome/browser/ui/webui/large_icon_source.h" | 31 #include "chrome/browser/ui/webui/large_icon_source.h" |
| 33 #include "chrome/browser/ui/webui/theme_source.h" | 32 #include "chrome/browser/ui/webui/theme_source.h" |
| 34 #include "chrome/common/render_messages.h" | 33 #include "chrome/common/render_messages.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 FallbackIconServiceFactory::GetForBrowserContext(profile_); | 166 FallbackIconServiceFactory::GetForBrowserContext(profile_); |
| 168 favicon::LargeIconService* large_icon_service = | 167 favicon::LargeIconService* large_icon_service = |
| 169 LargeIconServiceFactory::GetForBrowserContext(profile_); | 168 LargeIconServiceFactory::GetForBrowserContext(profile_); |
| 170 content::URLDataSource::Add( | 169 content::URLDataSource::Add( |
| 171 profile_, new FallbackIconSource(fallback_icon_service)); | 170 profile_, new FallbackIconSource(fallback_icon_service)); |
| 172 content::URLDataSource::Add( | 171 content::URLDataSource::Add( |
| 173 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); | 172 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); |
| 174 content::URLDataSource::Add( | 173 content::URLDataSource::Add( |
| 175 profile_, new LargeIconSource(fallback_icon_service, large_icon_service)); | 174 profile_, new LargeIconSource(fallback_icon_service, large_icon_service)); |
| 176 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); | 175 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); |
| 177 content::URLDataSource::Add( | |
| 178 profile_, new suggestions::SuggestionsSource(profile_)); | |
| 179 | 176 |
| 180 if (IsLocalNTPSuggestionServiceEnabled()) { | 177 if (IsLocalNTPSuggestionServiceEnabled()) { |
| 181 suggestions_service_ = | 178 suggestions_service_ = |
| 182 suggestions::SuggestionsServiceFactory::GetForProfile(profile_); | 179 suggestions::SuggestionsServiceFactory::GetForProfile(profile_); |
| 183 } | 180 } |
| 184 | 181 |
| 185 if (suggestions_service_) { | 182 if (suggestions_service_) { |
| 186 suggestions_subscription_ = suggestions_service_->AddCallback( | 183 suggestions_subscription_ = suggestions_service_->AddCallback( |
| 187 base::Bind(&InstantService::OnSuggestionsAvailable, | 184 base::Bind(&InstantService::OnSuggestionsAvailable, |
| 188 base::Unretained(this))); | 185 base::Unretained(this))); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 } | 590 } |
| 594 | 591 |
| 595 void InstantService::ResetInstantSearchPrerenderer() { | 592 void InstantService::ResetInstantSearchPrerenderer() { |
| 596 if (!search::ShouldPrefetchSearchResults()) | 593 if (!search::ShouldPrefetchSearchResults()) |
| 597 return; | 594 return; |
| 598 | 595 |
| 599 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); | 596 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); |
| 600 instant_prerenderer_.reset( | 597 instant_prerenderer_.reset( |
| 601 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 598 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
| 602 } | 599 } |
| OLD | NEW |