| 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/history/top_sites.h" | 8 #include "chrome/browser/history/top_sites.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/instant_io_context.h" | 10 #include "chrome/browser/search/instant_io_context.h" |
| 11 #include "chrome/browser/search/instant_service_observer.h" | 11 #include "chrome/browser/search/instant_service_observer.h" |
| 12 #include "chrome/browser/search/local_ntp_source.h" | |
| 13 #include "chrome/browser/search/most_visited_iframe_source.h" | 12 #include "chrome/browser/search/most_visited_iframe_source.h" |
| 14 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
| 15 #include "chrome/browser/search/suggestions/suggestions_source.h" | 14 #include "chrome/browser/search/suggestions/suggestions_source.h" |
| 16 #include "chrome/browser/search_engines/template_url_service_factory.h" | 15 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 17 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 16 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 18 #include "chrome/browser/themes/theme_properties.h" | 17 #include "chrome/browser/themes/theme_properties.h" |
| 19 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
| 20 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
| 21 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 20 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
| 22 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 21 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 23 #include "chrome/browser/ui/webui/favicon_source.h" | 22 #include "chrome/browser/ui/webui/favicon_source.h" |
| 24 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 23 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 25 #include "chrome/browser/ui/webui/theme_source.h" | 24 #include "chrome/browser/ui/webui/theme_source.h" |
| 26 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
| 27 #include "components/search_engines/template_url_service.h" | 26 #include "components/search_engines/template_url_service.h" |
| 28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
| 31 #include "content/public/browser/render_process_host.h" | 30 #include "content/public/browser/render_process_host.h" |
| 32 #include "content/public/browser/url_data_source.h" | 31 #include "content/public/browser/url_data_source.h" |
| 33 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
| 34 #include "third_party/skia/include/core/SkColor.h" | 33 #include "third_party/skia/include/core/SkColor.h" |
| 35 #include "ui/gfx/color_utils.h" | 34 #include "ui/gfx/color_utils.h" |
| 36 #include "ui/gfx/image/image_skia.h" | 35 #include "ui/gfx/image/image_skia.h" |
| 37 #include "ui/gfx/sys_color_change_listener.h" | 36 #include "ui/gfx/sys_color_change_listener.h" |
| 38 | 37 |
| 38 #if !defined(OS_ANDROID) |
| 39 #include "chrome/browser/search/local_ntp_source.h" |
| 40 #endif |
| 39 | 41 |
| 40 namespace { | 42 namespace { |
| 41 | 43 |
| 42 const int kSectionBorderAlphaTransparency = 80; | 44 const int kSectionBorderAlphaTransparency = 80; |
| 43 | 45 |
| 44 // Converts SkColor to RGBAColor | 46 // Converts SkColor to RGBAColor |
| 45 RGBAColor SkColorToRGBAColor(const SkColor& sKColor) { | 47 RGBAColor SkColorToRGBAColor(const SkColor& sKColor) { |
| 46 RGBAColor color; | 48 RGBAColor color; |
| 47 color.r = SkColorGetR(sKColor); | 49 color.r = SkColorGetR(sKColor); |
| 48 color.g = SkColorGetG(sKColor); | 50 color.g = SkColorGetG(sKColor); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 112 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 111 content::Source<ThemeService>( | 113 content::Source<ThemeService>( |
| 112 ThemeServiceFactory::GetForProfile(profile_))); | 114 ThemeServiceFactory::GetForProfile(profile_))); |
| 113 | 115 |
| 114 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); | 116 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); |
| 115 #endif // defined(ENABLE_THEMES) | 117 #endif // defined(ENABLE_THEMES) |
| 116 | 118 |
| 117 // TODO(aurimas) remove this #if once instant_service.cc is no longer compiled | 119 // TODO(aurimas) remove this #if once instant_service.cc is no longer compiled |
| 118 // on Android. | 120 // on Android. |
| 119 #if !defined(OS_ANDROID) | 121 #if !defined(OS_ANDROID) |
| 122 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); |
| 120 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); | 123 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); |
| 121 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); | 124 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); |
| 122 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); | 125 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); |
| 123 #endif // !defined(OS_ANDROID) | 126 #endif // !defined(OS_ANDROID) |
| 124 | 127 |
| 125 content::URLDataSource::Add( | 128 content::URLDataSource::Add( |
| 126 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); | 129 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); |
| 127 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); | |
| 128 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); | 130 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); |
| 129 content::URLDataSource::Add( | 131 content::URLDataSource::Add( |
| 130 profile_, new suggestions::SuggestionsSource(profile_)); | 132 profile_, new suggestions::SuggestionsSource(profile_)); |
| 131 } | 133 } |
| 132 | 134 |
| 133 InstantService::~InstantService() { | 135 InstantService::~InstantService() { |
| 134 if (template_url_service_) | 136 if (template_url_service_) |
| 135 template_url_service_->RemoveObserver(this); | 137 template_url_service_->RemoveObserver(this); |
| 136 } | 138 } |
| 137 | 139 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 424 } |
| 423 | 425 |
| 424 void InstantService::ResetInstantSearchPrerenderer() { | 426 void InstantService::ResetInstantSearchPrerenderer() { |
| 425 if (!chrome::ShouldPrefetchSearchResults()) | 427 if (!chrome::ShouldPrefetchSearchResults()) |
| 426 return; | 428 return; |
| 427 | 429 |
| 428 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); | 430 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); |
| 429 instant_prerenderer_.reset( | 431 instant_prerenderer_.reset( |
| 430 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 432 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
| 431 } | 433 } |
| OLD | NEW |