| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 content::RenderFrameHost* rfh = contents->GetMainFrame(); | 264 content::RenderFrameHost* rfh = contents->GetMainFrame(); |
| 265 if (!rfh) | 265 if (!rfh) |
| 266 return RespondNow(Error("Could not enable accessibility for active tab")); | 266 return RespondNow(Error("Could not enable accessibility for active tab")); |
| 267 | 267 |
| 268 if (!CanRequestAutomation(extension(), automation_info, contents)) { | 268 if (!CanRequestAutomation(extension(), automation_info, contents)) { |
| 269 return RespondNow( | 269 return RespondNow( |
| 270 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec())); | 270 Error(kCannotRequestAutomationOnPage, contents->GetURL().spec())); |
| 271 } | 271 } |
| 272 | 272 |
| 273 AutomationWebContentsObserver::CreateForWebContents(contents); | 273 AutomationWebContentsObserver::CreateForWebContents(contents); |
| 274 contents->EnableTreeOnlyAccessibilityMode(); | 274 contents->EnableWebContentsOnlyAccessibilityMode(); |
| 275 | 275 |
| 276 int ax_tree_id = rfh->GetAXTreeID(); | 276 int ax_tree_id = rfh->GetAXTreeID(); |
| 277 | 277 |
| 278 // This gets removed when the extension process dies. | 278 // This gets removed when the extension process dies. |
| 279 AutomationEventRouter::GetInstance()->RegisterListenerForOneTree( | 279 AutomationEventRouter::GetInstance()->RegisterListenerForOneTree( |
| 280 extension_id(), | 280 extension_id(), |
| 281 source_process_id(), | 281 source_process_id(), |
| 282 params->args.routing_id, | 282 params->args.routing_id, |
| 283 ax_tree_id); | 283 ax_tree_id); |
| 284 | 284 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 298 if (!rfh) | 298 if (!rfh) |
| 299 return RespondNow(Error("unable to load tab")); | 299 return RespondNow(Error("unable to load tab")); |
| 300 | 300 |
| 301 content::WebContents* contents = | 301 content::WebContents* contents = |
| 302 content::WebContents::FromRenderFrameHost(rfh); | 302 content::WebContents::FromRenderFrameHost(rfh); |
| 303 AutomationWebContentsObserver::CreateForWebContents(contents); | 303 AutomationWebContentsObserver::CreateForWebContents(contents); |
| 304 | 304 |
| 305 // Only call this if this is the root of a frame tree, to avoid resetting | 305 // Only call this if this is the root of a frame tree, to avoid resetting |
| 306 // the accessibility state multiple times. | 306 // the accessibility state multiple times. |
| 307 if (!rfh->GetParent()) | 307 if (!rfh->GetParent()) |
| 308 contents->EnableTreeOnlyAccessibilityMode(); | 308 contents->EnableWebContentsOnlyAccessibilityMode(); |
| 309 | 309 |
| 310 return RespondNow(NoArguments()); | 310 return RespondNow(NoArguments()); |
| 311 } | 311 } |
| 312 | 312 |
| 313 ExtensionFunction::ResponseAction | 313 ExtensionFunction::ResponseAction |
| 314 AutomationInternalPerformActionFunction::Run() { | 314 AutomationInternalPerformActionFunction::Run() { |
| 315 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 315 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 316 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); | 316 EXTENSION_FUNCTION_VALIDATE(automation_info && automation_info->interact); |
| 317 | 317 |
| 318 using api::automation_internal::PerformAction::Params; | 318 using api::automation_internal::PerformAction::Params; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 if (!error.empty()) { | 477 if (!error.empty()) { |
| 478 Respond(Error(error)); | 478 Respond(Error(error)); |
| 479 return; | 479 return; |
| 480 } | 480 } |
| 481 | 481 |
| 482 Respond( | 482 Respond( |
| 483 OneArgument(base::MakeUnique<base::FundamentalValue>(result_acc_obj_id))); | 483 OneArgument(base::MakeUnique<base::FundamentalValue>(result_acc_obj_id))); |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace extensions | 486 } // namespace extensions |
| OLD | NEW |