Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Unified Diff: chrome/browser/ui/search/instant_ntp_prerenderer.cc

Issue 20388003: Reload Instant NTP and Instant-process tabs on search url change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ui and unit tests Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698