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

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

Issue 935293002: Launcher Search box, Back and Mic buttons now focusable in ChromeVox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tileitemview-setselected
Patch Set: Rebase. Created 5 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
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 "ui/app_list/app_list_constants.h" 9 #include "ui/app_list/app_list_constants.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_switches.h" 11 #include "ui/app_list/app_list_switches.h"
12 #include "ui/app_list/app_list_view_delegate.h" 12 #include "ui/app_list/app_list_view_delegate.h"
13 #include "ui/app_list/search_box_model.h" 13 #include "ui/app_list/search_box_model.h"
14 #include "ui/app_list/speech_ui_model.h" 14 #include "ui/app_list/speech_ui_model.h"
15 #include "ui/app_list/views/app_list_menu_views.h" 15 #include "ui/app_list/views/app_list_menu_views.h"
16 #include "ui/app_list/views/contents_view.h"
16 #include "ui/app_list/views/search_box_view_delegate.h" 17 #include "ui/app_list/views/search_box_view_delegate.h"
18 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/events/event.h" 20 #include "ui/events/event.h"
19 #include "ui/gfx/canvas.h" 21 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/shadow_value.h" 22 #include "ui/gfx/shadow_value.h"
21 #include "ui/resources/grit/ui_resources.h" 23 #include "ui/resources/grit/ui_resources.h"
24 #include "ui/strings/grit/ui_strings.h"
22 #include "ui/views/border.h" 25 #include "ui/views/border.h"
23 #include "ui/views/controls/button/image_button.h" 26 #include "ui/views/controls/button/image_button.h"
24 #include "ui/views/controls/button/menu_button.h" 27 #include "ui/views/controls/button/menu_button.h"
25 #include "ui/views/controls/image_view.h" 28 #include "ui/views/controls/image_view.h"
26 #include "ui/views/controls/textfield/textfield.h" 29 #include "ui/views/controls/textfield/textfield.h"
27 #include "ui/views/layout/box_layout.h" 30 #include "ui/views/layout/box_layout.h"
28 #include "ui/views/layout/fill_layout.h" 31 #include "ui/views/layout/fill_layout.h"
29 #include "ui/views/shadow_border.h" 32 #include "ui/views/shadow_border.h"
30 33
31 namespace app_list { 34 namespace app_list {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 : ImageButton(listener), selected_(false) {} 77 : ImageButton(listener), selected_(false) {}
75 ~SearchBoxImageButton() override {} 78 ~SearchBoxImageButton() override {}
76 79
77 bool selected() { return selected_; } 80 bool selected() { return selected_; }
78 void SetSelected(bool selected) { 81 void SetSelected(bool selected) {
79 if (selected_ == selected) 82 if (selected_ == selected)
80 return; 83 return;
81 84
82 selected_ = selected; 85 selected_ = selected;
83 SchedulePaint(); 86 SchedulePaint();
87 if (selected)
88 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true);
84 } 89 }
85 90
86 bool OnKeyPressed(const ui::KeyEvent& event) override { 91 bool OnKeyPressed(const ui::KeyEvent& event) override {
87 // Disable space key to press the button. The keyboard events received 92 // Disable space key to press the button. The keyboard events received
88 // by this view are forwarded from a Textfield (SearchBoxView) and key 93 // by this view are forwarded from a Textfield (SearchBoxView) and key
89 // released events are not forwarded. This leaves the button in pressed 94 // released events are not forwarded. This leaves the button in pressed
90 // state. 95 // state.
91 if (event.key_code() == ui::VKEY_SPACE) 96 if (event.key_code() == ui::VKEY_SPACE)
92 return false; 97 return false;
93 98
(...skipping 30 matching lines...) Expand all
124 129
125 if (switches::IsExperimentalAppListEnabled()) { 130 if (switches::IsExperimentalAppListEnabled()) {
126 SetShadow(GetShadowForZHeight(2)); 131 SetShadow(GetShadowForZHeight(2));
127 back_button_ = new SearchBoxImageButton(this); 132 back_button_ = new SearchBoxImageButton(this);
128 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 133 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
129 back_button_->SetImage( 134 back_button_->SetImage(
130 views::ImageButton::STATE_NORMAL, 135 views::ImageButton::STATE_NORMAL,
131 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL)); 136 rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL));
132 back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, 137 back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
133 views::ImageButton::ALIGN_MIDDLE); 138 views::ImageButton::ALIGN_MIDDLE);
139 base::string16 back_title(l10n_util::GetStringUTF16(IDS_APP_LIST_BACK));
140 back_button_->SetAccessibleName(back_title);
141 back_button_->SetTooltipText(back_title);
134 content_container_->AddChildView(back_button_); 142 content_container_->AddChildView(back_button_);
135 143
136 content_container_->set_background(new ExperimentalSearchBoxBackground()); 144 content_container_->set_background(new ExperimentalSearchBoxBackground());
137 } else { 145 } else {
138 set_background( 146 set_background(
139 views::Background::CreateSolidBackground(kSearchBoxBackground)); 147 views::Background::CreateSolidBackground(kSearchBoxBackground));
140 SetBorder( 148 SetBorder(
141 views::Border::CreateSolidSidedBorder(0, 0, 1, 0, kTopSeparatorColor)); 149 views::Border::CreateSolidSidedBorder(0, 0, 1, 0, kTopSeparatorColor));
142 icon_view_ = new views::ImageView; 150 icon_view_ = new views::ImageView;
143 content_container_->AddChildView(icon_view_); 151 content_container_->AddChildView(icon_view_);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 case FOCUS_CONTENTS_VIEW: 260 case FOCUS_CONTENTS_VIEW:
253 focused_view_ = move_backwards 261 focused_view_ = move_backwards
254 ? (speech_button_ && speech_button_->visible() ? 262 ? (speech_button_ && speech_button_->visible() ?
255 FOCUS_MIC_BUTTON : FOCUS_SEARCH_BOX) 263 FOCUS_MIC_BUTTON : FOCUS_SEARCH_BOX)
256 : FOCUS_CONTENTS_VIEW; 264 : FOCUS_CONTENTS_VIEW;
257 break; 265 break;
258 default: 266 default:
259 DCHECK(false); 267 DCHECK(false);
260 } 268 }
261 269
262 if (back_button_ && focused_view_ == FOCUS_BACK_BUTTON) 270 switch (focused_view_) {
263 back_button_->SetSelected(true); 271 case FOCUS_BACK_BUTTON:
264 if (speech_button_ && focused_view_ == FOCUS_MIC_BUTTON) 272 if (back_button_)
265 speech_button_->SetSelected(true); 273 back_button_->SetSelected(true);
274 break;
275 case FOCUS_SEARCH_BOX:
276 // Set the ChromeVox focus to the search box. However, DO NOT do this if
277 // we are in the search results state, because the focus is about to be
278 // shifted to the first search result and we do not want to read out the
279 // name of the search box as well.
280 if (!contents_view_->IsStateActive(AppListModel::STATE_SEARCH_RESULTS))
281 search_box_->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true);
282 break;
283 case FOCUS_MIC_BUTTON:
284 if (speech_button_)
285 speech_button_->SetSelected(true);
286 break;
287 default:
288 break;
289 }
266 290
267 if (focused_view_ < FOCUS_CONTENTS_VIEW) 291 if (focused_view_ < FOCUS_CONTENTS_VIEW)
268 delegate_->SetSearchResultSelection(focused_view_ == FOCUS_SEARCH_BOX); 292 delegate_->SetSearchResultSelection(focused_view_ == FOCUS_SEARCH_BOX);
269 293
270 return (focused_view_ < FOCUS_CONTENTS_VIEW); 294 return (focused_view_ < FOCUS_CONTENTS_VIEW);
271 } 295 }
272 296
273 void SearchBoxView::ResetTabFocus(bool on_contents) { 297 void SearchBoxView::ResetTabFocus(bool on_contents) {
274 if (back_button_) 298 if (back_button_)
275 back_button_->SetSelected(false); 299 back_button_->SetSelected(false);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 404
381 void SearchBoxView::SpeechRecognitionButtonPropChanged() { 405 void SearchBoxView::SpeechRecognitionButtonPropChanged() {
382 const SearchBoxModel::SpeechButtonProperty* speech_button_prop = 406 const SearchBoxModel::SpeechButtonProperty* speech_button_prop =
383 model_->search_box()->speech_button(); 407 model_->search_box()->speech_button();
384 if (speech_button_prop) { 408 if (speech_button_prop) {
385 if (!speech_button_) { 409 if (!speech_button_) {
386 speech_button_ = new SearchBoxImageButton(this); 410 speech_button_ = new SearchBoxImageButton(this);
387 content_container_->AddChildView(speech_button_); 411 content_container_->AddChildView(speech_button_);
388 } 412 }
389 413
414 speech_button_->SetAccessibleName(speech_button_prop->accessible_name);
390 if (view_delegate_->GetSpeechUI()->state() == 415 if (view_delegate_->GetSpeechUI()->state() ==
391 SPEECH_RECOGNITION_HOTWORD_LISTENING) { 416 SPEECH_RECOGNITION_HOTWORD_LISTENING) {
392 speech_button_->SetImage( 417 speech_button_->SetImage(
393 views::Button::STATE_NORMAL, &speech_button_prop->on_icon); 418 views::Button::STATE_NORMAL, &speech_button_prop->on_icon);
394 speech_button_->SetTooltipText(speech_button_prop->on_tooltip); 419 speech_button_->SetTooltipText(speech_button_prop->on_tooltip);
395 } else { 420 } else {
396 speech_button_->SetImage( 421 speech_button_->SetImage(
397 views::Button::STATE_NORMAL, &speech_button_prop->off_icon); 422 views::Button::STATE_NORMAL, &speech_button_prop->off_icon);
398 speech_button_->SetTooltipText(speech_button_prop->off_tooltip); 423 speech_button_->SetTooltipText(speech_button_prop->off_tooltip);
399 } 424 }
(...skipping 22 matching lines...) Expand all
422 NotifyQueryChanged(); 447 NotifyQueryChanged();
423 } 448 }
424 449
425 void SearchBoxView::OnSpeechRecognitionStateChanged( 450 void SearchBoxView::OnSpeechRecognitionStateChanged(
426 SpeechRecognitionState new_state) { 451 SpeechRecognitionState new_state) {
427 SpeechRecognitionButtonPropChanged(); 452 SpeechRecognitionButtonPropChanged();
428 SchedulePaint(); 453 SchedulePaint();
429 } 454 }
430 455
431 } // namespace app_list 456 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698