Chromium Code Reviews| Index: chrome/browser/ui/search/instant_ntp_prerenderer.cc |
| diff --git a/chrome/browser/ui/search/instant_ntp_prerenderer.cc b/chrome/browser/ui/search/instant_ntp_prerenderer.cc |
| index 7b336575cc2ba08a5b5e2e5833a7f7ed67ae5a4a..d59c7854399f7ee34778d776b70a0c697bbb3ce3 100644 |
| --- a/chrome/browser/ui/search/instant_ntp_prerenderer.cc |
| +++ b/chrome/browser/ui/search/instant_ntp_prerenderer.cc |
| @@ -55,11 +55,7 @@ InstantNTPPrerenderer::InstantNTPPrerenderer(Profile* profile, |
| profile_pref_registrar_.Init(prefs); |
| profile_pref_registrar_.Add( |
| prefs::kSearchSuggestEnabled, |
| - base::Bind(&InstantNTPPrerenderer::ReloadStaleNTP, |
| - base::Unretained(this))); |
| - profile_pref_registrar_.Add( |
| - prefs::kDefaultSearchProviderID, |
| - base::Bind(&InstantNTPPrerenderer::OnDefaultSearchProviderChanged, |
| + base::Bind(&InstantNTPPrerenderer::ReloadInstantNTP, |
| base::Unretained(this))); |
| } |
| net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
| @@ -69,10 +65,7 @@ InstantNTPPrerenderer::~InstantNTPPrerenderer() { |
| net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
| } |
| -void InstantNTPPrerenderer::PreloadInstantNTP() { |
| - DCHECK(!ntp()); |
| - ReloadStaleNTP(); |
| -} |
| +void InstantNTPPrerenderer::ReloadInstantNTP() { ResetNTP(GetInstantURL()); } |
|
samarth
2013/08/02 21:51:15
nit: please keep on its own line.
Anuj
2013/08/09 07:22:00
Done.
|
| scoped_ptr<content::WebContents> InstantNTPPrerenderer::ReleaseNTPContents() { |
| if (!extended_enabled() || !profile_ || profile_->IsOffTheRecord() || |
| @@ -245,31 +238,15 @@ void InstantNTPPrerenderer::InstantPageLoadFailed( |
| ResetNTP(GetLocalInstantURL()); |
| } |
| -void InstantNTPPrerenderer::OnDefaultSearchProviderChanged( |
| - const std::string& pref_name) { |
| - DCHECK_EQ(pref_name, std::string(prefs::kDefaultSearchProviderID)); |
| - if (!extended_enabled() || !ntp()) |
| - return; |
| - |
| - ResetNTP(GetInstantURL()); |
| -} |
| - |
| void InstantNTPPrerenderer::ResetNTP(const std::string& instant_url) { |
| // Instant NTP is only used in extended mode so we should always have a |
| // non-empty URL to use. |
| DCHECK(!instant_url.empty()); |
| ntp_.reset(new InstantNTP(this, instant_url, profile_)); |
| - ntp_->InitContents(base::Bind(&InstantNTPPrerenderer::ReloadStaleNTP, |
| + ntp_->InitContents(base::Bind(&InstantNTPPrerenderer::ReloadInstantNTP, |
| base::Unretained(this))); |
| } |
| -void InstantNTPPrerenderer::ReloadStaleNTP() { |
| - if (!extended_enabled()) |
| - return; |
| - |
| - ResetNTP(GetInstantURL()); |
| -} |
| - |
| bool InstantNTPPrerenderer::PageIsCurrent() const { |
| const std::string& instant_url = GetInstantURL(); |
| if (instant_url.empty() || |
| @@ -301,3 +278,12 @@ bool InstantNTPPrerenderer::ShouldSwitchToLocalNTP() const { |
| // (unless the finch flag to use the remote NTP is set). |
| return !(InStartup() && chrome::ShouldPreferRemoteNTPOnStartup()); |
| } |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// InstantNTPPrerenderer, InstantServiceObserver implementation: |
| + |
| +void InstantNTPPrerenderer::DefaultSearchProviderChanged() { |
| + ReloadInstantNTP(); |
| +} |
| + |
| +void InstantNTPPrerenderer::GoogleURLUpdated() { ReloadInstantNTP(); } |
|
samarth
2013/08/02 21:51:15
also here
Anuj
2013/08/09 07:22:00
Done.
|