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

Side by Side Diff: ui/app_list/views/search_box_view.cc

Issue 164193005: Refactors the auto-launch logic and adds tests for it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win error 2 Created 6 years, 10 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
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | ui/app_list/views/search_box_view_unittest.cc » ('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 (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/views/search_box_view.h" 5 #include "ui/app_list/views/search_box_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
11 #include "ui/app_list/app_list_view_delegate.h" 11 #include "ui/app_list/app_list_view_delegate.h"
12 #include "ui/app_list/search_box_model.h" 12 #include "ui/app_list/search_box_model.h"
13 #include "ui/app_list/speech_ui_model.h" 13 #include "ui/app_list/speech_ui_model.h"
14 #include "ui/app_list/views/app_list_menu_views.h" 14 #include "ui/app_list/views/app_list_menu_views.h"
15 #include "ui/app_list/views/contents_view.h"
16 #include "ui/app_list/views/search_box_view_delegate.h" 15 #include "ui/app_list/views/search_box_view_delegate.h"
17 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/events/event.h" 18 #include "ui/events/event.h"
20 #include "ui/views/controls/button/image_button.h" 19 #include "ui/views/controls/button/image_button.h"
21 #include "ui/views/controls/button/menu_button.h" 20 #include "ui/views/controls/button/menu_button.h"
22 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
23 #include "ui/views/controls/textfield/textfield.h" 22 #include "ui/views/controls/textfield/textfield.h"
24 23
25 namespace app_list { 24 namespace app_list {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 SpeechRecognitionButtonPropChanged(); 90 SpeechRecognitionButtonPropChanged();
92 HintTextChanged(); 91 HintTextChanged();
93 } 92 }
94 93
95 bool SearchBoxView::HasSearch() const { 94 bool SearchBoxView::HasSearch() const {
96 return !search_box_->text().empty(); 95 return !search_box_->text().empty();
97 } 96 }
98 97
99 void SearchBoxView::ClearSearch() { 98 void SearchBoxView::ClearSearch() {
100 search_box_->SetText(base::string16()); 99 search_box_->SetText(base::string16());
100 view_delegate_->AutoLaunchCanceled();
101 // Updates model and fires query changed manually because SetText() above 101 // Updates model and fires query changed manually because SetText() above
102 // does not generate ContentsChanged() notification. 102 // does not generate ContentsChanged() notification.
103 UpdateModel(); 103 UpdateModel();
104 NotifyQueryChanged(); 104 NotifyQueryChanged();
105 } 105 }
106 106
107 void SearchBoxView::InvalidateMenu() { 107 void SearchBoxView::InvalidateMenu() {
108 menu_.reset(); 108 menu_.reset();
109 } 109 }
110 110
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 173
174 void SearchBoxView::NotifyQueryChanged() { 174 void SearchBoxView::NotifyQueryChanged() {
175 DCHECK(delegate_); 175 DCHECK(delegate_);
176 delegate_->QueryChanged(this); 176 delegate_->QueryChanged(this);
177 } 177 }
178 178
179 void SearchBoxView::ContentsChanged(views::Textfield* sender, 179 void SearchBoxView::ContentsChanged(views::Textfield* sender,
180 const base::string16& new_contents) { 180 const base::string16& new_contents) {
181 UpdateModel(); 181 UpdateModel();
182 contents_view_->CancelAutoLaunch(); 182 view_delegate_->AutoLaunchCanceled();
183 NotifyQueryChanged(); 183 NotifyQueryChanged();
184 } 184 }
185 185
186 bool SearchBoxView::HandleKeyEvent(views::Textfield* sender, 186 bool SearchBoxView::HandleKeyEvent(views::Textfield* sender,
187 const ui::KeyEvent& key_event) { 187 const ui::KeyEvent& key_event) {
188 bool handled = false; 188 bool handled = false;
189 if (contents_view_ && contents_view_->visible()) 189 if (contents_view_ && contents_view_->visible())
190 handled = contents_view_->OnKeyPressed(key_event); 190 handled = contents_view_->OnKeyPressed(key_event);
191 191
192 return handled; 192 return handled;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 NotifyQueryChanged(); 253 NotifyQueryChanged();
254 } 254 }
255 255
256 void SearchBoxView::OnSpeechRecognitionStateChanged( 256 void SearchBoxView::OnSpeechRecognitionStateChanged(
257 SpeechRecognitionState new_state) { 257 SpeechRecognitionState new_state) {
258 SpeechRecognitionButtonPropChanged(); 258 SpeechRecognitionButtonPropChanged();
259 SchedulePaint(); 259 SchedulePaint();
260 } 260 }
261 261
262 } // namespace app_list 262 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | ui/app_list/views/search_box_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698