OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/automation_internal/automation_internal_
api.h" | 5 #include "chrome/browser/extensions/api/automation_internal/automation_internal_
api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad
apter.h" | 9 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad
apter.h" |
10 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" | 10 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/common/extensions/api/automation_internal.h" | 13 #include "chrome/common/extensions/api/automation_internal.h" |
14 #include "chrome/common/extensions/manifest_handlers/automation.h" | 14 #include "chrome/common/extensions/manifest_handlers/automation.h" |
15 #include "content/public/browser/ax_event_notification_details.h" | 15 #include "content/public/browser/ax_event_notification_details.h" |
| 16 #include "content/public/browser/render_frame_host.h" |
16 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/browser/render_view_host.h" | |
18 #include "content/public/browser/render_widget_host.h" | 18 #include "content/public/browser/render_widget_host.h" |
19 #include "content/public/browser/render_widget_host_view.h" | 19 #include "content/public/browser/render_widget_host_view.h" |
20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 | 21 |
22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
23 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" | 23 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" |
24 #endif | 24 #endif |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 class AutomationWebContentsObserver; | 27 class AutomationWebContentsObserver; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 TabStripModel* tab_strip = current_browser->tab_strip_model(); | 105 TabStripModel* tab_strip = current_browser->tab_strip_model(); |
106 content::WebContents* contents = | 106 content::WebContents* contents = |
107 tab_strip->GetWebContentsAt(tab_strip->active_index()); | 107 tab_strip->GetWebContentsAt(tab_strip->active_index()); |
108 if (!contents) | 108 if (!contents) |
109 return RespondNow(Error("No active tab")); | 109 return RespondNow(Error("No active tab")); |
110 content::RenderWidgetHost* rwh = | 110 content::RenderWidgetHost* rwh = |
111 contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); | 111 contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); |
112 if (!rwh) | 112 if (!rwh) |
113 return RespondNow(Error("Could not enable accessibility for active tab")); | 113 return RespondNow(Error("Could not enable accessibility for active tab")); |
114 AutomationWebContentsObserver::CreateForWebContents(contents); | 114 AutomationWebContentsObserver::CreateForWebContents(contents); |
| 115 contents->EnableTreeOnlyAccessibilityMode(); |
115 rwh->EnableTreeOnlyAccessibilityMode(); | 116 rwh->EnableTreeOnlyAccessibilityMode(); |
116 return RespondNow( | 117 return RespondNow( |
117 ArgumentList(api::automation_internal::EnableCurrentTab::Results::Create( | 118 ArgumentList(api::automation_internal::EnableCurrentTab::Results::Create( |
118 rwh->GetProcess()->GetID(), rwh->GetRoutingID()))); | 119 rwh->GetProcess()->GetID(), rwh->GetRoutingID()))); |
119 } | 120 } |
120 | 121 |
121 ExtensionFunction::ResponseAction | 122 ExtensionFunction::ResponseAction |
122 AutomationInternalPerformActionFunction::Run() { | 123 AutomationInternalPerformActionFunction::Run() { |
123 const AutomationInfo* automation_info = AutomationInfo::Get(GetExtension()); | 124 const AutomationInfo* automation_info = AutomationInfo::Get(GetExtension()); |
124 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); | 125 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); |
125 | 126 |
126 using api::automation_internal::PerformAction::Params; | 127 using api::automation_internal::PerformAction::Params; |
127 scoped_ptr<Params> params(Params::Create(*args_)); | 128 scoped_ptr<Params> params(Params::Create(*args_)); |
128 EXTENSION_FUNCTION_VALIDATE(params.get()); | 129 EXTENSION_FUNCTION_VALIDATE(params.get()); |
129 | 130 |
130 if (params->args.process_id == kDesktopProcessID && | 131 if (params->args.process_id == kDesktopProcessID && |
131 params->args.routing_id == kDesktopRoutingID) { | 132 params->args.routing_id == kDesktopRoutingID) { |
132 #if defined(OS_CHROMEOS) | 133 #if defined(OS_CHROMEOS) |
133 return RouteActionToAdapter( | 134 return RouteActionToAdapter( |
134 params.get(), AutomationManagerAsh::GetInstance()); | 135 params.get(), AutomationManagerAsh::GetInstance()); |
135 #else | 136 #else |
136 NOTREACHED(); | 137 NOTREACHED(); |
137 return RespondNow(Error("Unexpected action on desktop automation tree;" | 138 return RespondNow(Error("Unexpected action on desktop automation tree;" |
138 " platform does not support desktop automation")); | 139 " platform does not support desktop automation")); |
139 #endif // defined(OS_CHROMEOS) | 140 #endif // defined(OS_CHROMEOS) |
140 } | 141 } |
141 content::RenderWidgetHost* rwh = content::RenderWidgetHost::FromID( | 142 content::RenderFrameHost* rfh = |
142 params->args.process_id, params->args.routing_id); | 143 content::RenderFrameHost::FromID(params->args.process_id, |
| 144 params->args.routing_id); |
143 | 145 |
144 if (!rwh) | 146 if (!rfh) |
145 return RespondNow(Error("Ignoring action on destroyed node")); | 147 return RespondNow(Error("Ignoring action on destroyed node")); |
146 | 148 |
147 RenderWidgetHostActionAdapter adapter(rwh); | 149 RenderWidgetHostActionAdapter adapter(rfh); |
148 return RouteActionToAdapter(params.get(), &adapter); | 150 return RouteActionToAdapter(params.get(), &adapter); |
149 } | 151 } |
150 | 152 |
151 ExtensionFunction::ResponseAction | 153 ExtensionFunction::ResponseAction |
152 AutomationInternalPerformActionFunction::RouteActionToAdapter( | 154 AutomationInternalPerformActionFunction::RouteActionToAdapter( |
153 api::automation_internal::PerformAction::Params* params, | 155 api::automation_internal::PerformAction::Params* params, |
154 AutomationActionAdapter* adapter) { | 156 AutomationActionAdapter* adapter) { |
155 int32 automation_id = params->args.automation_node_id; | 157 int32 automation_id = params->args.automation_node_id; |
156 switch (params->args.action_type) { | 158 switch (params->args.action_type) { |
157 case api::automation_internal::ACTION_TYPE_DODEFAULT: | 159 case api::automation_internal::ACTION_TYPE_DODEFAULT: |
(...skipping 29 matching lines...) Expand all Loading... |
187 return RespondNow(Error("desktop permission must be requested")); | 189 return RespondNow(Error("desktop permission must be requested")); |
188 | 190 |
189 AutomationManagerAsh::GetInstance()->Enable(browser_context()); | 191 AutomationManagerAsh::GetInstance()->Enable(browser_context()); |
190 return RespondNow(NoArguments()); | 192 return RespondNow(NoArguments()); |
191 #else | 193 #else |
192 return RespondNow(Error("getDesktop is unsupported by this platform")); | 194 return RespondNow(Error("getDesktop is unsupported by this platform")); |
193 #endif // defined(OS_CHROMEOS) | 195 #endif // defined(OS_CHROMEOS) |
194 } | 196 } |
195 | 197 |
196 } // namespace extensions | 198 } // namespace extensions |
OLD | NEW |