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

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

Issue 1251723003: Revert of Re-land: Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 scoped_ptr<base::ListValue> args( 72 scoped_ptr<base::ListValue> args(
74 api::automation_internal::OnAccessibilityTreeDestroyed::Create(tree_id)); 73 api::automation_internal::OnAccessibilityTreeDestroyed::Create(tree_id));
75 scoped_ptr<Event> event(new Event( 74 scoped_ptr<Event> event(new Event(
76 events::AUTOMATION_INTERNAL_ON_ACCESSIBILITY_TREE_DESTROYED, 75 events::AUTOMATION_INTERNAL_ON_ACCESSIBILITY_TREE_DESTROYED,
(...skipping 10 matching lines...) Expand all
87 } 86 }
88 87
89 void AutomationEventRouter::Register( 88 void AutomationEventRouter::Register(
90 int listener_process_id, 89 int listener_process_id,
91 int listener_routing_id, 90 int listener_routing_id,
92 int ax_tree_id, 91 int ax_tree_id,
93 bool desktop) { 92 bool desktop) {
94 auto iter = std::find_if( 93 auto iter = std::find_if(
95 listeners_.begin(), 94 listeners_.begin(),
96 listeners_.end(), 95 listeners_.end(),
97 [listener_process_id, listener_routing_id]( 96 [listener_process_id, listener_routing_id](AutomationListener& item) {
98 const AutomationListener& item) {
99 return (item.process_id == listener_process_id && 97 return (item.process_id == listener_process_id &&
100 item.routing_id == listener_routing_id); 98 item.routing_id == listener_routing_id);
101 }); 99 });
102 100
103 // Add a new entry if we don't have one with that process and routing id. 101 // Add a new entry if we don't have one with that process and routing id.
104 if (iter == listeners_.end()) { 102 if (iter == listeners_.end()) {
105 AutomationListener listener; 103 AutomationListener listener;
106 listener.routing_id = listener_routing_id; 104 listener.routing_id = listener_routing_id;
107 listener.process_id = listener_process_id; 105 listener.process_id = listener_process_id;
108 listener.desktop = desktop; 106 listener.desktop = desktop;
(...skipping 18 matching lines...) Expand all
127 NOTREACHED(); 125 NOTREACHED();
128 return; 126 return;
129 } 127 }
130 128
131 content::RenderProcessHost* rph = 129 content::RenderProcessHost* rph =
132 content::Source<content::RenderProcessHost>(source).ptr(); 130 content::Source<content::RenderProcessHost>(source).ptr();
133 int process_id = rph->GetID(); 131 int process_id = rph->GetID();
134 std::remove_if( 132 std::remove_if(
135 listeners_.begin(), 133 listeners_.begin(),
136 listeners_.end(), 134 listeners_.end(),
137 [process_id](const AutomationListener& item) { 135 [process_id](AutomationListener& item) {
138 return item.process_id == process_id; 136 return item.process_id = process_id;
139 }); 137 });
140 } 138 }
141 139
142 } // namespace extensions 140 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698