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
10namespace blink {
11class WebMouseWheelEvent;
12}
13
14// This protocol is used as a delegate for the NSView class used in the
15// hierarchy. There are two ways to extend the view:
16// - Implement the methods listed in the protocol below.
17// - Implement any method, and if the view is requested to perform that method
18//   and cannot, the delegate's implementation will be used.
19//
20// Like any Objective-C delegate, it is not retained by the delegator object.
21// The delegator object will call the -viewGone: method when it is going away.
22
23@class NSEvent;
24@protocol RenderWidgetHostViewMacDelegate
25@optional
26// Notification that the view is gone.
27- (void)viewGone:(NSView*)view;
28
29// Handle an event. All incoming key and mouse events flow through this delegate
30// 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// Provides validation of user interface items. If the return value is NO, then
35// the delegate is unaware of that item and |valid| is undefined.  Otherwise,
36// |valid| contains the validity of the specified item.
37- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
38                      isValidItem:(BOOL*)valid;
39
40@required
41// Notification of when a gesture begins/ends.
42- (void)beginGestureWithEvent:(NSEvent*)event;
43- (void)endGestureWithEvent:(NSEvent*)event;
44
45// This is a low level API which provides touches associated with an event.
46// It is used in conjunction with gestures to determine finger placement
47// on the trackpad.
48- (void)touchesMovedWithEvent:(NSEvent*)event;
49- (void)touchesBeganWithEvent:(NSEvent*)event;
50- (void)touchesCancelledWithEvent:(NSEvent*)event;
51- (void)touchesEndedWithEvent:(NSEvent*)event;
52
53// These methods control whether a given view is allowed to rubberband in the
54// given direction. This is inversely related to whether the view is allowed to
55// 2-finger history swipe in the given direction.
56- (BOOL)canRubberbandLeft:(NSView*)view;
57- (BOOL)canRubberbandRight:(NSView*)view;
58
59// The browser process received an ACK from the renderer after it processed
60// |event|.
61- (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event
62                         consumed:(BOOL)consumed;
63@end
64
65#endif  // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_MAC_DELEGATE_H_
66