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

Side by Side Diff: chrome/browser/extensions/api/automation_internal/automation_event_router.cc

Issue 1198613002: Revert of Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@automation_faster_2
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/extensions/api/automation_internal/automation_event_rou ter.h" 5 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou ter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void AutomationEventRouter::DispatchAccessibilityEvent( 55 void AutomationEventRouter::DispatchAccessibilityEvent(
56 const ExtensionMsg_AccessibilityEventParams& params) { 56 const ExtensionMsg_AccessibilityEventParams& params) {
57 for (const auto& listener : listeners_) { 57 for (const auto& listener : listeners_) {
58 if (!listener.desktop && 58 if (!listener.desktop &&
59 listener.tree_ids.find(params.tree_id) == listener.tree_ids.end()) { 59 listener.tree_ids.find(params.tree_id) == listener.tree_ids.end()) {
60 continue; 60 continue;
61 } 61 }
62 62
63 content::RenderProcessHost* rph = 63 content::RenderProcessHost* rph =
64 content::RenderProcessHost::FromID(listener.process_id); 64 content::RenderProcessHost::FromID(listener.process_id);
65 rph->Send(new ExtensionMsg_AccessibilityEvent(listener.routing_id, 65 rph->Send(new ExtensionMsg_AccessibilityEvent(listener.routing_id, params));
66 params));
67 } 66 }
68 } 67 }
69 68
70 void AutomationEventRouter::DispatchTreeDestroyedEvent( 69 void AutomationEventRouter::DispatchTreeDestroyedEvent(
71 int tree_id, 70 int tree_id,
72 content::BrowserContext* browser_context) { 71 content::BrowserContext* browser_context) {
73 std::string event_name( 72 std::string event_name(
74 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName); 73 api::automation_internal::OnAccessibilityTreeDestroyed::kEventName);
75 scoped_ptr<base::ListValue> args( 74 scoped_ptr<base::ListValue> args(
76 api::automation_internal::OnAccessibilityTreeDestroyed::Create(tree_id)); 75 api::automation_internal::OnAccessibilityTreeDestroyed::Create(tree_id));
77 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 76 scoped_ptr<Event> event(new Event(event_name, args.Pass()));
78 event->restrict_to_browser_context = browser_context; 77 event->restrict_to_browser_context = browser_context;
79 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass()); 78 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass());
80 } 79 }
81 80
82 AutomationEventRouter::AutomationListener::AutomationListener() { 81 AutomationEventRouter::AutomationListener::AutomationListener() {
83 } 82 }
84 83
85 AutomationEventRouter::AutomationListener::~AutomationListener() { 84 AutomationEventRouter::AutomationListener::~AutomationListener() {
86 } 85 }
87 86
88 void AutomationEventRouter::Register( 87 void AutomationEventRouter::Register(
89 int listener_process_id, 88 int listener_process_id,
90 int listener_routing_id, 89 int listener_routing_id,
91 int ax_tree_id, 90 int ax_tree_id,
92 bool desktop) { 91 bool desktop) {
93 auto iter = std::find_if( 92 auto iter = std::find_if(
94 listeners_.begin(), 93 listeners_.begin(),
95 listeners_.end(), 94 listeners_.end(),
96 [listener_process_id, listener_routing_id]( 95 [listener_process_id, listener_routing_id](AutomationListener& item) {
97 const AutomationListener& item) {
98 return (item.process_id == listener_process_id && 96 return (item.process_id == listener_process_id &&
99 item.routing_id == listener_routing_id); 97 item.routing_id == listener_routing_id);
100 }); 98 });
101 99
102 // Add a new entry if we don't have one with that process and routing id. 100 // Add a new entry if we don't have one with that process and routing id.
103 if (iter == listeners_.end()) { 101 if (iter == listeners_.end()) {
104 AutomationListener listener; 102 AutomationListener listener;
105 listener.routing_id = listener_routing_id; 103 listener.routing_id = listener_routing_id;
106 listener.process_id = listener_process_id; 104 listener.process_id = listener_process_id;
107 listener.desktop = desktop; 105 listener.desktop = desktop;
(...skipping 18 matching lines...) Expand all
126 NOTREACHED(); 124 NOTREACHED();
127 return; 125 return;
128 } 126 }
129 127
130 content::RenderProcessHost* rph = 128 content::RenderProcessHost* rph =
131 content::Source<content::RenderProcessHost>(source).ptr(); 129 content::Source<content::RenderProcessHost>(source).ptr();
132 int process_id = rph->GetID(); 130 int process_id = rph->GetID();
133 std::remove_if( 131 std::remove_if(
134 listeners_.begin(), 132 listeners_.begin(),
135 listeners_.end(), 133 listeners_.end(),
136 [process_id](const AutomationListener& item) { 134 [process_id](AutomationListener& item) {
137 return item.process_id == process_id; 135 return item.process_id = process_id;
138 }); 136 });
139 } 137 }
140 138
141 } // namespace extensions 139 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698