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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/favicon/fallback_icon_service_factory.h" | |
9 #include "chrome/browser/favicon/favicon_service_factory.h" | |
8 #include "chrome/browser/history/top_sites_factory.h" | 10 #include "chrome/browser/history/top_sites_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/search/instant_io_context.h" | 12 #include "chrome/browser/search/instant_io_context.h" |
11 #include "chrome/browser/search/instant_service_observer.h" | 13 #include "chrome/browser/search/instant_service_observer.h" |
12 #include "chrome/browser/search/most_visited_iframe_source.h" | 14 #include "chrome/browser/search/most_visited_iframe_source.h" |
13 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
14 #include "chrome/browser/search/suggestions/suggestions_source.h" | 16 #include "chrome/browser/search/suggestions/suggestions_source.h" |
15 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
16 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
17 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
18 #include "chrome/browser/themes/theme_service.h" | 20 #include "chrome/browser/themes/theme_service.h" |
19 #include "chrome/browser/themes/theme_service_factory.h" | 21 #include "chrome/browser/themes/theme_service_factory.h" |
20 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 22 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
21 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 23 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
22 #include "chrome/browser/ui/webui/fallback_icon_source.h" | 24 #include "chrome/browser/ui/webui/fallback_icon_source.h" |
23 #include "chrome/browser/ui/webui/favicon_source.h" | 25 #include "chrome/browser/ui/webui/favicon_source.h" |
24 #include "chrome/browser/ui/webui/large_icon_source.h" | 26 #include "chrome/browser/ui/webui/large_icon_source.h" |
25 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 27 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
26 #include "chrome/browser/ui/webui/theme_source.h" | 28 #include "chrome/browser/ui/webui/theme_source.h" |
27 #include "chrome/common/render_messages.h" | 29 #include "chrome/common/render_messages.h" |
30 #include "components/favicon/core/fallback_icon_service.h" | |
31 #include "components/favicon/core/favicon_service.h" | |
28 #include "components/history/core/browser/top_sites.h" | 32 #include "components/history/core/browser/top_sites.h" |
33 #include "components/keyed_service/core/service_access_type.h" | |
29 #include "components/search_engines/template_url_service.h" | 34 #include "components/search_engines/template_url_service.h" |
30 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
32 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
33 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
34 #include "content/public/browser/url_data_source.h" | 39 #include "content/public/browser/url_data_source.h" |
35 #include "grit/theme_resources.h" | 40 #include "grit/theme_resources.h" |
36 #include "third_party/skia/include/core/SkColor.h" | 41 #include "third_party/skia/include/core/SkColor.h" |
37 #include "ui/gfx/color_utils.h" | 42 #include "ui/gfx/color_utils.h" |
38 #include "ui/gfx/image/image_skia.h" | 43 #include "ui/gfx/image/image_skia.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 124 |
120 // TODO(aurimas) remove this #if once instant_service.cc is no longer compiled | 125 // TODO(aurimas) remove this #if once instant_service.cc is no longer compiled |
121 // on Android. | 126 // on Android. |
122 #if !defined(OS_ANDROID) | 127 #if !defined(OS_ANDROID) |
123 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); | 128 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); |
124 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); | 129 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); |
125 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); | 130 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); |
126 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); | 131 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); |
127 #endif // !defined(OS_ANDROID) | 132 #endif // !defined(OS_ANDROID) |
128 | 133 |
129 content::URLDataSource::Add(profile_, new LargeIconSource(profile)); | 134 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
130 content::URLDataSource::Add(profile_, new FallbackIconSource()); | 135 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
136 FallbackIconService* fallback_icon_service = | |
137 FallbackIconServiceFactory::GetForProfile( | |
138 profile_, ServiceAccessType::EXPLICIT_ACCESS); | |
139 | |
140 if (favicon_service && fallback_icon_service) { | |
141 content::URLDataSource::Add(profile_, | |
142 new LargeIconSource(favicon_service, fallback_icon_service)); | |
143 } | |
144 if (fallback_icon_service) { | |
145 content::URLDataSource::Add(profile_, | |
146 new FallbackIconSource(fallback_icon_service)); | |
beaudoin
2015/03/26 12:53:55
I'm not super aware of the lifecycle of these diff
huangs
2015/03/26 18:26:06
I added these because favicon_service === nullptr
| |
147 } | |
131 content::URLDataSource::Add( | 148 content::URLDataSource::Add( |
132 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); | 149 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); |
133 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); | 150 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); |
134 content::URLDataSource::Add( | 151 content::URLDataSource::Add( |
135 profile_, new suggestions::SuggestionsSource(profile_)); | 152 profile_, new suggestions::SuggestionsSource(profile_)); |
136 } | 153 } |
137 | 154 |
138 InstantService::~InstantService() { | 155 InstantService::~InstantService() { |
139 if (template_url_service_) | 156 if (template_url_service_) |
140 template_url_service_->RemoveObserver(this); | 157 template_url_service_->RemoveObserver(this); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 } | 456 } |
440 | 457 |
441 void InstantService::ResetInstantSearchPrerenderer() { | 458 void InstantService::ResetInstantSearchPrerenderer() { |
442 if (!chrome::ShouldPrefetchSearchResults()) | 459 if (!chrome::ShouldPrefetchSearchResults()) |
443 return; | 460 return; |
444 | 461 |
445 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); | 462 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); |
446 instant_prerenderer_.reset( | 463 instant_prerenderer_.reset( |
447 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 464 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
448 } | 465 } |
OLD | NEW |