1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 6 #define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 7 8 #import <Cocoa/Cocoa.h> 9 10 namespace blink { 11 class WebGestureEvent; 12 class WebMouseWheelEvent; 13 } 14 15 namespace ui { 16 struct DidOverscrollParams; 17 } 18 19 // This protocol is used as a delegate for the NSView class used in the 20 // hierarchy. There are two ways to extend the view: 21 // - Implement the methods listed in the protocol below. 22 // - Implement any method, and if the view is requested to perform that method 23 // and cannot, the delegate's implementation will be used. 24 // 25 // Like any Objective-C delegate, it is not retained by the delegator object. 26 // The delegator object will call the -viewGone: method when it is going away. 27 28 @class NSEvent; 29 @protocol RenderWidgetHostViewMacDelegate 30 // Notification of when a gesture begins/ends. 31 - (void)beginGestureWithEvent:(NSEvent*)event; 32 - (void)endGestureWithEvent:(NSEvent*)event; 33 34 // This is a low level API which provides touches associated with an event. 35 // It is used in conjunction with gestures to determine finger placement 36 // on the trackpad. 37 - (void)touchesMovedWithEvent:(NSEvent*)event; 38 - (void)touchesBeganWithEvent:(NSEvent*)event; 39 - (void)touchesCancelledWithEvent:(NSEvent*)event; 40 - (void)touchesEndedWithEvent:(NSEvent*)event; 41 42 // The browser process received an ACK from the renderer after it processed 43 // |event|. 44 - (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event 45 consumed:(BOOL)consumed; 46 - (void)rendererHandledGestureScrollEvent:(const blink::WebGestureEvent&)event 47 consumed:(BOOL)consumed; 48 - (void)rendererHandledOverscrollEvent:(const ui::DidOverscrollParams&)params; 49 50 @optional 51 // Notification that the view is gone. 52 - (void)viewGone:(NSView*)view; 53 54 // Handle an event. All incoming key and mouse events flow through this delegate 55 // method if implemented. Return YES if the event is fully handled, or NO if 56 // normal processing should take place. 57 - (BOOL)handleEvent:(NSEvent*)event; 58 59 // Provides validation of user interface items. If the return value is NO, then 60 // the delegate is unaware of that item and |valid| is undefined. Otherwise, 61 // |valid| contains the validity of the specified item. 62 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item 63 isValidItem:(BOOL*)valid; 64 65 - (void)becomeFirstResponder; 66 - (void)resignFirstResponder; 67 68 - (void)windowDidBecomeKey; 69 @end 70 71 #endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 72