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

Side by Side 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: referrer + transition type 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser_instant_controller.h" 5 #include "chrome/browser/ui/browser_instant_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/infobars/infobar_service.h" 8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/instant_service.h" 10 #include "chrome/browser/search/instant_service.h"
11 #include "chrome/browser/search/instant_service_factory.h" 11 #include "chrome/browser/search/instant_service_factory.h"
12 #include "chrome/browser/search/search.h" 12 #include "chrome/browser/search/search.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/location_bar/location_bar.h" 15 #include "chrome/browser/ui/location_bar/location_bar.h"
16 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 16 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
17 #include "chrome/browser/ui/omnibox/omnibox_view.h" 17 #include "chrome/browser/ui/omnibox/omnibox_view.h"
18 #include "chrome/browser/ui/search/instant_search_prerenderer.h" 18 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
19 #include "chrome/browser/ui/search/search_model.h" 19 #include "chrome/browser/ui/search/search_model.h"
20 #include "chrome/browser/ui/search/search_tab_helper.h" 20 #include "chrome/browser/ui/search/search_tab_helper.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/instant_types.h" 22 #include "chrome/common/instant_types.h"
23 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
24 #include "content/public/browser/navigation_controller.h"
25 #include "content/public/browser/navigation_entry.h"
kmadhusu 2015/02/19 21:38:46 Do you need this include?
Mathieu 2015/02/19 21:45:40 Done.
24 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/user_metrics.h" 27 #include "content/public/browser/user_metrics.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 29 #include "content/public/common/referrer.h"
28 30
29 // Helpers -------------------------------------------------------------------- 31 // Helpers --------------------------------------------------------------------
30 32
31 namespace { 33 namespace {
32 34
33 InstantSearchPrerenderer* GetInstantSearchPrerenderer(Profile* profile) { 35 InstantSearchPrerenderer* GetInstantSearchPrerenderer(Profile* profile) {
34 DCHECK(profile); 36 DCHECK(profile);
35 InstantService* instant_service = 37 InstantService* instant_service =
36 InstantServiceFactory::GetForProfile(profile); 38 InstantServiceFactory::GetForProfile(profile);
37 return instant_service ? instant_service->instant_search_prerenderer() : NULL; 39 return instant_service ? instant_service->instant_search_prerenderer() : NULL;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 else if (new_mode.is_ntp()) 135 else if (new_mode.is_ntp())
134 content::RecordAction(base::UserMetricsAction("InstantExtended.ShowNTP")); 136 content::RecordAction(base::UserMetricsAction("InstantExtended.ShowNTP"));
135 137
136 instant_.SearchModeChanged(old_state.mode, new_mode); 138 instant_.SearchModeChanged(old_state.mode, new_mode);
137 } 139 }
138 140
139 if (old_state.instant_support != new_state.instant_support) 141 if (old_state.instant_support != new_state.instant_support)
140 instant_.InstantSupportChanged(new_state.instant_support); 142 instant_.InstantSupportChanged(new_state.instant_support);
141 } 143 }
142 144
143 void BrowserInstantController::DefaultSearchProviderChanged() { 145 void BrowserInstantController::DefaultSearchProviderChanged(
146 bool google_base_url_domain_changed) {
144 InstantService* instant_service = 147 InstantService* instant_service =
145 InstantServiceFactory::GetForProfile(profile()); 148 InstantServiceFactory::GetForProfile(profile());
146 if (!instant_service) 149 if (!instant_service)
147 return; 150 return;
148 151
149 TabStripModel* tab_model = browser_->tab_strip_model(); 152 TabStripModel* tab_model = browser_->tab_strip_model();
150 int count = tab_model->count(); 153 int count = tab_model->count();
151 for (int index = 0; index < count; ++index) { 154 for (int index = 0; index < count; ++index) {
152 content::WebContents* contents = tab_model->GetWebContentsAt(index); 155 content::WebContents* contents = tab_model->GetWebContentsAt(index);
153 if (!contents) 156 if (!contents)
154 continue; 157 continue;
155 158
156 // Send new search URLs to the renderer. 159 // Send new search URLs to the renderer.
157 content::RenderProcessHost* rph = contents->GetRenderProcessHost(); 160 content::RenderProcessHost* rph = contents->GetRenderProcessHost();
158 instant_service->SendSearchURLsToRenderer(rph); 161 instant_service->SendSearchURLsToRenderer(rph);
159 162
160 // Reload the contents to ensure that it gets assigned to a non-priviledged
161 // renderer.
162 if (!instant_service->IsInstantProcess(rph->GetID())) 163 if (!instant_service->IsInstantProcess(rph->GetID()))
163 continue; 164 continue;
164 165
165 contents->GetController().Reload(false); 166 if (google_base_url_domain_changed &&
167 SearchTabHelper::FromWebContents(contents)->model()->mode().is_ntp()) {
168 // Replace the server NTP with the local NTP.
169 content::NavigationController::LoadURLParams
170 params(chrome::GetLocalInstantURL(profile()));
171 params.should_replace_current_entry = true;
172 params.referrer = content::Referrer();
173 params.transition_type = ui::PAGE_TRANSITION_RELOAD;
kmadhusu 2015/02/19 21:38:46 nit: Include "ui/base/page_transition_types.h" hea
Mathieu 2015/02/19 21:45:40 Done.
174 contents->GetController().LoadURLWithParams(params);
175 } else {
176 // Reload the contents to ensure that it gets assigned to a
177 // non-priviledged renderer.
178 contents->GetController().Reload(false);
166 179
167 // As the reload was not triggered by the user we don't want to close any 180 // As the reload was not triggered by the user we don't want to close any
168 // infobars. We have to tell the InfoBarService after the reload, otherwise 181 // infobars. We have to tell the InfoBarService after the reload,
169 // it would ignore this call when 182 // otherwise it would ignore this call when
170 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked. 183 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked.
171 InfoBarService::FromWebContents(contents)->set_ignore_next_reload(); 184 InfoBarService::FromWebContents(contents)->set_ignore_next_reload();
185 }
172 } 186 }
173 } 187 }
OLDNEW
« 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