1 // Copyright (c) 2011 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.
5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_
8 #import <Cocoa/Cocoa.h>
10 #include "chrome/browser/ui/cocoa/themed_window.h"
15 struct NativeWebKeyboardEvent
;
18 @interface BrowserWindowUtils
: NSObject
20 // Returns YES if keyboard event should be handled.
21 + (BOOL
)shouldHandleKeyboardEvent
:(const content::NativeWebKeyboardEvent
&)event
;
23 // Determines the command associated with the keyboard event.
24 // Returns -1 if no command found.
25 + (int)getCommandId
:(const content::NativeWebKeyboardEvent
&)event
;
27 // NSWindow must be a ChromeEventProcessingWindow.
28 + (BOOL
)handleKeyboardEvent
:(NSEvent
*)event
29 inWindow
:(NSWindow
*)window
;
31 // Schedule a window title change in the next run loop iteration. This works
32 // around a Cocoa bug: if a window changes title during the tracking of the
33 // Window menu it doesn't display well and the constant re-sorting of the list
34 // makes it difficult for the user to pick the desired window.
35 // Passing in a non-nil oldTitle will also cancel any pending title changes with
36 // a matching window and title. This function returns a NSString* that can be
37 // passed in future calls as oldTitle.
38 + (NSString
*)scheduleReplaceOldTitle
:(NSString
*)oldTitle
39 withNewTitle
:(NSString
*)newTitle
40 forWindow
:(NSWindow
*)window
;
42 // Returns the position in the coordinates of |windowView| that the top left of
43 // a theme image should be painted at. See
44 // [BrowserWindowController themeImagePositionForAlignment:] for more details.
45 + (NSPoint
)themeImagePositionFor
:(NSView
*)windowView
46 withTabStrip
:(NSView
*)tabStripView
47 alignment
:(ThemeImageAlignment
)alignment
;
49 // Returns the position in the coordinates of |tabStripView| that the top left
50 // of a theme image should be painted at. This method exists so that the
51 // position can be queried by the new tab button before the tab strip is layed
53 + (NSPoint
)themeImagePositionInTabStripCoords
:(NSView
*)tabStripView
54 alignment
:(ThemeImageAlignment
)alignment
;
56 + (void)activateWindowForController
:(NSWindowController
*)controller
;
59 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_