| 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 "chrome/browser/ui/app_list/search/search_controller.h" | 5 #include "chrome/browser/ui/app_list/search/search_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 30 #include "ui/app_list/search_box_model.h" | 30 #include "ui/app_list/search_box_model.h" |
| 31 #include "ui/app_list/speech_ui_model.h" | 31 #include "ui/app_list/speech_ui_model.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 const char kAppListSearchResultOpenTypeHistogram[] = | 36 const char kAppListSearchResultOpenTypeHistogram[] = |
| 37 "Apps.AppListSearchResultOpenType"; | 37 "Apps.AppListSearchResultOpenType"; |
| 38 |
| 39 // Maximum time (in milliseconds) to wait to the search providers to finish. |
| 40 const int kStopTimeMS = 1500; |
| 38 } | 41 } |
| 39 | 42 |
| 40 namespace app_list { | 43 namespace app_list { |
| 41 | 44 |
| 42 SearchController::SearchController(Profile* profile, | 45 SearchController::SearchController(Profile* profile, |
| 43 SearchBoxModel* search_box, | 46 SearchBoxModel* search_box, |
| 44 AppListModel::SearchResults* results, | 47 AppListModel::SearchResults* results, |
| 45 SpeechUIModel* speech_ui, | 48 SpeechUIModel* speech_ui, |
| 46 AppListControllerDelegate* list_controller) | 49 AppListControllerDelegate* list_controller) |
| 47 : profile_(profile), | 50 : profile_(profile), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 dispatching_query_ = true; | 105 dispatching_query_ = true; |
| 103 for (Providers::iterator it = providers_.begin(); | 106 for (Providers::iterator it = providers_.begin(); |
| 104 it != providers_.end(); | 107 it != providers_.end(); |
| 105 ++it) { | 108 ++it) { |
| 106 (*it)->Start(query); | 109 (*it)->Start(query); |
| 107 } | 110 } |
| 108 dispatching_query_ = false; | 111 dispatching_query_ = false; |
| 109 | 112 |
| 110 OnResultsChanged(); | 113 OnResultsChanged(); |
| 111 | 114 |
| 112 // Maximum time (in milliseconds) to wait to the search providers to finish. | |
| 113 const int kStopTimeMS = 1500; | |
| 114 stop_timer_.Start(FROM_HERE, | 115 stop_timer_.Start(FROM_HERE, |
| 115 base::TimeDelta::FromMilliseconds(kStopTimeMS), | 116 base::TimeDelta::FromMilliseconds(kStopTimeMS), |
| 116 base::Bind(&SearchController::Stop, | 117 base::Bind(&SearchController::Stop, |
| 117 base::Unretained(this))); | 118 base::Unretained(this))); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void SearchController::Stop() { | 121 void SearchController::Stop() { |
| 121 stop_timer_.Stop(); | 122 stop_timer_.Stop(); |
| 122 | 123 |
| 123 for (Providers::iterator it = providers_.begin(); | 124 for (Providers::iterator it = providers_.begin(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 176 } |
| 176 | 177 |
| 177 void SearchController::OnSpeechRecognitionStateChanged( | 178 void SearchController::OnSpeechRecognitionStateChanged( |
| 178 SpeechRecognitionState new_state) { | 179 SpeechRecognitionState new_state) { |
| 179 search_box_->SetHintText(l10n_util::GetStringUTF16( | 180 search_box_->SetHintText(l10n_util::GetStringUTF16( |
| 180 (new_state == SPEECH_RECOGNITION_HOTWORD_LISTENING) ? | 181 (new_state == SPEECH_RECOGNITION_HOTWORD_LISTENING) ? |
| 181 IDS_SEARCH_BOX_HOTWORD_HINT : IDS_SEARCH_BOX_HINT)); | 182 IDS_SEARCH_BOX_HOTWORD_HINT : IDS_SEARCH_BOX_HINT)); |
| 182 } | 183 } |
| 183 | 184 |
| 184 } // namespace app_list | 185 } // namespace app_list |
| OLD | NEW |