| OLD | NEW |
| 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_window_obj_wrapper.h" | 5 #include "ui/views/accessibility/ax_window_obj_wrapper.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "ui/accessibility/ax_node_data.h" | 8 #include "ui/accessibility/ax_node_data.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 10 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 if (widget) | 42 if (widget) |
| 43 out_children->push_back(AXAuraObjCache::GetInstance()->GetOrCreate(widget)); | 43 out_children->push_back(AXAuraObjCache::GetInstance()->GetOrCreate(widget)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void AXWindowObjWrapper::Serialize(ui::AXNodeData* out_node_data) { | 46 void AXWindowObjWrapper::Serialize(ui::AXNodeData* out_node_data) { |
| 47 out_node_data->id = GetID(); | 47 out_node_data->id = GetID(); |
| 48 out_node_data->role = ui::AX_ROLE_WINDOW; | 48 out_node_data->role = ui::AX_ROLE_WINDOW; |
| 49 // TODO(dtseng): Set better states. | 49 // TODO(dtseng): Set better states. |
| 50 out_node_data->state = 0; | 50 out_node_data->state = 0; |
| 51 out_node_data->location = window_->bounds(); | 51 out_node_data->location = window_->bounds(); |
| 52 | 52 out_node_data->AddStringAttribute( |
| 53 // Root windows currently have a non readable name (e.g. Display1234...); | 53 ui::AX_ATTR_NAME, base::UTF16ToUTF8(window_->title())); |
| 54 // ignore them unless the window is the only node in the tree. | |
| 55 if (window_->parent() || window_->children().size() == 0) { | |
| 56 out_node_data->AddStringAttribute(ui::AX_ATTR_NAME, | |
| 57 base::UTF16ToUTF8(window_->title())); | |
| 58 } | |
| 59 } | 54 } |
| 60 | 55 |
| 61 int32 AXWindowObjWrapper::GetID() { | 56 int32 AXWindowObjWrapper::GetID() { |
| 62 return AXAuraObjCache::GetInstance()->GetID(window_); | 57 return AXAuraObjCache::GetInstance()->GetID(window_); |
| 63 } | 58 } |
| 64 | 59 |
| 65 void AXWindowObjWrapper::OnWindowDestroying(aura::Window* window) { | 60 void AXWindowObjWrapper::OnWindowDestroying(aura::Window* window) { |
| 66 AXAuraObjCache::GetInstance()->Remove(window); | 61 AXAuraObjCache::GetInstance()->Remove(window); |
| 67 } | 62 } |
| 68 | 63 |
| 69 } // namespace views | 64 } // namespace views |
| OLD | NEW |