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 "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "content/public/browser/browser_accessibility_state.h" | 23 #include "content/public/browser/browser_accessibility_state.h" |
24 #include "content/public/browser/render_frame_host.h" | 24 #include "content/public/browser/render_frame_host.h" |
25 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/render_widget_host.h" | 27 #include "content/public/browser/render_widget_host.h" |
28 #include "content/public/browser/render_widget_host_view.h" | 28 #include "content/public/browser/render_widget_host_view.h" |
29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
30 #include "extensions/common/extension_messages.h" | 30 #include "extensions/common/extension_messages.h" |
31 #include "extensions/common/permissions/permissions_data.h" | 31 #include "extensions/common/permissions/permissions_data.h" |
32 | 32 |
33 #if defined(OS_CHROMEOS) | 33 #if defined(USE_AURA) |
34 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" | 34 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" |
35 #endif | 35 #endif |
36 | 36 |
37 namespace extensions { | 37 namespace extensions { |
38 class AutomationWebContentsObserver; | 38 class AutomationWebContentsObserver; |
39 } // namespace extensions | 39 } // namespace extensions |
40 | 40 |
41 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver); | 41 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver); |
42 | 42 |
43 namespace extensions { | 43 namespace extensions { |
44 | 44 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 AutomationWebContentsObserver::CreateForWebContents(contents); | 250 AutomationWebContentsObserver::CreateForWebContents(contents); |
251 contents->EnableTreeOnlyAccessibilityMode(); | 251 contents->EnableTreeOnlyAccessibilityMode(); |
252 int ax_tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( | 252 int ax_tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( |
253 rfh->GetProcess()->GetID(), rfh->GetRoutingID()); | 253 rfh->GetProcess()->GetID(), rfh->GetRoutingID()); |
254 return RespondNow(ArgumentList( | 254 return RespondNow(ArgumentList( |
255 api::automation_internal::EnableTab::Results::Create(ax_tree_id))); | 255 api::automation_internal::EnableTab::Results::Create(ax_tree_id))); |
256 } | 256 } |
257 | 257 |
258 ExtensionFunction::ResponseAction AutomationInternalEnableFrameFunction::Run() { | 258 ExtensionFunction::ResponseAction AutomationInternalEnableFrameFunction::Run() { |
259 // TODO(dtseng): Limited to desktop tree for now pending out of proc iframes. | 259 // TODO(dtseng): Limited to desktop tree for now pending out of proc iframes. |
260 #if defined(OS_CHROMEOS) | |
261 using api::automation_internal::EnableFrame::Params; | 260 using api::automation_internal::EnableFrame::Params; |
262 | 261 |
263 scoped_ptr<Params> params(Params::Create(*args_)); | 262 scoped_ptr<Params> params(Params::Create(*args_)); |
264 EXTENSION_FUNCTION_VALIDATE(params.get()); | 263 EXTENSION_FUNCTION_VALIDATE(params.get()); |
265 AXTreeIDRegistry::FrameID frame_id = | 264 AXTreeIDRegistry::FrameID frame_id = |
266 AXTreeIDRegistry::GetInstance()->GetFrameID(params->tree_id); | 265 AXTreeIDRegistry::GetInstance()->GetFrameID(params->tree_id); |
267 content::RenderFrameHost* rfh = | 266 content::RenderFrameHost* rfh = |
268 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); | 267 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); |
269 if (!rfh) | 268 if (!rfh) |
270 return RespondNow(Error("unable to load tab")); | 269 return RespondNow(Error("unable to load tab")); |
271 | 270 |
272 content::WebContents* contents = | 271 content::WebContents* contents = |
273 content::WebContents::FromRenderFrameHost(rfh); | 272 content::WebContents::FromRenderFrameHost(rfh); |
274 AutomationWebContentsObserver::CreateForWebContents(contents); | 273 AutomationWebContentsObserver::CreateForWebContents(contents); |
275 contents->EnableTreeOnlyAccessibilityMode(); | 274 contents->EnableTreeOnlyAccessibilityMode(); |
276 | 275 |
277 return RespondNow(NoArguments()); | 276 return RespondNow(NoArguments()); |
278 #endif | |
279 return RespondNow(Error("enableFrame is only supported on Chrome OS")); | |
280 } | 277 } |
281 | 278 |
282 ExtensionFunction::ResponseAction | 279 ExtensionFunction::ResponseAction |
283 AutomationInternalPerformActionFunction::Run() { | 280 AutomationInternalPerformActionFunction::Run() { |
284 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 281 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
285 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); | 282 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); |
286 | 283 |
287 using api::automation_internal::PerformAction::Params; | 284 using api::automation_internal::PerformAction::Params; |
288 scoped_ptr<Params> params(Params::Create(*args_)); | 285 scoped_ptr<Params> params(Params::Create(*args_)); |
289 EXTENSION_FUNCTION_VALIDATE(params.get()); | 286 EXTENSION_FUNCTION_VALIDATE(params.get()); |
290 | 287 |
291 if (params->args.tree_id == kDesktopTreeID) { | 288 if (params->args.tree_id == kDesktopTreeID) { |
292 #if defined(OS_CHROMEOS) | 289 #if defined(USE_AURA) |
293 return RouteActionToAdapter( | 290 return RouteActionToAdapter(params.get(), |
294 params.get(), AutomationManagerAsh::GetInstance()); | 291 AutomationManagerAura::GetInstance()); |
295 #else | 292 #else |
296 NOTREACHED(); | 293 NOTREACHED(); |
297 return RespondNow(Error("Unexpected action on desktop automation tree;" | 294 return RespondNow(Error("Unexpected action on desktop automation tree;" |
298 " platform does not support desktop automation")); | 295 " platform does not support desktop automation")); |
299 #endif // defined(OS_CHROMEOS) | 296 #endif // defined(USE_AURA) |
300 } | 297 } |
301 AXTreeIDRegistry::FrameID frame_id = | 298 AXTreeIDRegistry::FrameID frame_id = |
302 AXTreeIDRegistry::GetInstance()->GetFrameID(params->args.tree_id); | 299 AXTreeIDRegistry::GetInstance()->GetFrameID(params->args.tree_id); |
303 content::RenderFrameHost* rfh = | 300 content::RenderFrameHost* rfh = |
304 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); | 301 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); |
305 if (!rfh) | 302 if (!rfh) |
306 return RespondNow(Error("Ignoring action on destroyed node")); | 303 return RespondNow(Error("Ignoring action on destroyed node")); |
307 | 304 |
308 const content::WebContents* contents = | 305 const content::WebContents* contents = |
309 content::WebContents::FromRenderFrameHost(rfh); | 306 content::WebContents::FromRenderFrameHost(rfh); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 break; | 339 break; |
343 } | 340 } |
344 default: | 341 default: |
345 NOTREACHED(); | 342 NOTREACHED(); |
346 } | 343 } |
347 return RespondNow(NoArguments()); | 344 return RespondNow(NoArguments()); |
348 } | 345 } |
349 | 346 |
350 ExtensionFunction::ResponseAction | 347 ExtensionFunction::ResponseAction |
351 AutomationInternalEnableDesktopFunction::Run() { | 348 AutomationInternalEnableDesktopFunction::Run() { |
352 #if defined(OS_CHROMEOS) | 349 #if defined(USE_AURA) |
353 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 350 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
354 if (!automation_info || !automation_info->desktop) | 351 if (!automation_info || !automation_info->desktop) |
355 return RespondNow(Error("desktop permission must be requested")); | 352 return RespondNow(Error("desktop permission must be requested")); |
356 | 353 |
357 AutomationManagerAsh::GetInstance()->Enable(browser_context()); | 354 AutomationManagerAura::GetInstance()->Enable(browser_context()); |
358 return RespondNow(NoArguments()); | 355 return RespondNow(NoArguments()); |
359 #else | 356 #else |
360 return RespondNow(Error("getDesktop is unsupported by this platform")); | 357 return RespondNow(Error("getDesktop is unsupported by this platform")); |
361 #endif // defined(OS_CHROMEOS) | 358 #endif // defined(USE_AURA) |
362 } | 359 } |
363 | 360 |
364 // static | 361 // static |
365 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; | 362 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; |
366 | 363 |
367 ExtensionFunction::ResponseAction | 364 ExtensionFunction::ResponseAction |
368 AutomationInternalQuerySelectorFunction::Run() { | 365 AutomationInternalQuerySelectorFunction::Run() { |
369 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 366 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
370 EXTENSION_FUNCTION_VALIDATE(automation_info); | 367 EXTENSION_FUNCTION_VALIDATE(automation_info); |
371 | 368 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 int result_acc_obj_id) { | 400 int result_acc_obj_id) { |
404 if (!error.empty()) { | 401 if (!error.empty()) { |
405 Respond(Error(error)); | 402 Respond(Error(error)); |
406 return; | 403 return; |
407 } | 404 } |
408 | 405 |
409 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); | 406 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); |
410 } | 407 } |
411 | 408 |
412 } // namespace extensions | 409 } // namespace extensions |
OLD | NEW |