| Index: chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
|
| diff --git a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
|
| index 5c2ebe85608bcf195f7fb63da32a0fd3b963b983..5f2e8c862a18f3231547b456665f47539d5e59b7 100644
|
| --- a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
|
| +++ b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
|
| @@ -12,6 +12,7 @@
|
| #include "chrome/browser/accessibility/ax_tree_id_registry.h"
|
| #include "chrome/browser/extensions/api/automation_internal/automation_action_adapter.h"
|
| #include "chrome/browser/extensions/api/automation_internal/automation_event_router.h"
|
| +#include "chrome/browser/extensions/api/automation_internal/automation_util.h"
|
| #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| @@ -28,8 +29,6 @@
|
| #include "content/public/browser/render_widget_host.h"
|
| #include "content/public/browser/render_widget_host_view.h"
|
| #include "content/public/browser/web_contents.h"
|
| -#include "content/public/browser/web_contents_observer.h"
|
| -#include "content/public/browser/web_contents_user_data.h"
|
| #include "extensions/common/extension_messages.h"
|
| #include "extensions/common/permissions/permissions_data.h"
|
|
|
| @@ -46,7 +45,6 @@
|
| namespace extensions {
|
|
|
| namespace {
|
| -
|
| const int kDesktopTreeID = 0;
|
| const char kCannotRequestAutomationOnPage[] =
|
| "Cannot request automation tree on url \"*\". "
|
| @@ -195,41 +193,24 @@
|
| void AccessibilityEventReceived(
|
| const std::vector<content::AXEventNotificationDetails>& details)
|
| override {
|
| - 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);
|
| - }
|
| + automation_util::DispatchAccessibilityEventsToAutomation(
|
| + details, browser_context_,
|
| + web_contents()->GetContainerBounds().OffsetFromOrigin());
|
| }
|
|
|
| void RenderFrameDeleted(
|
| content::RenderFrameHost* render_frame_host) override {
|
| - int tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID(
|
| + automation_util::DispatchTreeDestroyedEventToAutomation(
|
| render_frame_host->GetProcess()->GetID(),
|
| - render_frame_host->GetRoutingID());
|
| - AXTreeIDRegistry::GetInstance()->RemoveAXTreeID(tree_id);
|
| - AutomationEventRouter::GetInstance()->DispatchTreeDestroyedEvent(
|
| - tree_id,
|
| + render_frame_host->GetRoutingID(),
|
| browser_context_);
|
| }
|
|
|
| private:
|
| friend class content::WebContentsUserData<AutomationWebContentsObserver>;
|
|
|
| - explicit AutomationWebContentsObserver(content::WebContents* web_contents)
|
| + AutomationWebContentsObserver(
|
| + content::WebContents* web_contents)
|
| : content::WebContentsObserver(web_contents),
|
| browser_context_(web_contents->GetBrowserContext()) {}
|
|
|
| @@ -264,7 +245,6 @@
|
| if (!contents)
|
| return RespondNow(Error("No active tab"));
|
| }
|
| -
|
| content::RenderFrameHost* rfh = contents->GetMainFrame();
|
| if (!rfh)
|
| return RespondNow(Error("Could not enable accessibility for active tab"));
|
| @@ -276,7 +256,6 @@
|
|
|
| AutomationWebContentsObserver::CreateForWebContents(contents);
|
| contents->EnableTreeOnlyAccessibilityMode();
|
| -
|
| int ax_tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID(
|
| rfh->GetProcess()->GetID(), rfh->GetRoutingID());
|
|
|
| @@ -291,12 +270,11 @@
|
| }
|
|
|
| ExtensionFunction::ResponseAction AutomationInternalEnableFrameFunction::Run() {
|
| - // TODO(dtseng): Limited to desktop tree for now pending out of proc iframes.
|
| +// TODO(dtseng): Limited to desktop tree for now pending out of proc iframes.
|
| using api::automation_internal::EnableFrame::Params;
|
|
|
| scoped_ptr<Params> params(Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| -
|
| AXTreeIDRegistry::FrameID frame_id =
|
| AXTreeIDRegistry::GetInstance()->GetFrameID(params->tree_id);
|
| content::RenderFrameHost* rfh =
|
|
|