| 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/ash/accessibility/automation_manager_ash.h" | 5 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" | 11 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "content/public/browser/ax_event_notification_details.h" | 13 #include "content/public/browser/ax_event_notification_details.h" |
| 14 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 15 #include "ui/aura/window.h" | |
| 16 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 15 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
| 17 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" | 16 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" |
| 18 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 19 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 20 | 19 |
| 21 using content::BrowserContext; | 20 using content::BrowserContext; |
| 22 | 21 |
| 23 // static | 22 // static |
| 24 AutomationManagerAsh* AutomationManagerAsh::GetInstance() { | 23 AutomationManagerAsh* AutomationManagerAsh::GetInstance() { |
| 25 return Singleton<AutomationManagerAsh>::get(); | 24 return Singleton<AutomationManagerAsh>::get(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 void AutomationManagerAsh::Disable() { | 35 void AutomationManagerAsh::Disable() { |
| 37 enabled_ = false; | 36 enabled_ = false; |
| 38 | 37 |
| 39 // Reset the serializer to save memory. | 38 // Reset the serializer to save memory. |
| 40 current_tree_serializer_->Reset(); | 39 current_tree_serializer_->Reset(); |
| 41 } | 40 } |
| 42 | 41 |
| 43 void AutomationManagerAsh::HandleEvent(BrowserContext* context, | 42 void AutomationManagerAsh::HandleEvent(BrowserContext* context, |
| 44 views::View* view, | 43 views::View* view, |
| 45 ui::AXEvent event_type) { | 44 ui::AXEvent event_type) { |
| 46 if (!enabled_) | 45 if (!enabled_) { |
| 47 return; | 46 return; |
| 47 } |
| 48 | 48 |
| 49 if (!context && g_browser_process->profile_manager()) | 49 if (!context && g_browser_process->profile_manager()) { |
| 50 context = g_browser_process->profile_manager()->GetLastUsedProfile(); | 50 context = g_browser_process->profile_manager()->GetLastUsedProfile(); |
| 51 | 51 } |
| 52 if (!context) { | 52 if (!context) { |
| 53 LOG(WARNING) << "Accessibility notification but no browser context"; | 53 LOG(WARNING) << "Accessibility notification but no browser context"; |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 | 56 |
| 57 views::AXAuraObjWrapper* aura_obj = | 57 views::AXAuraObjWrapper* aura_obj = |
| 58 views::AXAuraObjCache::GetInstance()->GetOrCreate(view); | 58 views::AXAuraObjCache::GetInstance()->GetOrCreate(view); |
| 59 SendEvent(context, aura_obj, event_type); | 59 SendEvent(context, aura_obj, event_type); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void AutomationManagerAsh::HandleAlert(content::BrowserContext* context, | |
| 63 const std::string& text) { | |
| 64 if (!enabled_) | |
| 65 return; | |
| 66 | |
| 67 views::AXAuraObjWrapper* obj = | |
| 68 static_cast<AXRootObjWrapper*>(current_tree_->GetRoot()) | |
| 69 ->GetAlertForText(text); | |
| 70 SendEvent(context, obj, ui::AX_EVENT_ALERT); | |
| 71 } | |
| 72 | |
| 73 void AutomationManagerAsh::DoDefault(int32 id) { | 62 void AutomationManagerAsh::DoDefault(int32 id) { |
| 74 CHECK(enabled_); | 63 CHECK(enabled_); |
| 75 current_tree_->DoDefault(id); | 64 current_tree_->DoDefault(id); |
| 76 } | 65 } |
| 77 | 66 |
| 78 void AutomationManagerAsh::Focus(int32 id) { | 67 void AutomationManagerAsh::Focus(int32 id) { |
| 79 CHECK(enabled_); | 68 CHECK(enabled_); |
| 80 current_tree_->Focus(id); | 69 current_tree_->Focus(id); |
| 81 } | 70 } |
| 82 | 71 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 update.nodes, | 103 update.nodes, |
| 115 event_type, | 104 event_type, |
| 116 aura_obj->GetID(), | 105 aura_obj->GetID(), |
| 117 0, /* process_id */ | 106 0, /* process_id */ |
| 118 0 /* routing_id */); | 107 0 /* routing_id */); |
| 119 std::vector<content::AXEventNotificationDetails> details; | 108 std::vector<content::AXEventNotificationDetails> details; |
| 120 details.push_back(detail); | 109 details.push_back(detail); |
| 121 extensions::automation_util::DispatchAccessibilityEventsToAutomation( | 110 extensions::automation_util::DispatchAccessibilityEventsToAutomation( |
| 122 details, context, gfx::Vector2d()); | 111 details, context, gfx::Vector2d()); |
| 123 } | 112 } |
| OLD | NEW |