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

Side by Side Diff: chrome/browser/ui/ash/accessibility/ax_root_obj_wrapper.cc

Issue 1003283002: Enable chrome.automation.getDesktop on all aura platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 "chrome/browser/ui/ash/accessibility/ax_root_obj_wrapper.h" 5 #include "chrome/browser/ui/ash/accessibility/ax_root_obj_wrapper.h"
6 6
7 #include "ash/shell.h"
8 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
9 #include "ui/accessibility/ax_node_data.h" 8 #include "ui/accessibility/ax_node_data.h"
10 #include "ui/accessibility/ax_view_state.h" 9 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/aura/window_tree_host.h"
12 #include "ui/views/accessibility/ax_aura_obj_cache.h" 12 #include "ui/views/accessibility/ax_aura_obj_cache.h"
13 #include "ui/views/accessibility/ax_window_obj_wrapper.h" 13 #include "ui/views/accessibility/ax_window_obj_wrapper.h"
14 14
15 #if defined(OS_CHROMEOS)
16 #include "ash/shell.h"
17 #endif
18
15 AXRootObjWrapper::AXRootObjWrapper(int32 id) 19 AXRootObjWrapper::AXRootObjWrapper(int32 id)
16 : id_(id), alert_window_(new aura::Window(NULL)) { 20 : id_(id), alert_window_(new aura::Window(NULL)) {
17 } 21 }
18 22
19 AXRootObjWrapper::~AXRootObjWrapper() { 23 AXRootObjWrapper::~AXRootObjWrapper() {
20 if (alert_window_) { 24 if (alert_window_) {
21 delete alert_window_; 25 delete alert_window_;
22 alert_window_ = NULL; 26 alert_window_ = NULL;
23 } 27 }
24 } 28 }
(...skipping 13 matching lines...) Expand all
38 GetChildren(&children); 42 GetChildren(&children);
39 return std::find(children.begin(), children.end(), child) != children.end(); 43 return std::find(children.begin(), children.end(), child) != children.end();
40 } 44 }
41 45
42 views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() { 46 views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() {
43 return NULL; 47 return NULL;
44 } 48 }
45 49
46 void AXRootObjWrapper::GetChildren( 50 void AXRootObjWrapper::GetChildren(
47 std::vector<views::AXAuraObjWrapper*>* out_children) { 51 std::vector<views::AXAuraObjWrapper*>* out_children) {
48 if (!ash::Shell::HasInstance()) 52 #if defined(OS_CHROMEOS)
oshima 2015/03/20 22:31:42 I still don't quite understand why you need this.
49 return;
50
51 // Only on ash is there a notion of a root with children.
52 aura::Window::Windows children = 53 aura::Window::Windows children =
53 ash::Shell::GetInstance()->GetAllRootWindows(); 54 ash::Shell::GetInstance()->GetAllRootWindows();
54 for (size_t i = 0; i < children.size(); ++i) { 55 for (size_t i = 0; i < children.size(); ++i) {
55 out_children->push_back( 56 out_children->push_back(
56 views::AXAuraObjCache::GetInstance()->GetOrCreate(children[i])); 57 views::AXAuraObjCache::GetInstance()->GetOrCreate(children[i]));
57 } 58 }
58 59
59 out_children->push_back( 60 out_children->push_back(
60 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_)); 61 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_));
62 #else
63 views::AXAuraObjCache::GetInstance()->GetTopLevelWindows(out_children);
64 #endif
61 } 65 }
62 66
63 void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) { 67 void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
64 out_node_data->id = id_; 68 out_node_data->id = id_;
65 out_node_data->role = ui::AX_ROLE_DESKTOP; 69 out_node_data->role = ui::AX_ROLE_DESKTOP;
66 // TODO(dtseng): Apply a richer set of states. 70 // TODO(dtseng): Apply a richer set of states.
67 out_node_data->state = 0; 71 out_node_data->state = 0;
68 } 72 }
69 73
70 int32 AXRootObjWrapper::GetID() { 74 int32 AXRootObjWrapper::GetID() {
71 return id_; 75 return id_;
72 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698