ax_tree_server.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef AX_TREE_SERVER_H_
  5. #define AX_TREE_SERVER_H_
  6. #include <string>
  7. #include "base/callback.h"
  8. #include "build/build_config.h"
  9. #include "content/public/browser/accessibility_tree_formatter.h"
  10. #if defined(OS_WIN)
  11. #include "base/win/scoped_com_initializer.h"
  12. #endif
  13. namespace content {
  14. class AXTreeServer final {
  15. public:
  16. AXTreeServer(gfx::AcceleratedWidget widget,
  17. const base::FilePath& filters_path,
  18. bool use_json);
  19. AXTreeServer(const AccessibilityTreeFormatter::TreeSelector& selector,
  20. const base::FilePath& filters_path,
  21. bool use_json);
  22. private:
  23. using BuildTree = base::OnceCallback<std::unique_ptr<base::DictionaryValue>(
  24. AccessibilityTreeFormatter*)>;
  25. // Builds and formats the accessible tree.
  26. void Run(BuildTree build_tree,
  27. const base::FilePath& filters_path,
  28. bool use_json);
  29. // Generates property filters.
  30. std::vector<AccessibilityTreeFormatter::PropertyFilter> GetPropertyFilters(
  31. const base::FilePath& filters_path);
  32. // Formats and dumps into console the tree.
  33. void Format(AccessibilityTreeFormatter& formatter,
  34. const base::DictionaryValue& dict,
  35. bool use_json);
  36. #if defined(OS_WIN)
  37. // Only one COM initializer per thread is permitted.
  38. base::win::ScopedCOMInitializer com_initializer_;
  39. #endif
  40. DISALLOW_COPY_AND_ASSIGN(AXTreeServer);
  41. };
  42. } // namespace content
  43. #endif // AX_TREE_SERVER_H_