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

Side by Side Diff: ui/views/accessibility/ax_aura_obj_cache.cc

Issue 2530073002: Add kAccessibilityFocusFallsbackToWidget property (Closed)
Patch Set: Check whether the window is arc or not Created 4 years 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 | « chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/views/accessibility/ax_aura_obj_cache.h" 5 #include "ui/views/accessibility/ax_aura_obj_cache.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/strings/string_util.h"
10 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/client/focus_client.h" 11 #include "ui/aura/client/focus_client.h"
10 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
11 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" 13 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
12 #include "ui/views/accessibility/ax_view_obj_wrapper.h" 14 #include "ui/views/accessibility/ax_view_obj_wrapper.h"
13 #include "ui/views/accessibility/ax_widget_obj_wrapper.h" 15 #include "ui/views/accessibility/ax_widget_obj_wrapper.h"
14 #include "ui/views/accessibility/ax_window_obj_wrapper.h" 16 #include "ui/views/accessibility/ax_window_obj_wrapper.h"
15 #include "ui/views/view.h" 17 #include "ui/views/view.h"
16 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
17 19
18 namespace views { 20 namespace views {
19 21
22 namespace {
23
24 const char kExoShellSurfaceWindowName[] = "ExoShellSurface";
25 const char kArcProcessNamePrefix[] = "org.chromium.arc.";
26
27 // TODO(yawano): chrome/browser/memory/tab_manager_delegate_chromeos.cc is doing
28 // the same thing. Move this to some utility function and share the logic with
29 // it.
30 bool IsArcWindow(aura::Window* window) {
sky 2016/12/06 17:23:20 Views shouldn't need to know about arc. Instead th
yawano 2016/12/07 11:10:00 Thank you! Seems good property for this behavior.
31 if (!window || window->GetName() != kExoShellSurfaceWindowName)
sky 2016/12/02 17:49:56 Why do you need to check the name *and* the kAppId
sky 2016/12/02 17:50:40 Also, can't you set an explicit property rather th
yawano 2016/12/05 02:16:36 As far as I tested, checking only kAppIdKey would
reveman 2016/12/05 16:42:37 We already do this. exo::ShellSurface::GetMainSurf
reveman 2016/12/05 16:42:37 exo::ShellSurface::GetMainSurface can be used to m
32 return false;
33
34 std::string* application_id = window->GetProperty(aura::client::kAppIdKey);
35 if (!application_id)
36 return false;
37
38 return base::StartsWith(*application_id, kArcProcessNamePrefix,
39 base::CompareCase::SENSITIVE);
40 }
41 } // namespace
42
20 // static 43 // static
21 AXAuraObjCache* AXAuraObjCache::GetInstance() { 44 AXAuraObjCache* AXAuraObjCache::GetInstance() {
22 return base::Singleton<AXAuraObjCache>::get(); 45 return base::Singleton<AXAuraObjCache>::get();
23 } 46 }
24 47
25 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(View* view) { 48 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(View* view) {
26 return CreateInternal<AXViewObjWrapper>(view, view_to_id_map_); 49 return CreateInternal<AXViewObjWrapper>(view, view_to_id_map_);
27 } 50 }
28 51
29 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(Widget* widget) { 52 AXAuraObjWrapper* AXAuraObjCache::GetOrCreate(Widget* widget) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 174 }
152 175
153 if (!focused_widget) 176 if (!focused_widget)
154 return nullptr; 177 return nullptr;
155 178
156 FocusManager* focus_manager = focused_widget->GetFocusManager(); 179 FocusManager* focus_manager = focused_widget->GetFocusManager();
157 if (!focus_manager) 180 if (!focus_manager)
158 return nullptr; 181 return nullptr;
159 182
160 View* focused_view = focus_manager->GetFocusedView(); 183 View* focused_view = focus_manager->GetFocusedView();
161 if (focused_view) 184
185 // If focused window is arc, don't try to put focus on root view even if
186 // focused_view is nullptr.
187 if (IsArcWindow(focused_window) || focused_view)
162 return focused_view; 188 return focused_view;
163 else 189
164 return focused_widget->GetRootView(); 190 // If no view is focused, falls back to root view.
191 return focused_widget->GetRootView();
165 } 192 }
166 193
167 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus, 194 void AXAuraObjCache::OnWindowFocused(aura::Window* gained_focus,
168 aura::Window* lost_focus) { 195 aura::Window* lost_focus) {
169 OnFocusedViewChanged(); 196 OnFocusedViewChanged();
170 } 197 }
171 198
172 void AXAuraObjCache::OnWindowDestroying(aura::Window* window) { 199 void AXAuraObjCache::OnWindowDestroying(aura::Window* window) {
173 focus_client_ = nullptr; 200 focus_client_ = nullptr;
174 } 201 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 AuraView* aura_view, 238 AuraView* aura_view,
212 std::map<AuraView*, int32_t>& aura_view_to_id_map) { 239 std::map<AuraView*, int32_t>& aura_view_to_id_map) {
213 int32_t id = GetID(aura_view); 240 int32_t id = GetID(aura_view);
214 if (id == -1) 241 if (id == -1)
215 return; 242 return;
216 aura_view_to_id_map.erase(aura_view); 243 aura_view_to_id_map.erase(aura_view);
217 Remove(id); 244 Remove(id);
218 } 245 }
219 246
220 } // namespace views 247 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698