| 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..49a8677ee8151353f3e7fd4807d733b4c4f1a943 100644
|
| --- a/chrome/browser/search/instant_service.cc
|
| +++ b/chrome/browser/search/instant_service.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <vector>
|
|
|
| +#include "base/bind.h"
|
| #include "base/logging.h"
|
| #include "base/prefs/pref_service.h"
|
| #include "base/strings/string_number_conversions.h"
|
| @@ -47,7 +48,6 @@
|
| #include "ui/gfx/color_utils.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "ui/gfx/sys_color_change_listener.h"
|
| -#include "url/gurl.h"
|
|
|
| using content::BrowserThread;
|
|
|
| @@ -70,11 +70,18 @@ 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_)) {
|
| // 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(this);
|
| +
|
| ResetInstantSearchPrerenderer();
|
|
|
| registrar_.Add(this,
|
| @@ -126,12 +133,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()));
|
| }
|
| @@ -429,9 +430,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 +441,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 +459,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();
|
| + }
|
| }
|
|
|