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/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/history/most_visited_tiles_experiment.h" | |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search/instant_service.h" | 15 #include "chrome/browser/search/instant_service.h" |
| 17 #include "chrome/browser/search/instant_service_factory.h" | 16 #include "chrome/browser/search/instant_service_factory.h" |
| 18 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 19 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 20 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
| 21 #include "chrome/browser/sync/profile_sync_service_factory.h" | 20 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 22 #include "chrome/browser/ui/app_list/app_list_util.h" | 21 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 23 #include "chrome/browser/ui/browser_navigator.h" | 22 #include "chrome/browser/ui/browser_navigator.h" |
| 24 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 void SearchTabHelper::OnSetVoiceSearchSupport(bool supports_voice_search) { | 411 void SearchTabHelper::OnSetVoiceSearchSupport(bool supports_voice_search) { |
| 413 model_.SetVoiceSearchSupported(supports_voice_search); | 412 model_.SetVoiceSearchSupported(supports_voice_search); |
| 414 } | 413 } |
| 415 | 414 |
| 416 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { | 415 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { |
| 417 ipc_router_.SendThemeBackgroundInfo(theme_info); | 416 ipc_router_.SendThemeBackgroundInfo(theme_info); |
| 418 } | 417 } |
| 419 | 418 |
| 420 void SearchTabHelper::MostVisitedItemsChanged( | 419 void SearchTabHelper::MostVisitedItemsChanged( |
| 421 const std::vector<InstantMostVisitedItem>& items) { | 420 const std::vector<InstantMostVisitedItem>& items) { |
| 422 std::vector<InstantMostVisitedItem> items_copy(items); | 421 std::vector<InstantMostVisitedItem> items_copy(items); |
|
Jered
2014/08/01 15:34:19
I think you do not need to make a copy now.
Mathieu
2014/08/01 15:46:54
Done. silly me.
| |
| 423 MaybeRemoveMostVisitedItems(&items_copy); | |
| 424 ipc_router_.SendMostVisitedItems(items_copy); | 422 ipc_router_.SendMostVisitedItems(items_copy); |
| 425 } | 423 } |
| 426 | 424 |
| 427 void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) { | 425 void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) { |
| 428 ipc_router_.SetOmniboxStartMargin(omnibox_start_margin); | 426 ipc_router_.SetOmniboxStartMargin(omnibox_start_margin); |
| 429 } | 427 } |
| 430 | 428 |
| 431 void SearchTabHelper::MaybeRemoveMostVisitedItems( | |
| 432 std::vector<InstantMostVisitedItem>* items) { | |
| 433 if (!delegate_) | |
| 434 return; | |
| 435 | |
| 436 if (!history::MostVisitedTilesExperiment::IsDontShowOpenURLsEnabled()) | |
| 437 return; | |
| 438 | |
| 439 history::MostVisitedTilesExperiment::RemoveItemsMatchingOpenTabs( | |
| 440 delegate_->GetOpenUrls(), items); | |
| 441 } | |
| 442 | |
| 443 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { | 429 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { |
| 444 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. | 430 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. |
| 445 #if !defined(OS_ANDROID) | 431 #if !defined(OS_ANDROID) |
| 446 OmniboxView* omnibox = GetOmniboxView(); | 432 OmniboxView* omnibox = GetOmniboxView(); |
| 447 if (!omnibox) | 433 if (!omnibox) |
| 448 return; | 434 return; |
| 449 | 435 |
| 450 // Do not add a default case in the switch block for the following reasons: | 436 // Do not add a default case in the switch block for the following reasons: |
| 451 // (1) Explicitly handle the new states. If new states are added in the | 437 // (1) Explicitly handle the new states. If new states are added in the |
| 452 // OmniboxFocusState, the compiler will warn the developer to handle the new | 438 // OmniboxFocusState, the compiler will warn the developer to handle the new |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 | 617 |
| 632 bool SearchTabHelper::IsInputInProgress() const { | 618 bool SearchTabHelper::IsInputInProgress() const { |
| 633 OmniboxView* omnibox = GetOmniboxView(); | 619 OmniboxView* omnibox = GetOmniboxView(); |
| 634 return !model_.mode().is_ntp() && omnibox && | 620 return !model_.mode().is_ntp() && omnibox && |
| 635 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 621 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 636 } | 622 } |
| 637 | 623 |
| 638 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 624 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 639 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 625 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 640 } | 626 } |
| OLD | NEW |