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

Unified Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 930853005: [Instant] Default Search Provider change redirects to local NTP in some cases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: includes Created 5 years, 10 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/browser_instant_controller.cc
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index c579176157be92fd3cc0490a7f7c3ef1aeb52f6f..c4871ef162c7cbfbd3767f5faedf01075bd77aa5 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -21,10 +21,12 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/instant_types.h"
#include "chrome/common/url_constants.h"
+#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
-
+#include "content/public/common/referrer.h"
+#include "ui/base/page_transition_types.h"
// Helpers --------------------------------------------------------------------
@@ -140,7 +142,8 @@ void BrowserInstantController::ModelChanged(
instant_.InstantSupportChanged(new_state.instant_support);
}
-void BrowserInstantController::DefaultSearchProviderChanged() {
+void BrowserInstantController::DefaultSearchProviderChanged(
+ bool google_base_url_domain_changed) {
InstantService* instant_service =
InstantServiceFactory::GetForProfile(profile());
if (!instant_service)
@@ -157,17 +160,28 @@ void BrowserInstantController::DefaultSearchProviderChanged() {
content::RenderProcessHost* rph = contents->GetRenderProcessHost();
instant_service->SendSearchURLsToRenderer(rph);
- // Reload the contents to ensure that it gets assigned to a non-priviledged
- // renderer.
if (!instant_service->IsInstantProcess(rph->GetID()))
continue;
- contents->GetController().Reload(false);
-
- // As the reload was not triggered by the user we don't want to close any
- // infobars. We have to tell the InfoBarService after the reload, otherwise
- // it would ignore this call when
- // WebContentsObserver::DidStartNavigationToPendingEntry is invoked.
- InfoBarService::FromWebContents(contents)->set_ignore_next_reload();
+ if (google_base_url_domain_changed &&
+ SearchTabHelper::FromWebContents(contents)->model()->mode().is_ntp()) {
+ // Replace the server NTP with the local NTP.
+ content::NavigationController::LoadURLParams
+ params(chrome::GetLocalInstantURL(profile()));
+ params.should_replace_current_entry = true;
+ params.referrer = content::Referrer();
+ params.transition_type = ui::PAGE_TRANSITION_RELOAD;
+ contents->GetController().LoadURLWithParams(params);
+ } else {
+ // Reload the contents to ensure that it gets assigned to a
+ // non-priviledged renderer.
+ contents->GetController().Reload(false);
+
+ // As the reload was not triggered by the user we don't want to close any
+ // infobars. We have to tell the InfoBarService after the reload,
+ // otherwise it would ignore this call when
+ // WebContentsObserver::DidStartNavigationToPendingEntry is invoked.
+ InfoBarService::FromWebContents(contents)->set_ignore_next_reload();
+ }
}
}
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/browser/ui/browser_instant_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698