OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/aura/accessibility/ax_root_obj_wrapper.h" | |
6 | |
7 #include "base/strings/utf_string_conversions.h" | |
8 #include "ui/accessibility/ax_node_data.h" | |
9 #include "ui/accessibility/ax_view_state.h" | |
10 #include "ui/aura/window.h" | |
11 #include "ui/views/accessibility/ax_aura_obj_cache.h" | |
12 #include "ui/views/accessibility/ax_window_obj_wrapper.h" | |
13 | |
14 AXRootObjWrapper::AXRootObjWrapper(int32 id) | |
15 : id_(id), alert_window_(new aura::Window(NULL)) { | |
16 } | |
17 | |
18 AXRootObjWrapper::~AXRootObjWrapper() { | |
19 if (alert_window_) { | |
20 delete alert_window_; | |
21 alert_window_ = NULL; | |
22 } | |
23 } | |
24 | |
25 views::AXAuraObjWrapper* AXRootObjWrapper::GetAlertForText( | |
26 const std::string& text) { | |
27 alert_window_->SetTitle(base::UTF8ToUTF16((text))); | |
28 views::AXWindowObjWrapper* window_obj = | |
29 static_cast<views::AXWindowObjWrapper*>( | |
30 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_)); | |
31 window_obj->set_is_alert(true); | |
32 return window_obj; | |
33 } | |
34 | |
35 bool AXRootObjWrapper::HasChild(views::AXAuraObjWrapper* child) { | |
36 std::vector<views::AXAuraObjWrapper*> children; | |
37 GetChildren(&children); | |
38 return std::find(children.begin(), children.end(), child) != children.end(); | |
39 } | |
40 | |
41 views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() { | |
42 return NULL; | |
43 } | |
44 | |
45 void AXRootObjWrapper::GetChildren( | |
46 std::vector<views::AXAuraObjWrapper*>* out_children) { | |
47 views::AXAuraObjCache::GetInstance()->GetTopLevelWindows(out_children); | |
48 } | |
49 | |
50 void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) { | |
51 out_node_data->id = id_; | |
52 out_node_data->role = ui::AX_ROLE_DESKTOP; | |
53 // TODO(dtseng): Apply a richer set of states. | |
54 out_node_data->state = 0; | |
55 } | |
56 | |
57 int32 AXRootObjWrapper::GetID() { | |
58 return id_; | |
59 } | |
OLD | NEW |