| 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_engines/template_url.h" | 23 #include "chrome/browser/search_engines/template_url.h" |
| 24 #include "chrome/browser/search_engines/template_url_service.h" | 24 #include "chrome/browser/search_engines/template_url_service.h" |
| 25 #include "chrome/browser/search_engines/template_url_service_factory.h" | 25 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 26 #include "chrome/browser/themes/theme_properties.h" | 26 #include "chrome/browser/themes/theme_properties.h" |
| 27 #include "chrome/browser/themes/theme_service.h" | 27 #include "chrome/browser/themes/theme_service.h" |
| 28 #include "chrome/browser/themes/theme_service_factory.h" | 28 #include "chrome/browser/themes/theme_service_factory.h" |
| 29 #include "chrome/browser/ui/webui/favicon_source.h" | 29 #include "chrome/browser/ui/webui/favicon_source.h" |
| 30 #include "chrome/browser/ui/webui/ntp/thumbnail_list_source.h" |
| 30 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 31 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 31 #include "chrome/browser/ui/webui/theme_source.h" | 32 #include "chrome/browser/ui/webui/theme_source.h" |
| 32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
| 34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/notification_details.h" | 36 #include "content/public/browser/notification_details.h" |
| 36 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
| 38 #include "content/public/browser/notification_types.h" | 39 #include "content/public/browser/notification_types.h" |
| 39 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Set up the data sources that Instant uses on the NTP. | 99 // Set up the data sources that Instant uses on the NTP. |
| 99 #if defined(ENABLE_THEMES) | 100 #if defined(ENABLE_THEMES) |
| 100 // Listen for theme installation. | 101 // Listen for theme installation. |
| 101 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 102 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 102 content::Source<ThemeService>( | 103 content::Source<ThemeService>( |
| 103 ThemeServiceFactory::GetForProfile(profile_))); | 104 ThemeServiceFactory::GetForProfile(profile_))); |
| 104 | 105 |
| 105 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); | 106 content::URLDataSource::Add(profile_, new ThemeSource(profile_)); |
| 106 #endif // defined(ENABLE_THEMES) | 107 #endif // defined(ENABLE_THEMES) |
| 107 | 108 |
| 108 | |
| 109 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); | 109 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, false)); |
| 110 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); | 110 content::URLDataSource::Add(profile_, new ThumbnailSource(profile_, true)); |
| 111 content::URLDataSource::Add(profile_, new ThumbnailListSource(profile_)); |
| 111 content::URLDataSource::Add( | 112 content::URLDataSource::Add( |
| 112 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); | 113 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); |
| 113 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); | 114 content::URLDataSource::Add(profile_, new LocalNtpSource(profile_)); |
| 114 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); | 115 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); |
| 115 | 116 |
| 116 profile_pref_registrar_.Init(profile_->GetPrefs()); | 117 profile_pref_registrar_.Init(profile_->GetPrefs()); |
| 117 profile_pref_registrar_.Add( | 118 profile_pref_registrar_.Add( |
| 118 prefs::kDefaultSearchProviderID, | 119 prefs::kDefaultSearchProviderID, |
| 119 base::Bind(&InstantService::OnDefaultSearchProviderChanged, | 120 base::Bind(&InstantService::OnDefaultSearchProviderChanged, |
| 120 base::Unretained(this))); | 121 base::Unretained(this))); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // could cause that, neither of which we support. | 465 // could cause that, neither of which we support. |
| 465 return; | 466 return; |
| 466 } | 467 } |
| 467 FOR_EACH_OBSERVER( | 468 FOR_EACH_OBSERVER( |
| 468 InstantServiceObserver, observers_, DefaultSearchProviderChanged()); | 469 InstantServiceObserver, observers_, DefaultSearchProviderChanged()); |
| 469 } | 470 } |
| 470 | 471 |
| 471 InstantNTPPrerenderer* InstantService::ntp_prerenderer() { | 472 InstantNTPPrerenderer* InstantService::ntp_prerenderer() { |
| 472 return &ntp_prerenderer_; | 473 return &ntp_prerenderer_; |
| 473 } | 474 } |
| OLD | NEW |