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

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
« no previous file with comments | « chrome/browser/ui/ash/accessibility/ax_root_obj_wrapper.h ('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 "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" 7 #include "ash/shell.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/accessibility/ax_node_data.h" 9 #include "ui/accessibility/ax_node_data.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
11 #include "ui/aura/env.h"
11 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_tree_host.h"
12 #include "ui/views/accessibility/ax_aura_obj_cache.h" 14 #include "ui/views/accessibility/ax_aura_obj_cache.h"
13 #include "ui/views/accessibility/ax_window_obj_wrapper.h" 15 #include "ui/views/accessibility/ax_window_obj_wrapper.h"
14 16
15 AXRootObjWrapper::AXRootObjWrapper(int32 id) 17 AXRootObjWrapper::AXRootObjWrapper(int32 id)
16 : id_(id), alert_window_(new aura::Window(NULL)) { 18 : id_(id), alert_window_(new aura::Window(NULL)), host_(NULL) {
19 aura::Env::GetInstance()->AddObserver(this);
17 } 20 }
18 21
19 AXRootObjWrapper::~AXRootObjWrapper() { 22 AXRootObjWrapper::~AXRootObjWrapper() {
20 if (alert_window_) { 23 if (alert_window_) {
21 delete alert_window_; 24 delete alert_window_;
22 alert_window_ = NULL; 25 alert_window_ = NULL;
23 } 26 }
24 } 27 }
25 28
26 views::AXAuraObjWrapper* AXRootObjWrapper::GetAlertForText( 29 views::AXAuraObjWrapper* AXRootObjWrapper::GetAlertForText(
(...skipping 11 matching lines...) Expand all
38 GetChildren(&children); 41 GetChildren(&children);
39 return std::find(children.begin(), children.end(), child) != children.end(); 42 return std::find(children.begin(), children.end(), child) != children.end();
40 } 43 }
41 44
42 views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() { 45 views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() {
43 return NULL; 46 return NULL;
44 } 47 }
45 48
46 void AXRootObjWrapper::GetChildren( 49 void AXRootObjWrapper::GetChildren(
47 std::vector<views::AXAuraObjWrapper*>* out_children) { 50 std::vector<views::AXAuraObjWrapper*>* out_children) {
48 if (!ash::Shell::HasInstance()) 51 if (!ash::Shell::HasInstance()) {
52 if (host_) {
53 out_children->push_back(
54 views::AXAuraObjCache::GetInstance()->GetOrCreate(host_->window()));
55 }
49 return; 56 return;
sadrul 2015/03/13 20:07:01 This essentially means a WindowTreeHost was create
oshima 2015/03/13 20:40:03 Yeah, this shouldn't happen (or you shouldn't try
David Tseng 2015/03/13 21:33:53 This code is meant to handle the linux/win case wh
oshima 2015/03/13 21:58:47 If that's the case, what you check screen type to
David Tseng 2015/03/16 17:28:48 To be clear, I need to know if shell exists in ord
57 }
50 58
51 // Only on ash is there a notion of a root with children.
52 aura::Window::Windows children = 59 aura::Window::Windows children =
53 ash::Shell::GetInstance()->GetAllRootWindows(); 60 ash::Shell::GetInstance()->GetAllRootWindows();
54 for (size_t i = 0; i < children.size(); ++i) { 61 for (size_t i = 0; i < children.size(); ++i) {
55 out_children->push_back( 62 out_children->push_back(
56 views::AXAuraObjCache::GetInstance()->GetOrCreate(children[i])); 63 views::AXAuraObjCache::GetInstance()->GetOrCreate(children[i]));
57 } 64 }
58 65
59 out_children->push_back( 66 out_children->push_back(
60 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_)); 67 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_));
61 } 68 }
62 69
63 void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) { 70 void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
64 out_node_data->id = id_; 71 out_node_data->id = id_;
65 out_node_data->role = ui::AX_ROLE_DESKTOP; 72 out_node_data->role = ui::AX_ROLE_DESKTOP;
66 // TODO(dtseng): Apply a richer set of states. 73 // TODO(dtseng): Apply a richer set of states.
67 out_node_data->state = 0; 74 out_node_data->state = 0;
68 } 75 }
69 76
70 int32 AXRootObjWrapper::GetID() { 77 int32 AXRootObjWrapper::GetID() {
71 return id_; 78 return id_;
72 } 79 }
80
81 void AXRootObjWrapper::OnWindowInitialized(aura::Window* window) {
82 }
83
84 void AXRootObjWrapper::OnHostActivated(aura::WindowTreeHost* host) {
85 host_ = host;
dmazzoni 2015/03/13 20:01:43 Can't there be more than one WindowTreeHost, like
oshima 2015/03/13 20:40:03 yes, that's correct.
David Tseng 2015/03/13 21:33:53 EnvObserver is how I'm keeping track of things. I
oshima 2015/03/13 21:58:47 Can you explain how these wrapper objects are desi
David Tseng 2015/03/16 17:00:52 These wrappers adapt various objects in Aura for u
86 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/accessibility/ax_root_obj_wrapper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698