15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#import <Cocoa/Cocoa.h> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)namespace blink { 1146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)class WebMouseWheelEvent; 1246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)} 1346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This protocol is used as a delegate for the NSView class used in the 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// hierarchy. There are two ways to extend the view: 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// - Implement the methods listed in the protocol below. 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// - Implement any method, and if the view is requested to perform that method 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and cannot, the delegate's implementation will be used. 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Like any Objective-C delegate, it is not retained by the delegator object. 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The delegator object will call the -viewGone: method when it is going away. 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 23a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)@class NSEvent; 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@protocol RenderWidgetHostViewMacDelegate 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@optional 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Notification that the view is gone. 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)viewGone:(NSView*)view; 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Handle an event. All incoming key and mouse events flow through this delegate 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// method if implemented. Return YES if the event is fully handled, or NO if 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// normal processing should take place. 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (BOOL)handleEvent:(NSEvent*)event; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Provides validation of user interface items. If the return value is NO, then 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the delegate is unaware of that item and |valid| is undefined. Otherwise, 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |valid| contains the validity of the specified item. 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) isValidItem:(BOOL*)valid; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 40a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)@required 41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Notification of when a gesture begins/ends. 42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (void)beginGestureWithEvent:(NSEvent*)event; 43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (void)endGestureWithEvent:(NSEvent*)event; 44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// This is a low level API which provides touches associated with an event. 46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// It is used in conjunction with gestures to determine finger placement 47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// on the trackpad. 48a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (void)touchesMovedWithEvent:(NSEvent*)event; 49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (void)touchesBeganWithEvent:(NSEvent*)event; 50a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (void)touchesCancelledWithEvent:(NSEvent*)event; 51a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (void)touchesEndedWithEvent:(NSEvent*)event; 52a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 53e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// These methods control whether a given view is allowed to rubberband in the 54e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// given direction. This is inversely related to whether the view is allowed to 55e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch// 2-finger history swipe in the given direction. 56e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch- (BOOL)canRubberbandLeft:(NSView*)view; 57e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch- (BOOL)canRubberbandRight:(NSView*)view; 5846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 5946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// The browser process received an ACK from the renderer after it processed 6046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// |event|. 6146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)- (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event 6246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) consumed:(BOOL)consumed; 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_ 66