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

Side by Side Diff: chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc

Issue 2878503003: Convert accessibility_helper.mojom to snake casing (Closed)
Patch Set: Rebase Created 3 years, 7 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 | chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge_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 2017 The Chromium Authors. All rights reserved. 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 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/arc/accessibility/arc_accessibility_helper_bri dge.h" 5 #include "chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bri dge.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 10 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (!wm_helper) 53 if (!wm_helper)
54 return; 54 return;
55 55
56 aura::Window* focused_window = wm_helper->GetFocusedWindow(); 56 aura::Window* focused_window = wm_helper->GetFocusedWindow();
57 if (!focused_window) 57 if (!focused_window)
58 return; 58 return;
59 59
60 aura::Window* toplevel_window = focused_window->GetToplevelWindow(); 60 aura::Window* toplevel_window = focused_window->GetToplevelWindow();
61 61
62 gfx::Rect bounds_in_screen = gfx::ScaleToEnclosingRect( 62 gfx::Rect bounds_in_screen = gfx::ScaleToEnclosingRect(
63 node_data->boundsInScreen, 63 node_data->bounds_in_screen,
64 1.0f / toplevel_window->layer()->device_scale_factor()); 64 1.0f / toplevel_window->layer()->device_scale_factor());
65 65
66 accessibility_manager->OnViewFocusedInArc(bounds_in_screen); 66 accessibility_manager->OnViewFocusedInArc(bounds_in_screen);
67 } 67 }
68 68
69 arc::mojom::AccessibilityFilterType GetFilterType() { 69 arc::mojom::AccessibilityFilterType GetFilterType() {
70 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 70 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
71 chromeos::switches::kEnableChromeVoxArcSupport)) { 71 chromeos::switches::kEnableChromeVoxArcSupport)) {
72 return arc::mojom::AccessibilityFilterType::ALL; 72 return arc::mojom::AccessibilityFilterType::ALL;
73 } 73 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 void ArcAccessibilityHelperBridge::OnAccessibilityEvent( 153 void ArcAccessibilityHelperBridge::OnAccessibilityEvent(
154 mojom::AccessibilityEventDataPtr event_data) { 154 mojom::AccessibilityEventDataPtr event_data) {
155 arc::mojom::AccessibilityFilterType filter_type = GetFilterType(); 155 arc::mojom::AccessibilityFilterType filter_type = GetFilterType();
156 156
157 if (filter_type == arc::mojom::AccessibilityFilterType::ALL || 157 if (filter_type == arc::mojom::AccessibilityFilterType::ALL ||
158 filter_type == 158 filter_type ==
159 arc::mojom::AccessibilityFilterType::WHITELISTED_PACKAGE_NAME) { 159 arc::mojom::AccessibilityFilterType::WHITELISTED_PACKAGE_NAME) {
160 // Get the task id for this package which requires inspecting node data. 160 // Get the task id for this package which requires inspecting node data.
161 if (event_data->nodeData.empty()) 161 if (event_data->node_data.empty())
162 return; 162 return;
163 163
164 arc::mojom::AccessibilityNodeInfoData* node = event_data->nodeData[0].get(); 164 arc::mojom::AccessibilityNodeInfoData* node =
165 if (!node->stringProperties) 165 event_data->node_data[0].get();
166 if (!node->string_properties)
166 return; 167 return;
167 168
168 auto package_it = node->stringProperties->find( 169 auto package_it = node->string_properties->find(
169 arc::mojom::AccessibilityStringProperty::PACKAGE_NAME); 170 arc::mojom::AccessibilityStringProperty::PACKAGE_NAME);
170 if (package_it == node->stringProperties->end()) 171 if (package_it == node->string_properties->end())
171 return; 172 return;
172 173
173 auto task_ids_it = package_name_to_task_ids_.find(package_it->second); 174 auto task_ids_it = package_name_to_task_ids_.find(package_it->second);
174 if (task_ids_it == package_name_to_task_ids_.end()) 175 if (task_ids_it == package_name_to_task_ids_.end())
175 return; 176 return;
176 177
177 const auto& task_ids = task_ids_it->second; 178 const auto& task_ids = task_ids_it->second;
178 179
179 // Reject updates to non-current task ids. We can do this currently 180 // Reject updates to non-current task ids. We can do this currently
180 // because all events include the entire tree. 181 // because all events include the entire tree.
181 if (task_ids.count(current_task_id_) == 0) 182 if (task_ids.count(current_task_id_) == 0)
182 return; 183 return;
183 184
184 auto tree_it = package_name_to_tree_.find(package_it->second); 185 auto tree_it = package_name_to_tree_.find(package_it->second);
185 AXTreeSourceArc* tree_source; 186 AXTreeSourceArc* tree_source;
186 if (tree_it == package_name_to_tree_.end()) { 187 if (tree_it == package_name_to_tree_.end()) {
187 package_name_to_tree_[package_it->second].reset( 188 package_name_to_tree_[package_it->second].reset(
188 new AXTreeSourceArc(this)); 189 new AXTreeSourceArc(this));
189 tree_source = package_name_to_tree_[package_it->second].get(); 190 tree_source = package_name_to_tree_[package_it->second].get();
190 } else { 191 } else {
191 tree_source = tree_it->second.get(); 192 tree_source = tree_it->second.get();
192 } 193 }
193 tree_source->NotifyAccessibilityEvent(event_data.get()); 194 tree_source->NotifyAccessibilityEvent(event_data.get());
194 return; 195 return;
195 } 196 }
196 197
197 if (event_data->eventType != arc::mojom::AccessibilityEventType::VIEW_FOCUSED) 198 if (event_data->event_type !=
199 arc::mojom::AccessibilityEventType::VIEW_FOCUSED)
198 return; 200 return;
199 201
200 CHECK_EQ(1U, event_data.get()->nodeData.size()); 202 CHECK_EQ(1U, event_data.get()->node_data.size());
201 DispatchFocusChange(event_data.get()->nodeData[0].get()); 203 DispatchFocusChange(event_data.get()->node_data[0].get());
202 } 204 }
203 205
204 void ArcAccessibilityHelperBridge::OnAction( 206 void ArcAccessibilityHelperBridge::OnAction(
205 const ui::AXActionData& data) const { 207 const ui::AXActionData& data) const {
206 arc::mojom::AccessibilityActionType mojo_action; 208 arc::mojom::AccessibilityActionType mojo_action;
207 switch (data.action) { 209 switch (data.action) {
208 case ui::AX_ACTION_DO_DEFAULT: 210 case ui::AX_ACTION_DO_DEFAULT:
209 mojo_action = arc::mojom::AccessibilityActionType::CLICK; 211 mojo_action = arc::mojom::AccessibilityActionType::CLICK;
210 break; 212 break;
211 default: 213 default:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 break; 264 break;
263 } 265 }
264 } 266 }
265 } 267 }
266 268
267 void ArcAccessibilityHelperBridge::OnTaskSetActive(int32_t task_id) { 269 void ArcAccessibilityHelperBridge::OnTaskSetActive(int32_t task_id) {
268 current_task_id_ = task_id; 270 current_task_id_ = task_id;
269 } 271 }
270 272
271 } // namespace arc 273 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698