render_widget_host_view_mac_delegate.h revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#import <Cocoa/Cocoa.h> 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 10116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace blink { 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class WebMouseWheelEvent; 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// This protocol is used as a delegate for the NSView class used in the 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// hierarchy. There are two ways to extend the view: 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// - Implement the methods listed in the protocol below. 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// - Implement any method, and if the view is requested to perform that method 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// and cannot, the delegate's implementation will be used. 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Like any Objective-C delegate, it is not retained by the delegator object. 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// The delegator object will call the -viewGone: method when it is going away. 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)@class NSEvent; 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)@protocol RenderWidgetHostViewMacDelegate 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)@optional 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Notification that the view is gone. 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)- (void)viewGone:(NSView*)view; 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Handle an event. All incoming key and mouse events flow through this delegate 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// method if implemented. Return YES if the event is fully handled, or NO if 31// normal processing should take place. 32- (BOOL)handleEvent:(NSEvent*)event; 33 34// Notification of scroll offset pinning. 35- (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right; 36 37// Notification of whether the view has a horizontal scrollbar. 38- (void)setHasHorizontalScrollbar:(BOOL)has_horizontal_scrollbar; 39 40// Provides validation of user interface items. If the return value is NO, then 41// the delegate is unaware of that item and |valid| is undefined. Otherwise, 42// |valid| contains the validity of the specified item. 43- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item 44 isValidItem:(BOOL*)valid; 45 46@required 47// Notification of when a gesture begins/ends. 48- (void)beginGestureWithEvent:(NSEvent*)event; 49- (void)endGestureWithEvent:(NSEvent*)event; 50 51// This is a low level API which provides touches associated with an event. 52// It is used in conjunction with gestures to determine finger placement 53// on the trackpad. 54- (void)touchesMovedWithEvent:(NSEvent*)event; 55- (void)touchesBeganWithEvent:(NSEvent*)event; 56- (void)touchesCancelledWithEvent:(NSEvent*)event; 57- (void)touchesEndedWithEvent:(NSEvent*)event; 58 59// These methods control whether a given view is allowed to rubberband in the 60// given direction. This is inversely related to whether the view is allowed to 61// 2-finger history swipe in the given direction. 62- (BOOL)canRubberbandLeft:(NSView*)view; 63- (BOOL)canRubberbandRight:(NSView*)view; 64 65// The browser process received an ACK from the renderer after it processed 66// |event|. 67- (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event 68 consumed:(BOOL)consumed; 69@end 70 71#endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 72