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

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

Issue 2711343005: Set keys to traverse accessibility tree. Using focus ring to highlight selected node. (Closed)
Patch Set: Fixing closure compilation error 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/accessibility/event_handler_common.h"
6
7 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/render_widget_host.h"
11 #include "extensions/browser/extension_host.h"
12 #include "extensions/browser/extension_registry.h"
13 #include "extensions/browser/process_manager.h"
14
15 namespace chromeos {
16
17 extensions::ExtensionHost* GetAccessibilityExtensionHost(
18 const std::string& extension_id) {
19 if (!AccessibilityManager::Get())
20 return nullptr;
21
22 content::BrowserContext* context = ProfileManager::GetActiveUserProfile();
23 if (!context)
24 return nullptr;
25
26 const extensions::Extension* extension =
27 extensions::ExtensionRegistry::Get(context)->enabled_extensions().GetByID(
28 extension_id);
29 if (!extension)
30 return nullptr;
31
32 extensions::ExtensionHost* host =
33 extensions::ProcessManager::Get(context)->GetBackgroundHostForExtension(
34 extension->id());
35 return host;
36 }
37
38 void ForwardKeyToExtension(const ui::KeyEvent& key_event,
39 extensions::ExtensionHost* host) {
40 if (!host) {
41 LOG(ERROR) << "Unable to forward key to extension";
42 return;
43 }
44
45 content::RenderViewHost* rvh = host->render_view_host();
46 if (!rvh) {
47 LOG(ERROR) << "Unable to forward key to extension";
48 return;
49 }
50
51 const content::NativeWebKeyboardEvent web_event(key_event);
52 rvh->GetWidget()->ForwardKeyboardEvent(web_event);
53 }
54 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698