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

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: 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 7a4c131bd4d58e3b356e688defcf918717d0b66e..70d8056f19a5882910e8bb910a372dac410978b2 100644
--- a/chrome/browser/ui/search/instant_ntp_prerenderer.cc
+++ b/chrome/browser/ui/search/instant_ntp_prerenderer.cc
@@ -53,11 +53,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);
@@ -67,9 +63,9 @@ InstantNTPPrerenderer::~InstantNTPPrerenderer() {
net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
}
-void InstantNTPPrerenderer::PreloadInstantNTP() {
+void InstantNTPPrerenderer::ReloadInstantNTP() {
DCHECK(!ntp());
samarth 2013/07/26 23:33:15 Aren't you going to trigger this DCHECK when it is
Anuj 2013/07/31 07:16:18 Done.
- ReloadStaleNTP();
+ ResetNTP(GetInstantURL());
}
scoped_ptr<content::WebContents> InstantNTPPrerenderer::ReleaseNTPContents() {
@@ -226,31 +222,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() ||
@@ -282,3 +262,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(); }

Powered by Google App Engine
This is Rietveld 408576698