bridged_content_view.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_REMOTE_COCOA_APP_SHIM_BRIDGED_CONTENT_VIEW_H_
  5. #define COMPONENTS_REMOTE_COCOA_APP_SHIM_BRIDGED_CONTENT_VIEW_H_
  6. #import <Cocoa/Cocoa.h>
  7. #include <string>
  8. #include "components/remote_cocoa/app_shim/remote_cocoa_app_shim_export.h"
  9. #import "ui/base/cocoa/tool_tip_base_view.h"
  10. #import "ui/base/cocoa/tracking_area.h"
  11. namespace remote_cocoa {
  12. class NativeWidgetNSWindowBridge;
  13. } // namespace remote_cocoa
  14. namespace ui {
  15. class TextInputClient;
  16. } // namespace ui
  17. // The NSView that sits as the root contentView of the NSWindow, whilst it has
  18. // a views::RootView present. Bridges requests from Cocoa to the hosted
  19. // views::View.
  20. REMOTE_COCOA_APP_SHIM_EXPORT
  21. @interface BridgedContentView : ToolTipBaseView <NSTextInputClient,
  22. NSUserInterfaceValidations,
  23. NSDraggingSource,
  24. NSServicesMenuRequestor> {
  25. @private
  26. // Weak, reset by clearView.
  27. remote_cocoa::NativeWidgetNSWindowBridge* _bridge;
  28. // A tracking area installed to enable mouseMoved events.
  29. ui::ScopedCrTrackingArea _cursorTrackingArea;
  30. // The keyDown event currently being handled, nil otherwise.
  31. NSEvent* _keyDownEvent;
  32. // Whether there's an active key down event which is not handled yet.
  33. BOOL _hasUnhandledKeyDownEvent;
  34. // Whether any -insertFoo: selector (e.g. -insertNewLine:) was passed to
  35. // -doCommandBySelector: during the processing of this keyDown. These must
  36. // always be dispatched as a ui::KeyEvent in -keyDown:.
  37. BOOL _wantsKeyHandledForInsert;
  38. // The last tooltip text, used to limit updates.
  39. std::u16string _lastTooltipText;
  40. }
  41. @property(readonly, nonatomic) remote_cocoa::NativeWidgetNSWindowBridge* bridge;
  42. @property(assign, nonatomic) BOOL drawMenuBackgroundForBlur;
  43. @property(assign, nonatomic) NSEvent* keyDownEventForTesting;
  44. // Initialize the NSView -> views::View bridge. |viewToHost| must be non-NULL.
  45. - (instancetype)initWithBridge:(remote_cocoa::NativeWidgetNSWindowBridge*)bridge
  46. bounds:(gfx::Rect)rect;
  47. // Clear the hosted view. For example, if it is about to be destroyed.
  48. - (void)clearView;
  49. // Process a mouse event captured while the widget had global mouse capture.
  50. - (void)processCapturedMouseEvent:(NSEvent*)theEvent;
  51. // Mac's version of views::corewm::TooltipController::UpdateIfRequired().
  52. // Updates the tooltip on the ToolTipBaseView if the text needs to change.
  53. // |locationInContent| is the position from the top left of the window's
  54. // contentRect (also this NSView's frame), as given by a ui::LocatedEvent.
  55. - (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent;
  56. // Notifies the associated FocusManager whether full keyboard access is enabled
  57. // or not.
  58. - (void)updateFullKeyboardAccess;
  59. // Update the cursor tracking area in response to the parent window's level
  60. // changing.
  61. // https://crbug.com/1214013
  62. - (void)updateCursorTrackingArea;
  63. // The TextInputClient of the currently focused views::View.
  64. // TODO(ccameron): This cannot be relied on across processes.
  65. - (ui::TextInputClient*)textInputClient;
  66. // Returns true if it is needed to call -[NSApp updateWindows] while updating
  67. // the text input client.
  68. - (bool)needsUpdateWindows;
  69. // Action for Cmd-E
  70. - (void)copyToFindPboard:(id)sender;
  71. @end
  72. #endif // COMPONENTS_REMOTE_COCOA_APP_SHIM_BRIDGED_CONTENT_VIEW_H_