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

Unified Diff: chrome/browser/extensions/api/automation_internal/automation_web_contents_observer.cc

Issue 1155183006: Reimplement automation API on top of C++-backed AXTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@automation_faster_2
Patch Set: Rebase, delete some code that shouldn't have been commented out 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/automation_internal/automation_web_contents_observer.cc
diff --git a/chrome/browser/extensions/api/automation_internal/automation_web_contents_observer.cc b/chrome/browser/extensions/api/automation_internal/automation_web_contents_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aff7a6a6e3b9a4ddacf966807d354aa32acbb97b
--- /dev/null
+++ b/chrome/browser/extensions/api/automation_internal/automation_web_contents_observer.cc
@@ -0,0 +1,56 @@
+// 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
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/automation_internal/automation_web_contents_observer.h"
+
+#include "chrome/browser/accessibility/ax_tree_id_registry.h"
+#include "chrome/browser/extensions/api/automation_internal/automation_event_router.h"
+#include "chrome/common/extensions/chrome_extension_messages.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver);
+
+namespace extensions {
+
+void AutomationWebContentsObserver::AccessibilityEventReceived(
+ const std::vector<content::AXEventNotificationDetails>& details) {
+ std::vector<content::AXEventNotificationDetails>::const_iterator iter =
+ details.begin();
+ for (; iter != details.end(); ++iter) {
+ const content::AXEventNotificationDetails& event = *iter;
+ int tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID(
+ event.process_id, event.routing_id);
+ ExtensionMsg_AccessibilityEventParams params;
+ params.tree_id = tree_id;
+ params.id = event.id;
+ params.event_type = event.event_type;
+ params.update.node_id_to_clear = event.node_id_to_clear;
+ params.update.nodes = event.nodes;
+ params.location_offset =
+ web_contents()->GetContainerBounds().OffsetFromOrigin();
+
+ AutomationEventRouter* router = AutomationEventRouter::GetInstance();
+ router->DispatchAccessibilityEvent(params);
+ }
+}
+
+void AutomationWebContentsObserver::RenderFrameDeleted(
+ content::RenderFrameHost* render_frame_host) {
+ int tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID(
+ render_frame_host->GetProcess()->GetID(),
+ render_frame_host->GetRoutingID());
+ AXTreeIDRegistry::GetInstance()->RemoveAXTreeID(tree_id);
+
+ AutomationEventRouter::GetInstance()->DispatchTreeDestroyedEvent(
+ tree_id,
+ browser_context_);
+}
+
+AutomationWebContentsObserver::AutomationWebContentsObserver(
+ content::WebContents* web_contents)
+ : content::WebContentsObserver(web_contents),
+ browser_context_(web_contents->GetBrowserContext()) {}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698