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