| 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.
|
| +// 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
|
|
|