| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 web_contents_->GetController().GetDefaultSessionStorageNamespace(), | 262 web_contents_->GetController().GetDefaultSessionStorageNamespace(), |
| 263 web_contents_->GetContainerBounds().size()); | 263 web_contents_->GetContainerBounds().size()); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 | 267 |
| 268 void SearchTabHelper::OnTabDeactivated() { | 268 void SearchTabHelper::OnTabDeactivated() { |
| 269 ipc_router_.OnTabDeactivated(); | 269 ipc_router_.OnTabDeactivated(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void SearchTabHelper::ToggleVoiceSearch() { | |
| 273 ipc_router_.ToggleVoiceSearch(); | |
| 274 } | |
| 275 | |
| 276 bool SearchTabHelper::IsSearchResultsPage() { | 272 bool SearchTabHelper::IsSearchResultsPage() { |
| 277 return model_.mode().is_origin_search(); | 273 return model_.mode().is_origin_search(); |
| 278 } | 274 } |
| 279 | 275 |
| 280 void SearchTabHelper::RenderViewCreated( | 276 void SearchTabHelper::RenderViewCreated( |
| 281 content::RenderViewHost* render_view_host) { | 277 content::RenderViewHost* render_view_host) { |
| 282 ipc_router_.SetPromoInformation(IsAppLauncherEnabled()); | 278 ipc_router_.SetPromoInformation(IsAppLauncherEnabled()); |
| 283 } | 279 } |
| 284 | 280 |
| 285 void SearchTabHelper::DidStartNavigationToPendingEntry( | 281 void SearchTabHelper::DidStartNavigationToPendingEntry( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // the previous entry. If the page does not support Instant, update the | 360 // the previous entry. If the page does not support Instant, update the |
| 365 // location bar from here to turn off search terms replacement. | 361 // location bar from here to turn off search terms replacement. |
| 366 search::SetInstantSupportStateInNavigationEntry(model_.instant_support(), | 362 search::SetInstantSupportStateInNavigationEntry(model_.instant_support(), |
| 367 entry); | 363 entry); |
| 368 if (delegate_ && model_.instant_support() == INSTANT_SUPPORT_NO) | 364 if (delegate_ && model_.instant_support() == INSTANT_SUPPORT_NO) |
| 369 delegate_->OnWebContentsInstantSupportDisabled(web_contents_); | 365 delegate_->OnWebContentsInstantSupportDisabled(web_contents_); |
| 370 return; | 366 return; |
| 371 } | 367 } |
| 372 | 368 |
| 373 model_.SetInstantSupportState(INSTANT_SUPPORT_UNKNOWN); | 369 model_.SetInstantSupportState(INSTANT_SUPPORT_UNKNOWN); |
| 374 model_.SetVoiceSearchSupported(false); | |
| 375 search::SetInstantSupportStateInNavigationEntry(model_.instant_support(), | 370 search::SetInstantSupportStateInNavigationEntry(model_.instant_support(), |
| 376 entry); | 371 entry); |
| 377 | 372 |
| 378 if (InInstantProcess(profile(), web_contents_)) | 373 if (InInstantProcess(profile(), web_contents_)) |
| 379 ipc_router_.OnNavigationEntryCommitted(); | 374 ipc_router_.OnNavigationEntryCommitted(); |
| 380 } | 375 } |
| 381 | 376 |
| 382 void SearchTabHelper::OnInstantSupportDetermined(bool supports_instant) { | 377 void SearchTabHelper::OnInstantSupportDetermined(bool supports_instant) { |
| 383 InstantSupportChanged(supports_instant); | 378 InstantSupportChanged(supports_instant); |
| 384 } | 379 } |
| 385 | 380 |
| 386 void SearchTabHelper::OnSetVoiceSearchSupport(bool supports_voice_search) { | |
| 387 model_.SetVoiceSearchSupported(supports_voice_search); | |
| 388 } | |
| 389 | |
| 390 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { | 381 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { |
| 391 ipc_router_.SendThemeBackgroundInfo(theme_info); | 382 ipc_router_.SendThemeBackgroundInfo(theme_info); |
| 392 } | 383 } |
| 393 | 384 |
| 394 void SearchTabHelper::MostVisitedItemsChanged( | 385 void SearchTabHelper::MostVisitedItemsChanged( |
| 395 const std::vector<InstantMostVisitedItem>& items) { | 386 const std::vector<InstantMostVisitedItem>& items) { |
| 396 // When most visited change, the NTP usually reloads the tiles. This means | 387 // When most visited change, the NTP usually reloads the tiles. This means |
| 397 // our metrics get inconsistent. So we'd rather emit stats now. | 388 // our metrics get inconsistent. So we'd rather emit stats now. |
| 398 InstantTab::EmitNtpStatistics(web_contents_); | 389 InstantTab::EmitNtpStatistics(web_contents_); |
| 399 ipc_router_.SendMostVisitedItems(items); | 390 ipc_router_.SendMostVisitedItems(items); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 578 |
| 588 bool SearchTabHelper::IsInputInProgress() const { | 579 bool SearchTabHelper::IsInputInProgress() const { |
| 589 OmniboxView* omnibox = GetOmniboxView(); | 580 OmniboxView* omnibox = GetOmniboxView(); |
| 590 return !model_.mode().is_ntp() && omnibox && | 581 return !model_.mode().is_ntp() && omnibox && |
| 591 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 582 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 592 } | 583 } |
| 593 | 584 |
| 594 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 585 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 595 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 586 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 596 } | 587 } |
| OLD | NEW |