| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver); | 239 DISALLOW_COPY_AND_ASSIGN(AutomationWebContentsObserver); |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 ExtensionFunction::ResponseAction | 242 ExtensionFunction::ResponseAction |
| 243 AutomationInternalEnableTabFunction::Run() { | 243 AutomationInternalEnableTabFunction::Run() { |
| 244 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 244 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 245 EXTENSION_FUNCTION_VALIDATE(automation_info); | 245 EXTENSION_FUNCTION_VALIDATE(automation_info); |
| 246 | 246 |
| 247 using api::automation_internal::EnableTab::Params; | 247 using api::automation_internal::EnableTab::Params; |
| 248 scoped_ptr<Params> params(Params::Create(*args_)); | 248 std::unique_ptr<Params> params(Params::Create(*args_)); |
| 249 EXTENSION_FUNCTION_VALIDATE(params.get()); | 249 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 250 content::WebContents* contents = NULL; | 250 content::WebContents* contents = NULL; |
| 251 if (params->args.tab_id.get()) { | 251 if (params->args.tab_id.get()) { |
| 252 int tab_id = *params->args.tab_id; | 252 int tab_id = *params->args.tab_id; |
| 253 if (!ExtensionTabUtil::GetTabById(tab_id, | 253 if (!ExtensionTabUtil::GetTabById(tab_id, |
| 254 GetProfile(), | 254 GetProfile(), |
| 255 include_incognito(), | 255 include_incognito(), |
| 256 NULL, /* browser out param*/ | 256 NULL, /* browser out param*/ |
| 257 NULL, /* tab_strip out param */ | 257 NULL, /* tab_strip out param */ |
| 258 &contents, | 258 &contents, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 288 ax_tree_id); | 288 ax_tree_id); |
| 289 | 289 |
| 290 return RespondNow(ArgumentList( | 290 return RespondNow(ArgumentList( |
| 291 api::automation_internal::EnableTab::Results::Create(ax_tree_id))); | 291 api::automation_internal::EnableTab::Results::Create(ax_tree_id))); |
| 292 } | 292 } |
| 293 | 293 |
| 294 ExtensionFunction::ResponseAction AutomationInternalEnableFrameFunction::Run() { | 294 ExtensionFunction::ResponseAction AutomationInternalEnableFrameFunction::Run() { |
| 295 // TODO(dtseng): Limited to desktop tree for now pending out of proc iframes. | 295 // TODO(dtseng): Limited to desktop tree for now pending out of proc iframes. |
| 296 using api::automation_internal::EnableFrame::Params; | 296 using api::automation_internal::EnableFrame::Params; |
| 297 | 297 |
| 298 scoped_ptr<Params> params(Params::Create(*args_)); | 298 std::unique_ptr<Params> params(Params::Create(*args_)); |
| 299 EXTENSION_FUNCTION_VALIDATE(params.get()); | 299 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 300 | 300 |
| 301 content::RenderFrameHost* rfh = | 301 content::RenderFrameHost* rfh = |
| 302 content::RenderFrameHost::FromAXTreeID(params->tree_id); | 302 content::RenderFrameHost::FromAXTreeID(params->tree_id); |
| 303 if (!rfh) | 303 if (!rfh) |
| 304 return RespondNow(Error("unable to load tab")); | 304 return RespondNow(Error("unable to load tab")); |
| 305 | 305 |
| 306 content::WebContents* contents = | 306 content::WebContents* contents = |
| 307 content::WebContents::FromRenderFrameHost(rfh); | 307 content::WebContents::FromRenderFrameHost(rfh); |
| 308 AutomationWebContentsObserver::CreateForWebContents(contents); | 308 AutomationWebContentsObserver::CreateForWebContents(contents); |
| 309 contents->EnableTreeOnlyAccessibilityMode(); | 309 contents->EnableTreeOnlyAccessibilityMode(); |
| 310 | 310 |
| 311 return RespondNow(NoArguments()); | 311 return RespondNow(NoArguments()); |
| 312 } | 312 } |
| 313 | 313 |
| 314 ExtensionFunction::ResponseAction | 314 ExtensionFunction::ResponseAction |
| 315 AutomationInternalPerformActionFunction::Run() { | 315 AutomationInternalPerformActionFunction::Run() { |
| 316 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 316 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 317 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); | 317 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); |
| 318 | 318 |
| 319 using api::automation_internal::PerformAction::Params; | 319 using api::automation_internal::PerformAction::Params; |
| 320 scoped_ptr<Params> params(Params::Create(*args_)); | 320 std::unique_ptr<Params> params(Params::Create(*args_)); |
| 321 EXTENSION_FUNCTION_VALIDATE(params.get()); | 321 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 322 | 322 |
| 323 if (params->args.tree_id == kDesktopTreeID) { | 323 if (params->args.tree_id == kDesktopTreeID) { |
| 324 #if defined(USE_AURA) | 324 #if defined(USE_AURA) |
| 325 return RouteActionToAdapter(params.get(), | 325 return RouteActionToAdapter(params.get(), |
| 326 AutomationManagerAura::GetInstance()); | 326 AutomationManagerAura::GetInstance()); |
| 327 #else | 327 #else |
| 328 NOTREACHED(); | 328 NOTREACHED(); |
| 329 return RespondNow(Error("Unexpected action on desktop automation tree;" | 329 return RespondNow(Error("Unexpected action on desktop automation tree;" |
| 330 " platform does not support desktop automation")); | 330 " platform does not support desktop automation")); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 382 } |
| 383 | 383 |
| 384 ExtensionFunction::ResponseAction | 384 ExtensionFunction::ResponseAction |
| 385 AutomationInternalEnableDesktopFunction::Run() { | 385 AutomationInternalEnableDesktopFunction::Run() { |
| 386 #if defined(USE_AURA) | 386 #if defined(USE_AURA) |
| 387 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 387 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 388 if (!automation_info || !automation_info->desktop) | 388 if (!automation_info || !automation_info->desktop) |
| 389 return RespondNow(Error("desktop permission must be requested")); | 389 return RespondNow(Error("desktop permission must be requested")); |
| 390 | 390 |
| 391 using api::automation_internal::EnableDesktop::Params; | 391 using api::automation_internal::EnableDesktop::Params; |
| 392 scoped_ptr<Params> params(Params::Create(*args_)); | 392 std::unique_ptr<Params> params(Params::Create(*args_)); |
| 393 EXTENSION_FUNCTION_VALIDATE(params.get()); | 393 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 394 | 394 |
| 395 // This gets removed when the extension process dies. | 395 // This gets removed when the extension process dies. |
| 396 AutomationEventRouter::GetInstance()->RegisterListenerWithDesktopPermission( | 396 AutomationEventRouter::GetInstance()->RegisterListenerWithDesktopPermission( |
| 397 extension_id(), | 397 extension_id(), |
| 398 source_process_id(), | 398 source_process_id(), |
| 399 params->routing_id); | 399 params->routing_id); |
| 400 | 400 |
| 401 AutomationManagerAura::GetInstance()->Enable(browser_context()); | 401 AutomationManagerAura::GetInstance()->Enable(browser_context()); |
| 402 return RespondNow(NoArguments()); | 402 return RespondNow(NoArguments()); |
| 403 #else | 403 #else |
| 404 return RespondNow(Error("getDesktop is unsupported by this platform")); | 404 return RespondNow(Error("getDesktop is unsupported by this platform")); |
| 405 #endif // defined(USE_AURA) | 405 #endif // defined(USE_AURA) |
| 406 } | 406 } |
| 407 | 407 |
| 408 // static | 408 // static |
| 409 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; | 409 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; |
| 410 | 410 |
| 411 ExtensionFunction::ResponseAction | 411 ExtensionFunction::ResponseAction |
| 412 AutomationInternalQuerySelectorFunction::Run() { | 412 AutomationInternalQuerySelectorFunction::Run() { |
| 413 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 413 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 414 EXTENSION_FUNCTION_VALIDATE(automation_info); | 414 EXTENSION_FUNCTION_VALIDATE(automation_info); |
| 415 | 415 |
| 416 using api::automation_internal::QuerySelector::Params; | 416 using api::automation_internal::QuerySelector::Params; |
| 417 scoped_ptr<Params> params(Params::Create(*args_)); | 417 std::unique_ptr<Params> params(Params::Create(*args_)); |
| 418 EXTENSION_FUNCTION_VALIDATE(params.get()); | 418 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 419 | 419 |
| 420 if (params->args.tree_id == kDesktopTreeID) { | 420 if (params->args.tree_id == kDesktopTreeID) { |
| 421 return RespondNow( | 421 return RespondNow( |
| 422 Error("domQuerySelector queries may not be used on the desktop.")); | 422 Error("domQuerySelector queries may not be used on the desktop.")); |
| 423 } | 423 } |
| 424 content::RenderFrameHost* rfh = | 424 content::RenderFrameHost* rfh = |
| 425 content::RenderFrameHost::FromAXTreeID(params->args.tree_id); | 425 content::RenderFrameHost::FromAXTreeID(params->args.tree_id); |
| 426 if (!rfh) | 426 if (!rfh) |
| 427 return RespondNow(Error("domQuerySelector query sent on destroyed tree.")); | 427 return RespondNow(Error("domQuerySelector query sent on destroyed tree.")); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 445 int result_acc_obj_id) { | 445 int result_acc_obj_id) { |
| 446 if (!error.empty()) { | 446 if (!error.empty()) { |
| 447 Respond(Error(error)); | 447 Respond(Error(error)); |
| 448 return; | 448 return; |
| 449 } | 449 } |
| 450 | 450 |
| 451 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); | 451 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); |
| 452 } | 452 } |
| 453 | 453 |
| 454 } // namespace extensions | 454 } // namespace extensions |
| OLD | NEW |