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

Side by Side Diff: ui/app_list/search_controller.cc

Issue 2225073002: [Chrome OS] Change layout of the launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase & scale the Google Doodle image when it's too large. Created 4 years, 4 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
« no previous file with comments | « ui/app_list/search_controller.h ('k') | ui/app_list/views/all_apps_tile_item_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 13 matching lines...) Expand all
24 24
25 // Maximum time (in milliseconds) to wait to the search providers to finish. 25 // Maximum time (in milliseconds) to wait to the search providers to finish.
26 const int kStopTimeMS = 1500; 26 const int kStopTimeMS = 1500;
27 } 27 }
28 28
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), 34 : search_box_(search_box), mixer_(new Mixer(results)), history_(history) {}
35 dispatching_query_(false),
36 mixer_(new Mixer(results)),
37 history_(history),
38 is_voice_query_(false) {
39 }
40 35
41 SearchController::~SearchController() { 36 SearchController::~SearchController() {
42 } 37 }
43 38
44 void SearchController::Start(bool is_voice_query) { 39 void SearchController::Start(bool is_voice_query) {
45 Stop(); 40 Stop();
46 41
47 base::string16 query; 42 base::string16 query;
48 base::TrimWhitespace(search_box_->text(), base::TRIM_ALL, &query); 43 base::TrimWhitespace(search_box_->text(), base::TRIM_ALL, &query);
49 44
50 dispatching_query_ = true; 45 dispatching_query_ = true;
51 for (Providers::iterator it = providers_.begin(); 46 for (Providers::iterator it = providers_.begin();
52 it != providers_.end(); 47 it != providers_.end();
53 ++it) { 48 ++it) {
54 (*it)->Start(is_voice_query, query); 49 (*it)->Start(is_voice_query, query);
55 } 50 }
56 dispatching_query_ = false; 51 dispatching_query_ = false;
52 query_for_recommendation_ = query.empty() ? true : false;
57 53
58 is_voice_query_ = is_voice_query; 54 is_voice_query_ = is_voice_query;
59 55
60 OnResultsChanged(); 56 OnResultsChanged();
61 57
62 stop_timer_.Start(FROM_HERE, 58 stop_timer_.Start(FROM_HERE,
63 base::TimeDelta::FromMilliseconds(kStopTimeMS), 59 base::TimeDelta::FromMilliseconds(kStopTimeMS),
64 base::Bind(&SearchController::Stop, 60 base::Bind(&SearchController::Stop,
65 base::Unretained(this))); 61 base::Unretained(this)));
66 } 62 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // TODO(xiyuan): Hook up with user learning. 107 // TODO(xiyuan): Hook up with user learning.
112 result->InvokeAction(action_index, event_flags); 108 result->InvokeAction(action_index, event_flags);
113 } 109 }
114 110
115 size_t SearchController::AddGroup(size_t max_results, double multiplier) { 111 size_t SearchController::AddGroup(size_t max_results, double multiplier) {
116 return mixer_->AddGroup(max_results, multiplier); 112 return mixer_->AddGroup(max_results, multiplier);
117 } 113 }
118 114
119 void SearchController::AddProvider(size_t group_id, 115 void SearchController::AddProvider(size_t group_id,
120 std::unique_ptr<SearchProvider> provider) { 116 std::unique_ptr<SearchProvider> provider) {
121 provider->set_result_changed_callback(base::Bind( 117 provider->set_result_changed_callback(
122 &SearchController::OnResultsChanged, 118 base::Bind(&SearchController::OnResultsChanged, base::Unretained(this)));
123 base::Unretained(this)));
124 mixer_->AddProviderToGroup(group_id, provider.get()); 119 mixer_->AddProviderToGroup(group_id, provider.get());
125 providers_.push_back(std::move(provider)); 120 providers_.push_back(std::move(provider));
126 } 121 }
127 122
128 void SearchController::OnResultsChanged() { 123 void SearchController::OnResultsChanged() {
129 if (dispatching_query_) 124 if (dispatching_query_)
130 return; 125 return;
131 126
132 KnownResults known_results; 127 KnownResults known_results;
133 if (history_ && history_->IsReady()) { 128 if (history_ && history_->IsReady()) {
134 history_->GetKnownResults(base::UTF16ToUTF8(search_box_->text())) 129 history_->GetKnownResults(base::UTF16ToUTF8(search_box_->text()))
135 ->swap(known_results); 130 ->swap(known_results);
136 } 131 }
137 132
138 mixer_->MixAndPublish(is_voice_query_, known_results); 133 size_t num_max_results =
134 query_for_recommendation_ ? kNumStartPageTiles : kMaxSearchResults;
135 mixer_->MixAndPublish(is_voice_query_, known_results, num_max_results);
139 } 136 }
140 137
141 } // namespace app_list 138 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/search_controller.h ('k') | ui/app_list/views/all_apps_tile_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698