| Index: chrome/browser/search/instant_service.cc
|
| diff --git a/chrome/browser/search/instant_service.cc b/chrome/browser/search/instant_service.cc
|
| index db35dd1dde93270be835ef9abac6cd8852c7a72a..583ece345b577e95d015aa55c0fbad29deb54c6e 100644
|
| --- a/chrome/browser/search/instant_service.cc
|
| +++ b/chrome/browser/search/instant_service.cc
|
| @@ -70,11 +70,19 @@ RGBAColor SkColorToRGBAColor(const SkColor& sKColor) {
|
| InstantService::InstantService(Profile* profile)
|
| : profile_(profile),
|
| omnibox_start_margin_(chrome::kDisableStartMargin),
|
| - weak_ptr_factory_(this) {
|
| + weak_ptr_factory_(this),
|
| + current_search_result_prefetch_base_url_(
|
| + chrome::GetSearchResultPrefetchBaseURL(profile_)),
|
| + default_search_engine_watcher_(this) {
|
| // Stub for unit tests.
|
| if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
|
| return;
|
|
|
| + TemplateURLService* template_url_service =
|
| + TemplateURLServiceFactory::GetForProfile(profile_);
|
| + if (template_url_service)
|
| + template_url_service->AddObserver(&default_search_engine_watcher_);
|
| +
|
| ResetInstantSearchPrerenderer();
|
|
|
| registrar_.Add(this,
|
| @@ -126,12 +134,6 @@ InstantService::InstantService(Profile* profile)
|
| profile_, new suggestions::SuggestionsSource(profile_));
|
| }
|
|
|
| - profile_pref_registrar_.Init(profile_->GetPrefs());
|
| - profile_pref_registrar_.Add(
|
| - prefs::kDefaultSearchProviderID,
|
| - base::Bind(&InstantService::OnDefaultSearchProviderChanged,
|
| - base::Unretained(this)));
|
| -
|
| registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED,
|
| content::Source<Profile>(profile_->GetOriginalProfile()));
|
| }
|
| @@ -200,6 +202,15 @@ void InstantService::UpdateMostVisitedItemsInfo() {
|
| NotifyAboutMostVisitedItems();
|
| }
|
|
|
| +InstantService::DefaultSearchEngineWatcher::DefaultSearchEngineWatcher(
|
| + InstantService* outer)
|
| + : outer_(outer) {
|
| +}
|
| +
|
| +void InstantService::DefaultSearchEngineWatcher::OnTemplateURLServiceChanged() {
|
| + outer_->OnTemplateURLServiceChanged();
|
| +}
|
| +
|
| void InstantService::Shutdown() {
|
| process_ids_.clear();
|
|
|
| @@ -429,9 +440,7 @@ void InstantService::OnGoogleURLUpdated(
|
| FOR_EACH_OBSERVER(InstantServiceObserver, observers_, GoogleURLUpdated());
|
| }
|
|
|
| -void InstantService::OnDefaultSearchProviderChanged(
|
| - const std::string& pref_name) {
|
| - DCHECK_EQ(pref_name, std::string(prefs::kDefaultSearchProviderID));
|
| +void InstantService::OnTemplateURLServiceChanged() {
|
| const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile(
|
| profile_)->GetDefaultSearchProvider();
|
| if (!template_url) {
|
| @@ -442,6 +451,13 @@ void InstantService::OnDefaultSearchProviderChanged(
|
| // could cause that, neither of which we support.
|
| return;
|
| }
|
| + GURL new_search_result_prefetch_base_url(
|
| + chrome::GetSearchResultPrefetchBaseURL(profile_));
|
| + if (new_search_result_prefetch_base_url ==
|
| + current_search_result_prefetch_base_url_)
|
| + return;
|
| + current_search_result_prefetch_base_url_ =
|
| + new_search_result_prefetch_base_url;
|
|
|
| ResetInstantSearchPrerenderer();
|
|
|
| @@ -453,9 +469,10 @@ void InstantService::ResetInstantSearchPrerenderer() {
|
| if (!chrome::ShouldPrefetchSearchResults())
|
| return;
|
|
|
| - GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_));
|
| - if (url.is_valid())
|
| - instant_prerenderer_.reset(new InstantSearchPrerenderer(profile_, url));
|
| - else
|
| + if (current_search_result_prefetch_base_url_.is_valid()) {
|
| + instant_prerenderer_.reset(new InstantSearchPrerenderer(
|
| + profile_, current_search_result_prefetch_base_url_));
|
| + } else {
|
| instant_prerenderer_.reset();
|
| + }
|
| }
|
|
|