| 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(USE_AURA) | 33 #if defined(OS_CHROMEOS) |
| 34 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" | 34 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.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) |
| 260 using api::automation_internal::EnableFrame::Params; | 261 using api::automation_internal::EnableFrame::Params; |
| 261 | 262 |
| 262 scoped_ptr<Params> params(Params::Create(*args_)); | 263 scoped_ptr<Params> params(Params::Create(*args_)); |
| 263 EXTENSION_FUNCTION_VALIDATE(params.get()); | 264 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 264 AXTreeIDRegistry::FrameID frame_id = | 265 AXTreeIDRegistry::FrameID frame_id = |
| 265 AXTreeIDRegistry::GetInstance()->GetFrameID(params->tree_id); | 266 AXTreeIDRegistry::GetInstance()->GetFrameID(params->tree_id); |
| 266 content::RenderFrameHost* rfh = | 267 content::RenderFrameHost* rfh = |
| 267 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); | 268 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); |
| 268 if (!rfh) | 269 if (!rfh) |
| 269 return RespondNow(Error("unable to load tab")); | 270 return RespondNow(Error("unable to load tab")); |
| 270 | 271 |
| 271 content::WebContents* contents = | 272 content::WebContents* contents = |
| 272 content::WebContents::FromRenderFrameHost(rfh); | 273 content::WebContents::FromRenderFrameHost(rfh); |
| 273 AutomationWebContentsObserver::CreateForWebContents(contents); | 274 AutomationWebContentsObserver::CreateForWebContents(contents); |
| 274 contents->EnableTreeOnlyAccessibilityMode(); | 275 contents->EnableTreeOnlyAccessibilityMode(); |
| 275 | 276 |
| 276 return RespondNow(NoArguments()); | 277 return RespondNow(NoArguments()); |
| 278 #endif |
| 279 return RespondNow(Error("enableFrame is only supported on Chrome OS")); |
| 277 } | 280 } |
| 278 | 281 |
| 279 ExtensionFunction::ResponseAction | 282 ExtensionFunction::ResponseAction |
| 280 AutomationInternalPerformActionFunction::Run() { | 283 AutomationInternalPerformActionFunction::Run() { |
| 281 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 284 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 282 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); | 285 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); |
| 283 | 286 |
| 284 using api::automation_internal::PerformAction::Params; | 287 using api::automation_internal::PerformAction::Params; |
| 285 scoped_ptr<Params> params(Params::Create(*args_)); | 288 scoped_ptr<Params> params(Params::Create(*args_)); |
| 286 EXTENSION_FUNCTION_VALIDATE(params.get()); | 289 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 287 | 290 |
| 288 if (params->args.tree_id == kDesktopTreeID) { | 291 if (params->args.tree_id == kDesktopTreeID) { |
| 289 #if defined(USE_AURA) | 292 #if defined(OS_CHROMEOS) |
| 290 return RouteActionToAdapter(params.get(), | 293 return RouteActionToAdapter( |
| 291 AutomationManagerAura::GetInstance()); | 294 params.get(), AutomationManagerAsh::GetInstance()); |
| 292 #else | 295 #else |
| 293 NOTREACHED(); | 296 NOTREACHED(); |
| 294 return RespondNow(Error("Unexpected action on desktop automation tree;" | 297 return RespondNow(Error("Unexpected action on desktop automation tree;" |
| 295 " platform does not support desktop automation")); | 298 " platform does not support desktop automation")); |
| 296 #endif // defined(USE_AURA) | 299 #endif // defined(OS_CHROMEOS) |
| 297 } | 300 } |
| 298 AXTreeIDRegistry::FrameID frame_id = | 301 AXTreeIDRegistry::FrameID frame_id = |
| 299 AXTreeIDRegistry::GetInstance()->GetFrameID(params->args.tree_id); | 302 AXTreeIDRegistry::GetInstance()->GetFrameID(params->args.tree_id); |
| 300 content::RenderFrameHost* rfh = | 303 content::RenderFrameHost* rfh = |
| 301 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); | 304 content::RenderFrameHost::FromID(frame_id.first, frame_id.second); |
| 302 if (!rfh) | 305 if (!rfh) |
| 303 return RespondNow(Error("Ignoring action on destroyed node")); | 306 return RespondNow(Error("Ignoring action on destroyed node")); |
| 304 | 307 |
| 305 const content::WebContents* contents = | 308 const content::WebContents* contents = |
| 306 content::WebContents::FromRenderFrameHost(rfh); | 309 content::WebContents::FromRenderFrameHost(rfh); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 break; | 342 break; |
| 340 } | 343 } |
| 341 default: | 344 default: |
| 342 NOTREACHED(); | 345 NOTREACHED(); |
| 343 } | 346 } |
| 344 return RespondNow(NoArguments()); | 347 return RespondNow(NoArguments()); |
| 345 } | 348 } |
| 346 | 349 |
| 347 ExtensionFunction::ResponseAction | 350 ExtensionFunction::ResponseAction |
| 348 AutomationInternalEnableDesktopFunction::Run() { | 351 AutomationInternalEnableDesktopFunction::Run() { |
| 349 #if defined(USE_AURA) | 352 #if defined(OS_CHROMEOS) |
| 350 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 353 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 351 if (!automation_info || !automation_info->desktop) | 354 if (!automation_info || !automation_info->desktop) |
| 352 return RespondNow(Error("desktop permission must be requested")); | 355 return RespondNow(Error("desktop permission must be requested")); |
| 353 | 356 |
| 354 AutomationManagerAura::GetInstance()->Enable(browser_context()); | 357 AutomationManagerAsh::GetInstance()->Enable(browser_context()); |
| 355 return RespondNow(NoArguments()); | 358 return RespondNow(NoArguments()); |
| 356 #else | 359 #else |
| 357 return RespondNow(Error("getDesktop is unsupported by this platform")); | 360 return RespondNow(Error("getDesktop is unsupported by this platform")); |
| 358 #endif // defined(USE_AURA) | 361 #endif // defined(OS_CHROMEOS) |
| 359 } | 362 } |
| 360 | 363 |
| 361 // static | 364 // static |
| 362 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; | 365 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; |
| 363 | 366 |
| 364 ExtensionFunction::ResponseAction | 367 ExtensionFunction::ResponseAction |
| 365 AutomationInternalQuerySelectorFunction::Run() { | 368 AutomationInternalQuerySelectorFunction::Run() { |
| 366 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 369 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 367 EXTENSION_FUNCTION_VALIDATE(automation_info); | 370 EXTENSION_FUNCTION_VALIDATE(automation_info); |
| 368 | 371 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 int result_acc_obj_id) { | 403 int result_acc_obj_id) { |
| 401 if (!error.empty()) { | 404 if (!error.empty()) { |
| 402 Respond(Error(error)); | 405 Respond(Error(error)); |
| 403 return; | 406 return; |
| 404 } | 407 } |
| 405 | 408 |
| 406 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); | 409 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); |
| 407 } | 410 } |
| 408 | 411 |
| 409 } // namespace extensions | 412 } // namespace extensions |
| OLD | NEW |