| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/accessibility/ax_tree_id_registry.h" | 12 #include "chrome/browser/accessibility/ax_tree_id_registry.h" |
| 13 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad
apter.h" | 13 #include "chrome/browser/extensions/api/automation_internal/automation_action_ad
apter.h" |
| 14 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" | 14 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" |
| 15 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 15 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/extensions/api/automation_internal.h" | 21 #include "chrome/common/extensions/api/automation_internal.h" |
| 21 #include "chrome/common/extensions/manifest_handlers/automation.h" | 22 #include "chrome/common/extensions/manifest_handlers/automation.h" |
| 22 #include "content/public/browser/ax_event_notification_details.h" | 23 #include "content/public/browser/ax_event_notification_details.h" |
| 23 #include "content/public/browser/browser_accessibility_state.h" | 24 #include "content/public/browser/browser_accessibility_state.h" |
| 24 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
| 25 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/render_widget_host.h" | 28 #include "content/public/browser/render_widget_host.h" |
| 28 #include "content/public/browser/render_widget_host_view.h" | 29 #include "content/public/browser/render_widget_host_view.h" |
| 29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| 30 #include "extensions/common/extension_messages.h" | 31 #include "extensions/common/extension_messages.h" |
| 31 #include "extensions/common/permissions/permissions_data.h" | 32 #include "extensions/common/permissions/permissions_data.h" |
| 32 | 33 |
| 33 #if defined(OS_CHROMEOS) | |
| 34 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" | |
| 35 #endif | |
| 36 | |
| 37 namespace extensions { | 34 namespace extensions { |
| 38 class AutomationWebContentsObserver; | 35 class AutomationWebContentsObserver; |
| 39 } // namespace extensions | 36 } // namespace extensions |
| 40 | 37 |
| 41 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver); | 38 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::AutomationWebContentsObserver); |
| 42 | 39 |
| 43 namespace extensions { | 40 namespace extensions { |
| 44 | 41 |
| 45 namespace { | 42 namespace { |
| 46 const int kDesktopTreeID = 0; | 43 const int kDesktopTreeID = 0; |
| (...skipping 295 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) | |
| 353 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 349 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 354 if (!automation_info || !automation_info->desktop) | 350 if (!automation_info || !automation_info->desktop) |
| 355 return RespondNow(Error("desktop permission must be requested")); | 351 return RespondNow(Error("desktop permission must be requested")); |
| 356 | 352 |
| 357 AutomationManagerAsh::GetInstance()->Enable(browser_context()); | 353 AutomationManagerAsh::GetInstance()->Enable(browser_context()); |
| 358 return RespondNow(NoArguments()); | 354 return RespondNow(NoArguments()); |
| 359 #else | |
| 360 return RespondNow(Error("getDesktop is unsupported by this platform")); | |
| 361 #endif // defined(OS_CHROMEOS) | |
| 362 } | 355 } |
| 363 | 356 |
| 364 // static | 357 // static |
| 365 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; | 358 int AutomationInternalQuerySelectorFunction::query_request_id_counter_ = 0; |
| 366 | 359 |
| 367 ExtensionFunction::ResponseAction | 360 ExtensionFunction::ResponseAction |
| 368 AutomationInternalQuerySelectorFunction::Run() { | 361 AutomationInternalQuerySelectorFunction::Run() { |
| 369 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); | 362 const AutomationInfo* automation_info = AutomationInfo::Get(extension()); |
| 370 EXTENSION_FUNCTION_VALIDATE(automation_info); | 363 EXTENSION_FUNCTION_VALIDATE(automation_info); |
| 371 | 364 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 int result_acc_obj_id) { | 396 int result_acc_obj_id) { |
| 404 if (!error.empty()) { | 397 if (!error.empty()) { |
| 405 Respond(Error(error)); | 398 Respond(Error(error)); |
| 406 return; | 399 return; |
| 407 } | 400 } |
| 408 | 401 |
| 409 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); | 402 Respond(OneArgument(new base::FundamentalValue(result_acc_obj_id))); |
| 410 } | 403 } |
| 411 | 404 |
| 412 } // namespace extensions | 405 } // namespace extensions |
| OLD | NEW |