ax_event_server.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_EVENT_SERVER_H_
  5. #define AX_EVENT_SERVER_H_
  6. #include "base/process/process_handle.h"
  7. #include "build/build_config.h"
  8. #include "content/browser/accessibility/accessibility_event_recorder.h"
  9. #if defined(OS_WIN)
  10. #include "base/win/scoped_com_initializer.h"
  11. #endif
  12. namespace tools {
  13. class AXEventServer final {
  14. public:
  15. // Dumps events into console for application identified either by process id
  16. // or tree selector.
  17. explicit AXEventServer(
  18. base::ProcessId pid,
  19. const content::AccessibilityTreeFormatter::TreeSelector& selector);
  20. ~AXEventServer();
  21. private:
  22. void OnEvent(const std::string& event) const;
  23. #if defined(OS_WIN)
  24. // Only one COM initializer per thread is permitted.
  25. base::win::ScopedCOMInitializer com_initializer_;
  26. #endif
  27. std::unique_ptr<content::AccessibilityEventRecorder> recorder_;
  28. DISALLOW_COPY_AND_ASSIGN(AXEventServer);
  29. };
  30. } // namespace tools
  31. #endif // AX_EVENT_SERVER_H_