145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org// Copyright 2014 The Chromium Authors. All rights reserved.
245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org// Use of this source code is governed by a BSD-style license that can be
345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org// found in the LICENSE file.
445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include "chrome/browser/ui/ash/accessibility/ax_root_obj_wrapper.h"
645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org
7#include "ash/shell.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
13AXRootObjWrapper::AXRootObjWrapper(int32 id) : id_(id) {
14}
15
16AXRootObjWrapper::~AXRootObjWrapper() {}
17
18bool AXRootObjWrapper::HasChild(views::AXAuraObjWrapper* child) {
19  std::vector<views::AXAuraObjWrapper*> children;
20  GetChildren(&children);
21  return std::find(children.begin(), children.end(), child) != children.end();
22}
23
24views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() {
25  return NULL;
26}
27
28void AXRootObjWrapper::GetChildren(
29    std::vector<views::AXAuraObjWrapper*>* out_children) {
30  if (!ash::Shell::HasInstance())
31    return;
32
33  // Only on ash is there a notion of a root with children.
34  aura::Window::Windows children =
35      ash::Shell::GetInstance()->GetAllRootWindows();
36  for (size_t i = 0; i < children.size(); ++i) {
37    out_children->push_back(
38        views::AXAuraObjCache::GetInstance()->GetOrCreate(children[i]));
39  }
40}
41
42void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
43  out_node_data->id = id_;
44  out_node_data->role = ui::AX_ROLE_DESKTOP;
45  // TODO(dtseng): Apply a richer set of states.
46  out_node_data->state = 0;
47}
48
49int32 AXRootObjWrapper::GetID() {
50  return id_;
51}
52