OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
David Tseng
2015/06/10 15:56:31
Is this class being used anywhere else? If not, th
aboxhall
2015/06/11 15:05:38
Also, wrong year :)
dmazzoni
2015/06/11 19:09:11
OK, moved back to automation_internal_api.cc
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/extensions/api/automation_internal/automation_web_conte nts_observer.h" | |
6 | |
7 #include "chrome/browser/accessibility/ax_tree_id_registry.h" | |
8 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou ter.h" | |
9 #include "chrome/common/extensions/chrome_extension_messages.h" | |
10 #include "content/public/browser/render_frame_host.h" | |
11 #include "content/public/browser/render_process_host.h" | |
12 | |
13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver); | |
14 | |
15 namespace extensions { | |
16 | |
17 void AutomationWebContentsObserver::AccessibilityEventReceived( | |
18 const std::vector<content::AXEventNotificationDetails>& details) { | |
19 std::vector<content::AXEventNotificationDetails>::const_iterator iter = | |
20 details.begin(); | |
21 for (; iter != details.end(); ++iter) { | |
22 const content::AXEventNotificationDetails& event = *iter; | |
23 int tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( | |
24 event.process_id, event.routing_id); | |
25 ExtensionMsg_AccessibilityEventParams params; | |
26 params.tree_id = tree_id; | |
27 params.id = event.id; | |
28 params.event_type = event.event_type; | |
29 params.update.node_id_to_clear = event.node_id_to_clear; | |
30 params.update.nodes = event.nodes; | |
31 params.location_offset = | |
32 web_contents()->GetContainerBounds().OffsetFromOrigin(); | |
33 | |
34 AutomationEventRouter* router = AutomationEventRouter::GetInstance(); | |
35 router->DispatchAccessibilityEvent(params); | |
36 } | |
37 } | |
38 | |
39 void AutomationWebContentsObserver::RenderFrameDeleted( | |
40 content::RenderFrameHost* render_frame_host) { | |
41 int tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( | |
42 render_frame_host->GetProcess()->GetID(), | |
43 render_frame_host->GetRoutingID()); | |
44 AXTreeIDRegistry::GetInstance()->RemoveAXTreeID(tree_id); | |
45 | |
46 AutomationEventRouter::GetInstance()->DispatchTreeDestroyedEvent( | |
47 tree_id, | |
48 browser_context_); | |
49 } | |
50 | |
51 AutomationWebContentsObserver::AutomationWebContentsObserver( | |
52 content::WebContents* web_contents) | |
53 : content::WebContentsObserver(web_contents), | |
54 browser_context_(web_contents->GetBrowserContext()) {} | |
55 | |
56 } // namespace extensions | |
OLD | NEW |