| 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 5f2e8c862a18f3231547b456665f47539d5e59b7..f5dac4c561c09361ca47151fd49647b3d7b11f66 100644
|
| --- a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
|
| +++ b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
|
| @@ -12,7 +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/automation_internal/automation_web_contents_observer.h"
|
| #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
|
| #include "chrome/browser/extensions/extension_tab_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| @@ -37,14 +37,9 @@
|
| #endif
|
|
|
| namespace extensions {
|
| -class AutomationWebContentsObserver;
|
| -} // namespace extensions
|
| -
|
| -DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver);
|
| -
|
| -namespace extensions {
|
|
|
| namespace {
|
| +
|
| const int kDesktopTreeID = 0;
|
| const char kCannotRequestAutomationOnPage[] =
|
| "Cannot request automation tree on url \"*\". "
|
| @@ -182,43 +177,6 @@ class RenderFrameHostActionAdapter : public AutomationActionAdapter {
|
|
|
| } // namespace
|
|
|
| -// Helper class that receives accessibility data from |WebContents|.
|
| -class AutomationWebContentsObserver
|
| - : public content::WebContentsObserver,
|
| - public content::WebContentsUserData<AutomationWebContentsObserver> {
|
| - public:
|
| - ~AutomationWebContentsObserver() override {}
|
| -
|
| - // content::WebContentsObserver overrides.
|
| - void AccessibilityEventReceived(
|
| - const std::vector<content::AXEventNotificationDetails>& details)
|
| - override {
|
| - automation_util::DispatchAccessibilityEventsToAutomation(
|
| - details, browser_context_,
|
| - web_contents()->GetContainerBounds().OffsetFromOrigin());
|
| - }
|
| -
|
| - void RenderFrameDeleted(
|
| - content::RenderFrameHost* render_frame_host) override {
|
| - automation_util::DispatchTreeDestroyedEventToAutomation(
|
| - render_frame_host->GetProcess()->GetID(),
|
| - render_frame_host->GetRoutingID(),
|
| - browser_context_);
|
| - }
|
| -
|
| - private:
|
| - friend class content::WebContentsUserData<AutomationWebContentsObserver>;
|
| -
|
| - AutomationWebContentsObserver(
|
| - content::WebContents* web_contents)
|
| - : content::WebContentsObserver(web_contents),
|
| - browser_context_(web_contents->GetBrowserContext()) {}
|
| -
|
| - content::BrowserContext* browser_context_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver);
|
| -};
|
| -
|
| ExtensionFunction::ResponseAction
|
| AutomationInternalEnableTabFunction::Run() {
|
| const AutomationInfo* automation_info = AutomationInfo::Get(extension());
|
| @@ -245,6 +203,7 @@ AutomationInternalEnableTabFunction::Run() {
|
| 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"));
|
| @@ -256,6 +215,7 @@ AutomationInternalEnableTabFunction::Run() {
|
|
|
| AutomationWebContentsObserver::CreateForWebContents(contents);
|
| contents->EnableTreeOnlyAccessibilityMode();
|
| +
|
| int ax_tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID(
|
| rfh->GetProcess()->GetID(), rfh->GetRoutingID());
|
|
|
| @@ -270,11 +230,12 @@ AutomationInternalEnableTabFunction::Run() {
|
| }
|
|
|
| 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 =
|
|
|