native_widget_ns_window_host_helper.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2018 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 COMPONENTS_REMOTE_COCOA_APP_SHIM_NATIVE_WIDGET_NS_WINDOW_HOST_HELPER_H_
  5. #define COMPONENTS_REMOTE_COCOA_APP_SHIM_NATIVE_WIDGET_NS_WINDOW_HOST_HELPER_H_
  6. #include "components/remote_cocoa/app_shim/remote_cocoa_app_shim_export.h"
  7. #include "ui/base/ui_base_types.h"
  8. #include "ui/events/event_utils.h"
  9. #include "ui/gfx/decorated_text.h"
  10. #include "ui/gfx/geometry/point.h"
  11. @class NSView;
  12. namespace ui {
  13. class TextInputClient;
  14. } // namespace ui
  15. namespace remote_cocoa {
  16. class DragDropClient;
  17. // This is a helper class for the mojo interface NativeWidgetNSWindowHost.
  18. // This provides an easier-to-use interface than the mojo for selected
  19. // functions. It also is temporarily exposing functionality that is not yet
  20. // implemented over mojo.
  21. class REMOTE_COCOA_APP_SHIM_EXPORT NativeWidgetNSWindowHostHelper {
  22. public:
  23. virtual ~NativeWidgetNSWindowHostHelper() = default;
  24. // Retrieve the NSObject for accessibility for this widget.
  25. virtual id GetNativeViewAccessible() = 0;
  26. // Synchronously dispatch a key event. Note that this function will modify
  27. // |event| based on whether or not it was handled.
  28. virtual void DispatchKeyEvent(ui::KeyEvent* event) = 0;
  29. // Synchronously dispatch a key event to the current menu controller (if one
  30. // exists and it is owned by the widget for this). Return true if the event
  31. // was swallowed (that is, if the menu's dispatch returned
  32. // POST_DISPATCH_NONE). Note that this function will modify |event| based on
  33. // whether or not it was handled.
  34. virtual bool DispatchKeyEventToMenuController(ui::KeyEvent* event) = 0;
  35. // Synchronously query the quicklook text at |location_in_content|. Return in
  36. // |found_word| whether or not a word was found.
  37. // TODO(ccameron): This needs gfx::DecoratedText to be mojo-ified before it
  38. // can be done over mojo.
  39. virtual void GetWordAt(const gfx::Point& location_in_content,
  40. bool* found_word,
  41. gfx::DecoratedText* decorated_word,
  42. gfx::Point* baseline_point) = 0;
  43. // Return a pointer to host's DragDropClientMac.
  44. // TODO(ccameron): Drag-drop behavior needs to be implemented over mojo.
  45. virtual DragDropClient* GetDragDropClient() = 0;
  46. // Return a pointer to the host's ui::TextInputClient.
  47. // TODO(ccameron): Remove the needs for this call.
  48. virtual ui::TextInputClient* GetTextInputClient() = 0;
  49. // Return whether or not the nested run loop to animate in a sheet must be
  50. // made on a fresh stack, produced by posting a task to make the call.
  51. // https://crbug.com/1234509
  52. virtual bool MustPostTaskToRunModalSheetAnimation() const = 0;
  53. };
  54. } // namespace remote_cocoa
  55. #endif // COMPONENTS_REMOTE_COCOA_APP_SHIM_NATIVE_WIDGET_NS_WINDOW_HOST_HELPER_H_