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

Side by Side Diff: chrome/browser/chromeos/accessibility/select_to_speak_event_handler.cc

Issue 2735413002: Select-to-speak event handler should be on root window, not ash Shell. (Closed)
Patch Set: Get rid of unrelated changes Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/chromeos/accessibility/select_to_speak_event_handler.h" 5 #include "chrome/browser/chromeos/accessibility/select_to_speak_event_handler.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/speech/tts_controller.h" 9 #include "chrome/browser/speech/tts_controller.h"
10 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" 10 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/display/display.h" 13 #include "ui/display/display.h"
14 #include "ui/events/event.h" 14 #include "ui/events/event.h"
15 #include "ui/views/focus/view_storage.h" 15 #include "ui/views/focus/view_storage.h"
16 #include "ui/views/view.h" 16 #include "ui/views/view.h"
17 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
18 18
19 namespace chromeos { 19 namespace chromeos {
20 20
21 SelectToSpeakEventHandler::SelectToSpeakEventHandler() { 21 SelectToSpeakEventHandler::SelectToSpeakEventHandler() {
22 if (ash::Shell::HasInstance()) 22 if (ash::Shell::HasInstance()) {
23 ash::Shell::GetInstance()->AddPreTargetHandler(this); 23 ash::Shell::GetInstance()->GetPrimaryRootWindow()->AddPreTargetHandler(
24 this);
25 }
24 } 26 }
25 27
26 SelectToSpeakEventHandler::~SelectToSpeakEventHandler() { 28 SelectToSpeakEventHandler::~SelectToSpeakEventHandler() {
27 if (ash::Shell::HasInstance()) 29 if (ash::Shell::HasInstance()) {
28 ash::Shell::GetInstance()->RemovePreTargetHandler(this); 30 ash::Shell::GetInstance()->GetPrimaryRootWindow()->RemovePreTargetHandler(
31 this);
32 }
29 } 33 }
30 34
31 void SelectToSpeakEventHandler::OnKeyEvent(ui::KeyEvent* event) { 35 void SelectToSpeakEventHandler::OnKeyEvent(ui::KeyEvent* event) {
32 DCHECK(event); 36 DCHECK(event);
33 37
34 // We can only call TtsController on the UI thread, make sure we 38 // We can only call TtsController on the UI thread, make sure we
35 // don't ever try to run this code on some other thread. 39 // don't ever try to run this code on some other thread.
36 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 40 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
37 41
38 ui::KeyboardCode key_code = event->key_code(); 42 ui::KeyboardCode key_code = event->key_code();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 : nullptr; 183 : nullptr;
180 if (last_view) { 184 if (last_view) {
181 last_view->NotifyAccessibilityEvent(ui::AX_EVENT_MOUSE_CANCELED, true); 185 last_view->NotifyAccessibilityEvent(ui::AX_EVENT_MOUSE_CANCELED, true);
182 } else { 186 } else {
183 AutomationManagerAura::GetInstance()->HandleEvent( 187 AutomationManagerAura::GetInstance()->HandleEvent(
184 nullptr, nullptr, ui::AX_EVENT_MOUSE_CANCELED); 188 nullptr, nullptr, ui::AX_EVENT_MOUSE_CANCELED);
185 } 189 }
186 } 190 }
187 191
188 } // namespace chromeos 192 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698