Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | |
| 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 Loading... | |
| 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 const GURL local_ntp_url = GURL(chrome::kChromeSearchLocalNtpUrl); | |
| 170 content::NavigationController::LoadURLParams params(local_ntp_url); | |
|
kmadhusu
2015/02/19 19:55:12
nit: content::NavigationController::LoadURLParams
Mathieu
2015/02/19 20:19:18
Done.
| |
| 171 params.should_replace_current_entry = true; | |
|
kmadhusu
2015/02/19 19:55:12
I think you need to override params.transition and
Mathieu
2015/02/19 20:19:18
Done with referrer. Also changed to RELOAD because
Peter Kasting
2015/02/19 21:26:34
SGTM
| |
| 172 contents->GetController().LoadURLWithParams(params); | |
| 173 } else { | |
| 174 // Reload the contents to ensure that it gets assigned to a | |
| 175 // non-priviledged renderer. | |
| 176 contents->GetController().Reload(false); | |
| 166 | 177 |
| 167 // As the reload was not triggered by the user we don't want to close any | 178 // 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 | 179 // infobars. We have to tell the InfoBarService after the reload, |
| 169 // it would ignore this call when | 180 // otherwise it would ignore this call when |
| 170 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked. | 181 // WebContentsObserver::DidStartNavigationToPendingEntry is invoked. |
| 171 InfoBarService::FromWebContents(contents)->set_ignore_next_reload(); | 182 InfoBarService::FromWebContents(contents)->set_ignore_next_reload(); |
| 183 } | |
| 172 } | 184 } |
| 173 } | 185 } |
| OLD | NEW |