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