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 7b9e172edd4a407c53694185a785ae1008708929..3c41bc2c2323b73f9954399924bc13bbe17ccc84 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 \"*\". " |
@@ -178,43 +173,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()); |
@@ -241,6 +199,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")); |
@@ -252,6 +211,7 @@ AutomationInternalEnableTabFunction::Run() { |
AutomationWebContentsObserver::CreateForWebContents(contents); |
contents->EnableTreeOnlyAccessibilityMode(); |
+ |
int ax_tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( |
rfh->GetProcess()->GetID(), rfh->GetRoutingID()); |
@@ -266,11 +226,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 = |