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

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

Issue 743273002: Various changes required to support ChromeVox Next to read Views and Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready with changes for flip (SpokenFeedbackTest.* pass). Created 6 years 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/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"
15 #include "ui/views/accessibility/ax_aura_obj_cache.h" 16 #include "ui/views/accessibility/ax_aura_obj_cache.h"
16 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" 17 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
17 #include "ui/views/view.h" 18 #include "ui/views/view.h"
18 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
19 20
20 using content::BrowserContext; 21 using content::BrowserContext;
21 22
22 // static 23 // static
23 AutomationManagerAsh* AutomationManagerAsh::GetInstance() { 24 AutomationManagerAsh* AutomationManagerAsh::GetInstance() {
24 return Singleton<AutomationManagerAsh>::get(); 25 return Singleton<AutomationManagerAsh>::get();
25 } 26 }
26 27
27 void AutomationManagerAsh::Enable(BrowserContext* context) { 28 void AutomationManagerAsh::Enable(BrowserContext* context) {
28 enabled_ = true; 29 enabled_ = true;
29 Reset(); 30 Reset();
30 SendEvent(context, current_tree_->GetRoot(), ui::AX_EVENT_LOAD_COMPLETE); 31 SendEvent(context, current_tree_->GetRoot(), ui::AX_EVENT_LOAD_COMPLETE);
31 } 32 }
32 33
33 void AutomationManagerAsh::Disable() { 34 void AutomationManagerAsh::Disable() {
34 enabled_ = false; 35 enabled_ = false;
35 36
36 // Reset the serializer to save memory. 37 // Reset the serializer to save memory.
37 current_tree_serializer_->Reset(); 38 current_tree_serializer_->Reset();
38 } 39 }
39 40
40 void AutomationManagerAsh::HandleEvent(BrowserContext* context, 41 void AutomationManagerAsh::HandleEvent(BrowserContext* context,
41 views::View* view, 42 views::View* view,
42 ui::AXEvent event_type) { 43 ui::AXEvent event_type) {
43 if (!enabled_) { 44 if (!enabled_)
44 return; 45 return;
45 }
46 46
47 if (!context && g_browser_process->profile_manager()) { 47 if (!context && g_browser_process->profile_manager())
48 context = g_browser_process->profile_manager()->GetLastUsedProfile(); 48 context = g_browser_process->profile_manager()->GetLastUsedProfile();
49 } 49
50 if (!context) { 50 if (!context) {
51 LOG(WARNING) << "Accessibility notification but no browser context"; 51 LOG(WARNING) << "Accessibility notification but no browser context";
52 return; 52 return;
53 } 53 }
54 54
55 views::AXAuraObjWrapper* aura_obj = 55 views::AXAuraObjWrapper* aura_obj =
56 views::AXAuraObjCache::GetInstance()->GetOrCreate(view); 56 views::AXAuraObjCache::GetInstance()->GetOrCreate(view);
57 SendEvent(context, aura_obj, event_type); 57 SendEvent(context, aura_obj, event_type);
58 } 58 }
59 59
60 void AutomationManagerAsh::HandleAlert(content::BrowserContext* context,
61 const std::string& text) {
62 if (!enabled_)
63 return;
64
65 views::AXAuraObjWrapper* obj =
66 static_cast<AXRootObjWrapper*>(current_tree_->GetRoot())
67 ->GetAlertForText(text);
68 SendEvent(context, obj, ui::AX_EVENT_ALERT);
69 }
70
60 void AutomationManagerAsh::DoDefault(int32 id) { 71 void AutomationManagerAsh::DoDefault(int32 id) {
61 CHECK(enabled_); 72 CHECK(enabled_);
62 current_tree_->DoDefault(id); 73 current_tree_->DoDefault(id);
63 } 74 }
64 75
65 void AutomationManagerAsh::Focus(int32 id) { 76 void AutomationManagerAsh::Focus(int32 id) {
66 CHECK(enabled_); 77 CHECK(enabled_);
67 current_tree_->Focus(id); 78 current_tree_->Focus(id);
68 } 79 }
69 80
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 update.nodes, 113 update.nodes,
103 event_type, 114 event_type,
104 aura_obj->GetID(), 115 aura_obj->GetID(),
105 0, /* process_id */ 116 0, /* process_id */
106 0 /* routing_id */); 117 0 /* routing_id */);
107 std::vector<content::AXEventNotificationDetails> details; 118 std::vector<content::AXEventNotificationDetails> details;
108 details.push_back(detail); 119 details.push_back(detail);
109 extensions::automation_util::DispatchAccessibilityEventsToAutomation( 120 extensions::automation_util::DispatchAccessibilityEventsToAutomation(
110 details, context, gfx::Vector2d()); 121 details, context, gfx::Vector2d());
111 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698