| 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/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 | 251 |
| 252 void SearchTabHelper::Submit(const base::string16& text, | 252 void SearchTabHelper::Submit(const base::string16& text, |
| 253 const EmbeddedSearchRequestParams& params) { | 253 const EmbeddedSearchRequestParams& params) { |
| 254 ipc_router_.Submit(text, params); | 254 ipc_router_.Submit(text, params); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void SearchTabHelper::OnTabActivated() { | 257 void SearchTabHelper::OnTabActivated() { |
| 258 ipc_router_.OnTabActivated(); | 258 ipc_router_.OnTabActivated(); |
| 259 | 259 |
| 260 if (search::IsInstantNTP(web_contents_)) { |
| 261 // Force creation of NTPUserDataLogger, if we loaded an NTP. The |
| 262 // NTPUserDataLogger tries to detect whether the NTP is being created at |
| 263 // startup or from the user opening a new tab, and if we wait until later, |
| 264 // it won't correctly detect this case. |
| 265 NTPUserDataLogger::GetOrCreateFromWebContents(web_contents_); |
| 266 } |
| 267 |
| 260 OmniboxView* omnibox_view = GetOmniboxView(); | 268 OmniboxView* omnibox_view = GetOmniboxView(); |
| 261 if (search::ShouldPrerenderInstantUrlOnOmniboxFocus() && | 269 if (search::ShouldPrerenderInstantUrlOnOmniboxFocus() && |
| 262 omnibox_has_focus_fn_(omnibox_view)) { | 270 omnibox_has_focus_fn_(omnibox_view)) { |
| 263 InstantSearchPrerenderer* prerenderer = | 271 InstantSearchPrerenderer* prerenderer = |
| 264 InstantSearchPrerenderer::GetForProfile(profile()); | 272 InstantSearchPrerenderer::GetForProfile(profile()); |
| 265 if (prerenderer && !IsSearchResultsPage()) { | 273 if (prerenderer && !IsSearchResultsPage()) { |
| 266 prerenderer->Init( | 274 prerenderer->Init( |
| 267 web_contents_->GetController().GetDefaultSessionStorageNamespace(), | 275 web_contents_->GetController().GetDefaultSessionStorageNamespace(), |
| 268 web_contents_->GetContainerBounds().size()); | 276 web_contents_->GetContainerBounds().size()); |
| 269 } | 277 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 568 |
| 561 bool SearchTabHelper::IsInputInProgress() const { | 569 bool SearchTabHelper::IsInputInProgress() const { |
| 562 OmniboxView* omnibox = GetOmniboxView(); | 570 OmniboxView* omnibox = GetOmniboxView(); |
| 563 return !model_.mode().is_ntp() && omnibox && | 571 return !model_.mode().is_ntp() && omnibox && |
| 564 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 572 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 565 } | 573 } |
| 566 | 574 |
| 567 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 575 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 568 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 576 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 569 } | 577 } |
| OLD | NEW |