| 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 "chrome/browser/ui/aura/accessibility/ax_root_obj_wrapper.h" | 5 #include "chrome/browser/ui/aura/accessibility/ax_root_obj_wrapper.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/common/channel_info.h" | 9 #include "chrome/common/channel_info.h" |
| 9 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| 10 #include "ui/accessibility/ax_node_data.h" | |
| 11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.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 AXRootObjWrapper::AXRootObjWrapper(int32_t id) | 15 AXRootObjWrapper::AXRootObjWrapper(int32_t id) |
| 16 : id_(id), alert_window_(new aura::Window(NULL)) { | 16 : id_(id), alert_window_(new aura::Window(NULL)) { |
| 17 alert_window_->Init(ui::LAYER_NOT_DRAWN); | 17 alert_window_->Init(ui::LAYER_NOT_DRAWN); |
| 18 } | 18 } |
| 19 | 19 |
| 20 AXRootObjWrapper::~AXRootObjWrapper() { | 20 AXRootObjWrapper::~AXRootObjWrapper() { |
| 21 if (alert_window_) { | 21 if (alert_window_) { |
| 22 delete alert_window_; | 22 delete alert_window_; |
| 23 alert_window_ = NULL; | 23 alert_window_ = NULL; |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 views::AXAuraObjWrapper* AXRootObjWrapper::GetAlertForText( | 27 views::AXAuraObjWrapper* AXRootObjWrapper::GetAlertForText( |
| 28 const std::string& text) { | 28 const std::string& text) { |
| 29 alert_window_->SetTitle(base::UTF8ToUTF16((text))); | 29 alert_window_->SetTitle(base::UTF8ToUTF16((text))); |
| 30 views::AXWindowObjWrapper* window_obj = | 30 views::AXWindowObjWrapper* window_obj = |
| 31 static_cast<views::AXWindowObjWrapper*>( | 31 static_cast<views::AXWindowObjWrapper*>( |
| 32 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_)); | 32 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_)); |
| 33 window_obj->set_is_alert(true); | 33 window_obj->set_is_alert(true); |
| 34 return window_obj; | 34 return window_obj; |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool AXRootObjWrapper::HasChild(views::AXAuraObjWrapper* child) { | 37 bool AXRootObjWrapper::HasChild(views::AXAuraObjWrapper* child) { |
| 38 std::vector<views::AXAuraObjWrapper*> children; | 38 std::vector<views::AXAuraObjWrapper*> children; |
| 39 GetChildren(&children); | 39 GetChildren(&children); |
| 40 return std::find(children.begin(), children.end(), child) != children.end(); | 40 return base::ContainsValue(children, child); |
| 41 } | 41 } |
| 42 | 42 |
| 43 views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() { | 43 views::AXAuraObjWrapper* AXRootObjWrapper::GetParent() { |
| 44 return NULL; | 44 return NULL; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void AXRootObjWrapper::GetChildren( | 47 void AXRootObjWrapper::GetChildren( |
| 48 std::vector<views::AXAuraObjWrapper*>* out_children) { | 48 std::vector<views::AXAuraObjWrapper*>* out_children) { |
| 49 views::AXAuraObjCache::GetInstance()->GetTopLevelWindows(out_children); | 49 views::AXAuraObjCache::GetInstance()->GetTopLevelWindows(out_children); |
| 50 out_children->push_back( | 50 out_children->push_back( |
| 51 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_)); | 51 views::AXAuraObjCache::GetInstance()->GetOrCreate(alert_window_)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) { | 54 void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) { |
| 55 out_node_data->id = id_; | 55 out_node_data->id = id_; |
| 56 out_node_data->role = ui::AX_ROLE_DESKTOP; | 56 out_node_data->role = ui::AX_ROLE_DESKTOP; |
| 57 out_node_data->AddStringAttribute(ui::AX_ATTR_CHROME_CHANNEL, | 57 out_node_data->AddStringAttribute(ui::AX_ATTR_CHROME_CHANNEL, |
| 58 chrome::GetChannelString()); | 58 chrome::GetChannelString()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 int32_t AXRootObjWrapper::GetID() { | 61 int32_t AXRootObjWrapper::GetID() { |
| 62 return id_; | 62 return id_; |
| 63 } | 63 } |
| OLD | NEW |