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. 4 5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_ 6 #define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_ 7 8 #import <Cocoa/Cocoa.h> 9 10 #include "chrome/browser/ui/cocoa/themed_window.h" 11 12 class Browser; 13 14 namespace content { 15 struct NativeWebKeyboardEvent; 16 } 17 18 @interface BrowserWindowUtils : NSObject 19 20 // Returns YES if keyboard event should be handled. 21 + (BOOL)shouldHandleKeyboardEvent:(const content::NativeWebKeyboardEvent&)event; 22 23 // Determines the command associated with the keyboard event. 24 // Returns -1 if no command found. 25 + (int)getCommandId:(const content::NativeWebKeyboardEvent&)event; 26 27 // NSWindow must be a ChromeEventProcessingWindow. 28 + (BOOL)handleKeyboardEvent:(NSEvent*)event 29 inWindow:(NSWindow*)window; 30 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; 41 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; 48 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 52 // out. 53 + (NSPoint)themeImagePositionInTabStripCoords:(NSView*)tabStripView 54 alignment:(ThemeImageAlignment)alignment; 55 56 + (void)activateWindowForController:(NSWindowController*)controller; 57 @end 58 59 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_ 60