15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 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 CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#import <Cocoa/Cocoa.h>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
103551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chrome/browser/ui/cocoa/themed_window.h"
113551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Browser;
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct NativeWebKeyboardEvent;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@interface BrowserWindowUtils : NSObject
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns YES if keyboard event should be handled.
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (BOOL)shouldHandleKeyboardEvent:(const content::NativeWebKeyboardEvent&)event;
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Determines the command associated with the keyboard event.
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns -1 if no command found.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (int)getCommandId:(const content::NativeWebKeyboardEvent&)event;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// NSWindow must be a ChromeEventProcessingWindow.
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (BOOL)handleKeyboardEvent:(NSEvent*)event
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                   inWindow:(NSWindow*)window;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Schedule a window title change in the next run loop iteration. This works
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// around a Cocoa bug: if a window changes title during the tracking of the
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Window menu it doesn't display well and the constant re-sorting of the list
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// makes it difficult for the user to pick the desired window.
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Passing in a non-nil oldTitle will also cancel any pending title changes with
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a matching window and title. This function returns a NSString* that can be
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// passed in future calls as oldTitle.
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (NSString*)scheduleReplaceOldTitle:(NSString*)oldTitle
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        withNewTitle:(NSString*)newTitle
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                           forWindow:(NSWindow*)window;
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
423551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// Returns the position in the coordinates of |windowView| that the top left of
433551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// a theme image should be painted at. See
443551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// [BrowserWindowController themeImagePositionForAlignment:] for more details.
453551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)+ (NSPoint)themeImagePositionFor:(NSView*)windowView
463551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                    withTabStrip:(NSView*)tabStripView
473551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                       alignment:(ThemeImageAlignment)alignment;
483551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
493551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// Returns the position in the coordinates of |tabStripView| that the top left
503551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// of a theme image should be painted at. This method exists so that the
513551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// position can be queried by the new tab button before the tab strip is layed
523551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// out.
533551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)+ (NSPoint)themeImagePositionInTabStripCoords:(NSView*)tabStripView
543551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)                                    alignment:(ThemeImageAlignment)alignment;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (void)activateWindowForController:(NSWindowController*)controller;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_UTILS_H_
60