| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/search_controller.h" | 5 #include "ui/app_list/search_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 namespace app_list { | 29 namespace app_list { |
| 30 | 30 |
| 31 SearchController::SearchController(SearchBoxModel* search_box, | 31 SearchController::SearchController(SearchBoxModel* search_box, |
| 32 AppListModel::SearchResults* results, | 32 AppListModel::SearchResults* results, |
| 33 History* history) | 33 History* history) |
| 34 : search_box_(search_box), mixer_(new Mixer(results)), history_(history) {} | 34 : search_box_(search_box), mixer_(new Mixer(results)), history_(history) {} |
| 35 | 35 |
| 36 SearchController::~SearchController() { | 36 SearchController::~SearchController() { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void SearchController::Start(bool is_voice_query) { | 39 void SearchController::Start() { |
| 40 Stop(); | 40 Stop(); |
| 41 | 41 |
| 42 base::string16 query; | 42 base::string16 query; |
| 43 base::TrimWhitespace(search_box_->text(), base::TRIM_ALL, &query); | 43 base::TrimWhitespace(search_box_->text(), base::TRIM_ALL, &query); |
| 44 | 44 |
| 45 is_voice_query_ = search_box_->is_voice_query(); |
| 46 |
| 45 dispatching_query_ = true; | 47 dispatching_query_ = true; |
| 46 for (const auto& provider : providers_) | 48 for (const auto& provider : providers_) |
| 47 provider->Start(is_voice_query, query); | 49 provider->Start(is_voice_query_, query); |
| 48 | 50 |
| 49 dispatching_query_ = false; | 51 dispatching_query_ = false; |
| 50 query_for_recommendation_ = query.empty() ? true : false; | 52 query_for_recommendation_ = query.empty() ? true : false; |
| 51 | 53 |
| 52 is_voice_query_ = is_voice_query; | |
| 53 | |
| 54 OnResultsChanged(); | 54 OnResultsChanged(); |
| 55 | 55 |
| 56 stop_timer_.Start(FROM_HERE, | 56 stop_timer_.Start(FROM_HERE, |
| 57 base::TimeDelta::FromMilliseconds(kStopTimeMS), | 57 base::TimeDelta::FromMilliseconds(kStopTimeMS), |
| 58 base::Bind(&SearchController::Stop, | 58 base::Bind(&SearchController::Stop, |
| 59 base::Unretained(this))); | 59 base::Unretained(this))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SearchController::Stop() { | 62 void SearchController::Stop() { |
| 63 stop_timer_.Stop(); | 63 stop_timer_.Stop(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 history_->GetKnownResults(base::UTF16ToUTF8(search_box_->text())) | 124 history_->GetKnownResults(base::UTF16ToUTF8(search_box_->text())) |
| 125 ->swap(known_results); | 125 ->swap(known_results); |
| 126 } | 126 } |
| 127 | 127 |
| 128 size_t num_max_results = | 128 size_t num_max_results = |
| 129 query_for_recommendation_ ? kNumStartPageTiles : kMaxSearchResults; | 129 query_for_recommendation_ ? kNumStartPageTiles : kMaxSearchResults; |
| 130 mixer_->MixAndPublish(is_voice_query_, known_results, num_max_results); | 130 mixer_->MixAndPublish(is_voice_query_, known_results, num_max_results); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace app_list | 133 } // namespace app_list |
| OLD | NEW |