| 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" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search/instant_service.h" | 15 #include "chrome/browser/search/instant_service.h" |
| 16 #include "chrome/browser/search/instant_service_factory.h" | 16 #include "chrome/browser/search/instant_service_factory.h" |
| 17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 18 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
| 20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 21 #include "chrome/browser/ui/app_list/app_list_util.h" | 21 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 22 #include "chrome/browser/ui/browser_navigator.h" | 22 #include "chrome/browser/ui/browser_navigator.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/location_bar/location_bar.h" | 24 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 25 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 25 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
| 26 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 26 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 27 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 27 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 28 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 28 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 29 #include "chrome/browser/ui/search/instant_tab.h" |
| 29 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" | 30 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" |
| 30 #include "chrome/browser/ui/search/search_tab_helper_delegate.h" | 31 #include "chrome/browser/ui/search/search_tab_helper_delegate.h" |
| 31 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 32 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 32 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" | 33 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" |
| 33 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/grit/generated_resources.h" | 35 #include "chrome/grit/generated_resources.h" |
| 35 #include "components/google/core/browser/google_util.h" | 36 #include "components/google/core/browser/google_util.h" |
| 36 #include "components/search/search.h" | 37 #include "components/search/search.h" |
| 37 #include "components/signin/core/browser/signin_manager.h" | 38 #include "components/signin/core/browser/signin_manager.h" |
| 38 #include "content/public/browser/navigation_controller.h" | 39 #include "content/public/browser/navigation_controller.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 void SearchTabHelper::OnSetVoiceSearchSupport(bool supports_voice_search) { | 395 void SearchTabHelper::OnSetVoiceSearchSupport(bool supports_voice_search) { |
| 395 model_.SetVoiceSearchSupported(supports_voice_search); | 396 model_.SetVoiceSearchSupported(supports_voice_search); |
| 396 } | 397 } |
| 397 | 398 |
| 398 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { | 399 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { |
| 399 ipc_router_.SendThemeBackgroundInfo(theme_info); | 400 ipc_router_.SendThemeBackgroundInfo(theme_info); |
| 400 } | 401 } |
| 401 | 402 |
| 402 void SearchTabHelper::MostVisitedItemsChanged( | 403 void SearchTabHelper::MostVisitedItemsChanged( |
| 403 const std::vector<InstantMostVisitedItem>& items) { | 404 const std::vector<InstantMostVisitedItem>& items) { |
| 405 InstantTab::EmitNtpStatistics(web_contents_); |
| 404 ipc_router_.SendMostVisitedItems(items); | 406 ipc_router_.SendMostVisitedItems(items); |
| 405 } | 407 } |
| 406 | 408 |
| 407 void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) { | 409 void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) { |
| 408 ipc_router_.SetOmniboxStartMargin(omnibox_start_margin); | 410 ipc_router_.SetOmniboxStartMargin(omnibox_start_margin); |
| 409 } | 411 } |
| 410 | 412 |
| 411 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { | 413 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { |
| 412 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. | 414 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. |
| 413 #if !defined(OS_ANDROID) | 415 #if !defined(OS_ANDROID) |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 592 |
| 591 bool SearchTabHelper::IsInputInProgress() const { | 593 bool SearchTabHelper::IsInputInProgress() const { |
| 592 OmniboxView* omnibox = GetOmniboxView(); | 594 OmniboxView* omnibox = GetOmniboxView(); |
| 593 return !model_.mode().is_ntp() && omnibox && | 595 return !model_.mode().is_ntp() && omnibox && |
| 594 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 596 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 595 } | 597 } |
| 596 | 598 |
| 597 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 599 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 598 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 600 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 599 } | 601 } |
| OLD | NEW |