Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: chrome/browser/ui/app_list/search/search_controller.cc

Issue 379333005: Allow AppSearchProvider to provide recommendations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 new OmniboxProvider(profile_)).Pass()); 84 new OmniboxProvider(profile_)).Pass());
85 AddProvider(Mixer::WEBSTORE_GROUP, scoped_ptr<SearchProvider>( 85 AddProvider(Mixer::WEBSTORE_GROUP, scoped_ptr<SearchProvider>(
86 new WebstoreProvider(profile_, list_controller_)).Pass()); 86 new WebstoreProvider(profile_, list_controller_)).Pass());
87 if (!CommandLine::ForCurrentProcess()->HasSwitch( 87 if (!CommandLine::ForCurrentProcess()->HasSwitch(
88 switches::kDisablePeopleSearch)) { 88 switches::kDisablePeopleSearch)) {
89 AddProvider(Mixer::PEOPLE_GROUP, scoped_ptr<SearchProvider>( 89 AddProvider(Mixer::PEOPLE_GROUP, scoped_ptr<SearchProvider>(
90 new PeopleProvider(profile_)).Pass()); 90 new PeopleProvider(profile_)).Pass());
91 } 91 }
92 } 92 }
93 93
94 void SearchController::FetchRecommendations() {
95 Stop();
96
97 list_controller_->OnSearchStarted();
98
99 dispatching_query_ = true;
100 for (Providers::iterator it = providers_.begin();
101 it != providers_.end();
102 ++it) {
103 (*it)->FetchRecommendations();
104 }
105 dispatching_query_ = false;
106
107 OnResultsChanged();
108 InitiateStopTimer();
109 }
110
94 void SearchController::Start() { 111 void SearchController::Start() {
95 Stop(); 112 Stop();
96 113
97 list_controller_->OnSearchStarted(); 114 list_controller_->OnSearchStarted();
98 115
99 base::string16 query; 116 base::string16 query;
100 base::TrimWhitespace(search_box_->text(), base::TRIM_ALL, &query); 117 base::TrimWhitespace(search_box_->text(), base::TRIM_ALL, &query);
101 118
102 dispatching_query_ = true; 119 dispatching_query_ = true;
103 for (Providers::iterator it = providers_.begin(); 120 for (Providers::iterator it = providers_.begin();
104 it != providers_.end(); 121 it != providers_.end();
105 ++it) { 122 ++it) {
106 (*it)->Start(query); 123 (*it)->Start(query);
107 } 124 }
108 dispatching_query_ = false; 125 dispatching_query_ = false;
109 126
110 OnResultsChanged(); 127 OnResultsChanged();
128 InitiateStopTimer();
129 }
111 130
131 void SearchController::InitiateStopTimer() {
112 // Maximum time (in milliseconds) to wait to the search providers to finish. 132 // Maximum time (in milliseconds) to wait to the search providers to finish.
113 const int kStopTimeMS = 1500; 133 const int kStopTimeMS = 1500;
Matt Giuca 2014/07/22 04:31:07 nit: This constant should be more visible -- at le
calamity 2014/07/22 07:24:04 Done.
114 stop_timer_.Start(FROM_HERE, 134 stop_timer_.Start(FROM_HERE,
115 base::TimeDelta::FromMilliseconds(kStopTimeMS), 135 base::TimeDelta::FromMilliseconds(kStopTimeMS),
116 base::Bind(&SearchController::Stop, 136 base::Bind(&SearchController::Stop,
117 base::Unretained(this))); 137 base::Unretained(this)));
118 } 138 }
119 139
120 void SearchController::Stop() { 140 void SearchController::Stop() {
121 stop_timer_.Stop(); 141 stop_timer_.Stop();
122 142
123 for (Providers::iterator it = providers_.begin(); 143 for (Providers::iterator it = providers_.begin();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 195 }
176 196
177 void SearchController::OnSpeechRecognitionStateChanged( 197 void SearchController::OnSpeechRecognitionStateChanged(
178 SpeechRecognitionState new_state) { 198 SpeechRecognitionState new_state) {
179 search_box_->SetHintText(l10n_util::GetStringUTF16( 199 search_box_->SetHintText(l10n_util::GetStringUTF16(
180 (new_state == SPEECH_RECOGNITION_HOTWORD_LISTENING) ? 200 (new_state == SPEECH_RECOGNITION_HOTWORD_LISTENING) ?
181 IDS_SEARCH_BOX_HOTWORD_HINT : IDS_SEARCH_BOX_HINT)); 201 IDS_SEARCH_BOX_HOTWORD_HINT : IDS_SEARCH_BOX_HINT));
182 } 202 }
183 203
184 } // namespace app_list 204 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698