Chromium Code Reviews| 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/most_visited_iframe_source.h" | 12 #include "chrome/browser/search/most_visited_iframe_source.h" |
| 13 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
| 14 #include "chrome/browser/search/suggestions/suggestions_source.h" | 14 #include "chrome/browser/search/suggestions/suggestions_source.h" |
| 15 #include "chrome/browser/search_engines/template_url_service_factory.h" | 15 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 16 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 16 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 17 #include "chrome/browser/themes/theme_properties.h" | 17 #include "chrome/browser/themes/theme_properties.h" |
| 18 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
| 19 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
| 20 #include "chrome/browser/thumbnails/thumbnail_list_source.h" | 20 #include "chrome/browser/thumbnails/thumbnail_list_source.h" |
| 21 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 21 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 22 #include "chrome/browser/ui/search/new_tab_page_interceptor_service.h" | |
| 23 #include "chrome/browser/ui/search/new_tab_page_interceptor_service_factory.h" | |
| 22 #include "chrome/browser/ui/webui/favicon_source.h" | 24 #include "chrome/browser/ui/webui/favicon_source.h" |
| 23 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 25 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 24 #include "chrome/browser/ui/webui/theme_source.h" | 26 #include "chrome/browser/ui/webui/theme_source.h" |
| 25 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
| 26 #include "components/search_engines/template_url_service.h" | 28 #include "components/search_engines/template_url_service.h" |
| 27 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
| 30 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
| 31 #include "content/public/browser/url_data_source.h" | 33 #include "content/public/browser/url_data_source.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 previous_google_base_url_ = google_base_url; | 415 previous_google_base_url_ = google_base_url; |
| 414 if (template_url && template_url->HasGoogleBaseURLs( | 416 if (template_url && template_url->HasGoogleBaseURLs( |
| 415 UIThreadSearchTermsData(profile_))) | 417 UIThreadSearchTermsData(profile_))) |
| 416 default_search_provider_changed = true; | 418 default_search_provider_changed = true; |
| 417 } | 419 } |
| 418 | 420 |
| 419 if (default_search_provider_changed) { | 421 if (default_search_provider_changed) { |
| 420 ResetInstantSearchPrerenderer(); | 422 ResetInstantSearchPrerenderer(); |
| 421 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, | 423 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, |
| 422 DefaultSearchProviderChanged()); | 424 DefaultSearchProviderChanged()); |
| 425 | |
| 426 // Update the New Tab Page interceptor with the new URL. | |
| 427 NewTabPageInterceptorService* service = | |
| 428 NewTabPageInterceptorServiceFactory::GetForProfile(profile_); | |
| 429 if (service) { | |
| 430 GURL new_tab_page_url(chrome::GetNewTabPageURL(profile_)); | |
| 431 service->UpdateDefaultSearchProvider(new_tab_page_url); | |
| 432 } | |
|
mmenke
2015/01/15 22:35:30
Can't the service just sign up as an InstantServic
Mathieu
2015/01/15 22:42:09
I tried for a long time to make that work. It turn
mmenke
2015/01/15 23:22:21
Did you have all those "DCHECK_CURRENTLY_ON(conten
kmadhusu
2015/01/16 00:13:12
(Just curious) Did you get a chance to find the cu
mmenke
2015/01/16 17:54:04
Currently, the InstantService is created once prof
mmenke
2015/01/16 22:04:16
Shouldn't we just be watching the TemplateURLServi
Mathieu
2015/01/21 21:30:02
Newest patch does that, have a look.
| |
| 423 } | 433 } |
| 424 } | 434 } |
| 425 | 435 |
| 426 void InstantService::ResetInstantSearchPrerenderer() { | 436 void InstantService::ResetInstantSearchPrerenderer() { |
| 427 if (!chrome::ShouldPrefetchSearchResults()) | 437 if (!chrome::ShouldPrefetchSearchResults()) |
| 428 return; | 438 return; |
| 429 | 439 |
| 430 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); | 440 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); |
| 431 instant_prerenderer_.reset( | 441 instant_prerenderer_.reset( |
| 432 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 442 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
| 433 } | 443 } |
| OLD | NEW |