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/extensions/extension_tab_util.h" | 11 #include "chrome/browser/extensions/extension_tab_util.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/common/extensions/api/automation_internal.h" | 14 #include "chrome/common/extensions/api/automation_internal.h" |
15 #include "chrome/common/extensions/manifest_handlers/automation.h" | 15 #include "chrome/common/extensions/manifest_handlers/automation.h" |
16 #include "content/public/browser/ax_event_notification_details.h" | 16 #include "content/public/browser/ax_event_notification_details.h" |
17 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/render_widget_host.h" | 19 #include "content/public/browser/render_widget_host.h" |
20 #include "content/public/browser/render_widget_host_view.h" | 20 #include "content/public/browser/render_widget_host_view.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "extensions/common/error_utils.h" | |
23 #include "extensions/common/permissions/permissions_data.h" | 22 #include "extensions/common/permissions/permissions_data.h" |
24 | 23 |
25 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
26 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" | 25 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" |
27 #endif | 26 #endif |
28 | 27 |
29 namespace extensions { | 28 namespace extensions { |
30 class AutomationWebContentsObserver; | 29 class AutomationWebContentsObserver; |
31 } // namespace extensions | 30 } // namespace extensions |
32 | 31 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 content::WebContents* contents = | 134 content::WebContents* contents = |
136 tab_strip->GetWebContentsAt(tab_strip->active_index()); | 135 tab_strip->GetWebContentsAt(tab_strip->active_index()); |
137 if (!contents) | 136 if (!contents) |
138 return RespondNow(Error("No active tab")); | 137 return RespondNow(Error("No active tab")); |
139 content::RenderWidgetHost* rwh = | 138 content::RenderWidgetHost* rwh = |
140 contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); | 139 contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); |
141 if (!rwh) | 140 if (!rwh) |
142 return RespondNow(Error("Could not enable accessibility for active tab")); | 141 return RespondNow(Error("Could not enable accessibility for active tab")); |
143 | 142 |
144 if (!CanRequestAutomation(GetExtension(), automation_info, contents)) { | 143 if (!CanRequestAutomation(GetExtension(), automation_info, contents)) { |
145 return RespondNow(Error(ErrorUtils::FormatErrorMessage( | 144 return RespondNow( |
146 kCannotRequestAutomationOnPage, contents->GetURL().spec()))); | 145 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec())); |
147 } | 146 } |
148 AutomationWebContentsObserver::CreateForWebContents(contents); | 147 AutomationWebContentsObserver::CreateForWebContents(contents); |
149 rwh->EnableTreeOnlyAccessibilityMode(); | 148 rwh->EnableTreeOnlyAccessibilityMode(); |
150 return RespondNow( | 149 return RespondNow( |
151 ArgumentList(api::automation_internal::EnableCurrentTab::Results::Create( | 150 ArgumentList(api::automation_internal::EnableCurrentTab::Results::Create( |
152 rwh->GetProcess()->GetID(), rwh->GetRoutingID()))); | 151 rwh->GetProcess()->GetID(), rwh->GetRoutingID()))); |
153 } | 152 } |
154 | 153 |
155 ExtensionFunction::ResponseAction | 154 ExtensionFunction::ResponseAction |
156 AutomationInternalPerformActionFunction::Run() { | 155 AutomationInternalPerformActionFunction::Run() { |
(...skipping 18 matching lines...) Expand all Loading... |
175 content::RenderWidgetHost* rwh = content::RenderWidgetHost::FromID( | 174 content::RenderWidgetHost* rwh = content::RenderWidgetHost::FromID( |
176 params->args.process_id, params->args.routing_id); | 175 params->args.process_id, params->args.routing_id); |
177 | 176 |
178 if (!rwh) | 177 if (!rwh) |
179 return RespondNow(Error("Ignoring action on destroyed node")); | 178 return RespondNow(Error("Ignoring action on destroyed node")); |
180 if (rwh->IsRenderView()) { | 179 if (rwh->IsRenderView()) { |
181 const content::RenderViewHost* rvh = content::RenderViewHost::From(rwh); | 180 const content::RenderViewHost* rvh = content::RenderViewHost::From(rwh); |
182 const content::WebContents* contents = | 181 const content::WebContents* contents = |
183 content::WebContents::FromRenderViewHost(rvh); | 182 content::WebContents::FromRenderViewHost(rvh); |
184 if (!CanRequestAutomation(GetExtension(), automation_info, contents)) { | 183 if (!CanRequestAutomation(GetExtension(), automation_info, contents)) { |
185 return RespondNow(Error(ErrorUtils::FormatErrorMessage( | 184 return RespondNow( |
186 kCannotRequestAutomationOnPage, contents->GetURL().spec()))); | 185 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec())); |
187 } | 186 } |
188 } | 187 } |
189 RenderWidgetHostActionAdapter adapter(rwh); | 188 RenderWidgetHostActionAdapter adapter(rwh); |
190 return RouteActionToAdapter(params.get(), &adapter); | 189 return RouteActionToAdapter(params.get(), &adapter); |
191 } | 190 } |
192 | 191 |
193 ExtensionFunction::ResponseAction | 192 ExtensionFunction::ResponseAction |
194 AutomationInternalPerformActionFunction::RouteActionToAdapter( | 193 AutomationInternalPerformActionFunction::RouteActionToAdapter( |
195 api::automation_internal::PerformAction::Params* params, | 194 api::automation_internal::PerformAction::Params* params, |
196 AutomationActionAdapter* adapter) { | 195 AutomationActionAdapter* adapter) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return RespondNow(Error("desktop permission must be requested")); | 228 return RespondNow(Error("desktop permission must be requested")); |
230 | 229 |
231 AutomationManagerAsh::GetInstance()->Enable(browser_context()); | 230 AutomationManagerAsh::GetInstance()->Enable(browser_context()); |
232 return RespondNow(NoArguments()); | 231 return RespondNow(NoArguments()); |
233 #else | 232 #else |
234 return RespondNow(Error("getDesktop is unsupported by this platform")); | 233 return RespondNow(Error("getDesktop is unsupported by this platform")); |
235 #endif // defined(OS_CHROMEOS) | 234 #endif // defined(OS_CHROMEOS) |
236 } | 235 } |
237 | 236 |
238 } // namespace extensions | 237 } // namespace extensions |
OLD | NEW |