OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/app_list/app_list_view.h" | 5 #include "ui/app_list/app_list_view.h" |
6 | 6 |
| 7 #include "base/string_util.h" |
7 #include "ui/app_list/app_list_bubble_border.h" | 8 #include "ui/app_list/app_list_bubble_border.h" |
8 #include "ui/app_list/app_list_item_view.h" | 9 #include "ui/app_list/app_list_item_view.h" |
9 #include "ui/app_list/app_list_model.h" | 10 #include "ui/app_list/app_list_model.h" |
10 #include "ui/app_list/app_list_view_delegate.h" | 11 #include "ui/app_list/app_list_view_delegate.h" |
11 #include "ui/app_list/contents_view.h" | 12 #include "ui/app_list/contents_view.h" |
12 #include "ui/app_list/pagination_model.h" | 13 #include "ui/app_list/pagination_model.h" |
13 #include "ui/app_list/search_box_model.h" | 14 #include "ui/app_list/search_box_model.h" |
14 #include "ui/app_list/search_box_view.h" | 15 #include "ui/app_list/search_box_view.h" |
15 #include "ui/gfx/insets.h" | 16 #include "ui/gfx/insets.h" |
16 #include "ui/views/bubble/bubble_frame_view.h" | 17 #include "ui/views/bubble/bubble_frame_view.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 anchor_rect); | 168 anchor_rect); |
168 | 169 |
169 // Repaints border if arrow offset is changed. | 170 // Repaints border if arrow offset is changed. |
170 if (bubble_border_->offset() != old_offset) | 171 if (bubble_border_->offset() != old_offset) |
171 GetBubbleFrameView()->SchedulePaint(); | 172 GetBubbleFrameView()->SchedulePaint(); |
172 | 173 |
173 return bubble_rect; | 174 return bubble_rect; |
174 } | 175 } |
175 | 176 |
176 void AppListView::QueryChanged(SearchBoxView* sender) { | 177 void AppListView::QueryChanged(SearchBoxView* sender) { |
177 bool should_show_search = !model_->search_box()->text().empty(); | 178 string16 query; |
| 179 TrimWhitespace(model_->search_box()->text(), TRIM_ALL, &query); |
| 180 bool should_show_search = !query.empty(); |
178 contents_view_->ShowSearchResults(should_show_search); | 181 contents_view_->ShowSearchResults(should_show_search); |
179 | 182 |
180 if (delegate_.get()) { | 183 if (delegate_.get()) { |
181 if (should_show_search) | 184 if (should_show_search) |
182 delegate_->StartSearch(); | 185 delegate_->StartSearch(); |
183 else | 186 else |
184 delegate_->StopSearch(); | 187 delegate_->StopSearch(); |
185 } | 188 } |
186 } | 189 } |
187 | 190 |
188 void AppListView::OpenResult(const SearchResult& result, int event_flags) { | 191 void AppListView::OpenResult(const SearchResult& result, int event_flags) { |
189 if (delegate_.get()) | 192 if (delegate_.get()) |
190 delegate_->OpenSearchResult(result, event_flags); | 193 delegate_->OpenSearchResult(result, event_flags); |
191 Close(); | 194 Close(); |
192 } | 195 } |
193 | 196 |
194 } // namespace app_list | 197 } // namespace app_list |
OLD | NEW |