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

Side by Side Diff: chrome/browser/ui/views/accessibility/automation_manager_views.cc

Issue 246433012: Extend AXTreeSourceViews to handle aura::Window and views::Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: With tests. Created 6 years, 8 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 | Annotate | Revision Log
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/views/accessibility/automation_manager_views.h" 5 #include "chrome/browser/ui/views/accessibility/automation_manager_views.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" 12 #include "chrome/browser/extensions/api/automation_internal/automation_util.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "content/public/browser/ax_event_notification_details.h" 16 #include "content/public/browser/ax_event_notification_details.h"
17 #include "ui/views/accessibility/ax_aura_obj_cache.h"
18 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
17 #include "ui/views/view.h" 19 #include "ui/views/view.h"
18 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
19 21
20 // static 22 // static
21 AutomationManagerViews* AutomationManagerViews::GetInstance() { 23 AutomationManagerViews* AutomationManagerViews::GetInstance() {
22 return Singleton<AutomationManagerViews>::get(); 24 return Singleton<AutomationManagerViews>::get();
23 } 25 }
24 26
25 void AutomationManagerViews::HandleEvent(Profile* profile, 27 void AutomationManagerViews::HandleEvent(Profile* profile,
26 views::View* view, 28 views::View* view,
(...skipping 10 matching lines...) Expand all
37 return; 39 return;
38 40
39 if (!profile && g_browser_process->profile_manager()) { 41 if (!profile && g_browser_process->profile_manager()) {
40 profile = g_browser_process->profile_manager()->GetLastUsedProfile(); 42 profile = g_browser_process->profile_manager()->GetLastUsedProfile();
41 } 43 }
42 if (!profile) { 44 if (!profile) {
43 LOG(WARNING) << "Accessibility notification but no profile"; 45 LOG(WARNING) << "Accessibility notification but no profile";
44 return; 46 return;
45 } 47 }
46 48
47 if (!current_tree_.get() || 49 if (!current_tree_.get()) {
48 current_tree_->GetRoot()->GetWidget() != widget) { 50 current_tree_.reset(new views::AXTreeSourceViews());
49 current_tree_.reset(new views::AXTreeSourceViews(widget));
50 current_tree_serializer_.reset( 51 current_tree_serializer_.reset(
51 new ui::AXTreeSerializer<views::View*>(current_tree_.get())); 52 new ui::AXTreeSerializer<views::AXAuraObjWrapper*>(
52 // TODO(dtseng): Need to send a load complete and clear any previous desktop 53 current_tree_.get()));
53 // trees.
54 } 54 }
55 55
56 ui::AXTreeUpdate out_update; 56 ui::AXTreeUpdate out_update;
57 current_tree_serializer_->SerializeChanges(view, &out_update); 57 views::AXAuraObjWrapper* obj =
58 views::AXAuraObjCache::GetInstance()->GetOrCreate(view);
59 current_tree_serializer_->SerializeChanges(obj, &out_update);
58 60
59 // Route this event to special process/routing ids recognized by the 61 // Route this event to special process/routing ids recognized by the
60 // Automation API as the desktop tree. 62 // Automation API as the desktop tree.
61
62 // TODO(dtseng): Would idealy define these special desktop constants in idl. 63 // TODO(dtseng): Would idealy define these special desktop constants in idl.
63 content::AXEventNotificationDetails detail(out_update.nodes, 64 content::AXEventNotificationDetails detail(out_update.nodes,
64 event_type, 65 event_type,
65 current_tree_->GetId(view), 66 obj->GetID(),
66 0, /* process_id */ 67 0, /* process_id */
67 0 /* routing_id */); 68 0 /* routing_id */);
68 std::vector<content::AXEventNotificationDetails> details; 69 std::vector<content::AXEventNotificationDetails> details;
69 details.push_back(detail); 70 details.push_back(detail);
70 extensions::automation_util::DispatchAccessibilityEventsToAutomation( 71 extensions::automation_util::DispatchAccessibilityEventsToAutomation(
71 details, profile); 72 details, profile);
72 } 73 }
73 74
74 AutomationManagerViews::AutomationManagerViews() {} 75 AutomationManagerViews::AutomationManagerViews() {}
75 76
76 AutomationManagerViews:: ~AutomationManagerViews() {} 77 AutomationManagerViews:: ~AutomationManagerViews() {}
dmazzoni 2014/04/25 06:13:59 Some extra whitespace here from a previous change
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698