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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/history/history_notifications.h" | 13 #include "chrome/browser/history/history_notifications.h" |
14 #include "chrome/browser/history/most_visited_tiles_experiment.h" | 14 #include "chrome/browser/history/most_visited_tiles_experiment.h" |
15 #include "chrome/browser/history/top_sites.h" | 15 #include "chrome/browser/history/top_sites.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/search/instant_io_context.h" | 17 #include "chrome/browser/search/instant_io_context.h" |
18 #include "chrome/browser/search/instant_service_factory.h" | 18 #include "chrome/browser/search/instant_service_factory.h" |
19 #include "chrome/browser/search/instant_service_observer.h" | 19 #include "chrome/browser/search/instant_service_observer.h" |
20 #include "chrome/browser/search/local_ntp_source.h" | 20 #include "chrome/browser/search/local_ntp_source.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.h" | |
24 #include "chrome/browser/search/suggestions/suggestions_source.h" | |
25 #include "chrome/browser/search_engines/template_url.h" | 23 #include "chrome/browser/search_engines/template_url.h" |
26 #include "chrome/browser/search_engines/template_url_service.h" | 24 #include "chrome/browser/search_engines/template_url_service.h" |
27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 25 #include "chrome/browser/search_engines/template_url_service_factory.h" |
28 #include "chrome/browser/themes/theme_properties.h" | 26 #include "chrome/browser/themes/theme_properties.h" |
29 #include "chrome/browser/themes/theme_service.h" | 27 #include "chrome/browser/themes/theme_service.h" |
30 #include "chrome/browser/themes/theme_service_factory.h" | 28 #include "chrome/browser/themes/theme_service_factory.h" |
31 #include "chrome/browser/ui/webui/favicon_source.h" | 29 #include "chrome/browser/ui/webui/favicon_source.h" |
32 #include "chrome/browser/ui/webui/ntp/thumbnail_list_source.h" | 30 #include "chrome/browser/ui/webui/ntp/thumbnail_list_source.h" |
33 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 31 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
34 #include "chrome/browser/ui/webui/theme_source.h" | 32 #include "chrome/browser/ui/webui/theme_source.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); | 107 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); |
110 #endif // defined(ENABLE_THEMES) | 108 #endif // defined(ENABLE_THEMES) |
111 | 109 |
112 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); | 110 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); |
113 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); | 111 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); |
114 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); | 112 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); |
115 content::URLDataSource::Add( | 113 content::URLDataSource::Add( |
116 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); | 114 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); |
117 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); | 115 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); |
118 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); | 116 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); |
119 if (suggestions::SuggestionsService::IsEnabled()) | |
120 content::URLDataSource::Add(profile_, new SuggestionsSource(profile_)); | |
121 | 117 |
122 profile_pref_registrar_.Init(profile_->GetPrefs()); | 118 profile_pref_registrar_.Init(profile_->GetPrefs()); |
123 profile_pref_registrar_.Add( | 119 profile_pref_registrar_.Add( |
124 prefs::kDefaultSearchProviderID, | 120 prefs::kDefaultSearchProviderID, |
125 base::Bind(&InstantService::OnDefaultSearchProviderChanged, | 121 base::Bind(&InstantService::OnDefaultSearchProviderChanged, |
126 base::Unretained(this))); | 122 base::Unretained(this))); |
127 | 123 |
128 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, | 124 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, |
129 content::Source<Profile>(profile_->GetOriginalProfile())); | 125 content::Source<Profile>(profile_->GetOriginalProfile())); |
130 } | 126 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 void InstantService::ResetInstantSearchPrerenderer() { | 441 void InstantService::ResetInstantSearchPrerenderer() { |
446 if (!chrome::ShouldPrefetchSearchResults()) | 442 if (!chrome::ShouldPrefetchSearchResults()) |
447 return; | 443 return; |
448 | 444 |
449 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); | 445 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); |
450 if (url.is_valid()) | 446 if (url.is_valid()) |
451 instant_prerenderer_.reset(new InstantSearchPrerenderer(profile_, url)); | 447 instant_prerenderer_.reset(new InstantSearchPrerenderer(profile_, url)); |
452 else | 448 else |
453 instant_prerenderer_.reset(); | 449 instant_prerenderer_.reset(); |
454 } | 450 } |
OLD | NEW |