| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ |
| 7 | 7 |
| 8 // A class acting as the Objective-C controller for the Panel window | 8 // A class acting as the Objective-C controller for the Panel window |
| 9 // object. Handles interactions between Cocoa and the cross-platform | 9 // object. Handles interactions between Cocoa and the cross-platform |
| 10 // code. Each window has a single titlebar and is managed/owned by Panel. | 10 // code. Each window has a single titlebar and is managed/owned by Panel. |
| 11 | 11 |
| 12 #import <Cocoa/Cocoa.h> | 12 #import <Cocoa/Cocoa.h> |
| 13 | 13 |
| 14 #include "base/memory/scoped_nsobject.h" | 14 #include "base/memory/scoped_nsobject.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #import "chrome/browser/ui/cocoa/browser_command_executor.h" | |
| 18 #import "chrome/browser/ui/cocoa/chrome_browser_window.h" | 17 #import "chrome/browser/ui/cocoa/chrome_browser_window.h" |
| 19 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 18 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 20 #import "chrome/browser/ui/cocoa/themed_window.h" | 19 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 21 #import "chrome/browser/ui/cocoa/tracking_area.h" | 20 #import "chrome/browser/ui/cocoa/tracking_area.h" |
| 22 #include "chrome/browser/ui/panels/panel.h" | 21 #include "chrome/browser/ui/panels/panel.h" |
| 23 | 22 |
| 24 @class FindBarCocoaController; | 23 class PanelCocoa; |
| 25 class NativePanelCocoa; | |
| 26 @class PanelTitlebarViewCocoa; | 24 @class PanelTitlebarViewCocoa; |
| 27 | 25 |
| 28 @interface PanelWindowCocoaImpl : ChromeBrowserWindow { | 26 @interface PanelWindowCocoaImpl : ChromeBrowserWindow { |
| 29 } | 27 } |
| 30 @end | 28 @end |
| 31 | 29 |
| 32 @interface PanelWindowControllerCocoa : NSWindowController | 30 @interface PanelWindowControllerCocoa : NSWindowController |
| 33 <NSWindowDelegate, | 31 <NSWindowDelegate, |
| 34 NSAnimationDelegate, | 32 NSAnimationDelegate> { |
| 35 BrowserCommandExecutor> { | |
| 36 @private | 33 @private |
| 37 IBOutlet PanelTitlebarViewCocoa* titlebar_view_; | 34 IBOutlet PanelTitlebarViewCocoa* titlebar_view_; |
| 38 scoped_ptr<NativePanelCocoa> windowShim_; | 35 scoped_ptr<PanelCocoa> windowShim_; |
| 39 scoped_nsobject<NSString> pendingWindowTitle_; | 36 scoped_nsobject<NSString> pendingWindowTitle_; |
| 40 scoped_nsobject<TabContentsController> contentsController_; | 37 scoped_nsobject<TabContentsController> contentsController_; |
| 41 NSViewAnimation* boundsAnimation_; // Lifetime controlled manually, needs | 38 NSViewAnimation* boundsAnimation_; // Lifetime controlled manually, needs |
| 42 // more then just |release| to terminate. | 39 // more then just |release| to terminate. |
| 43 BOOL animateOnBoundsChange_; | 40 BOOL animateOnBoundsChange_; |
| 44 BOOL throbberShouldSpin_; | 41 BOOL throbberShouldSpin_; |
| 45 BOOL playingMinimizeAnimation_; | 42 BOOL playingMinimizeAnimation_; |
| 46 float animationStopToShowTitlebarOnly_; | 43 float animationStopToShowTitlebarOnly_; |
| 47 BOOL canBecomeKeyWindow_; | 44 BOOL canBecomeKeyWindow_; |
| 48 // Allow a panel to become key if activated via Panel logic, as opposed | 45 // Allow a panel to become key if activated via Panel logic, as opposed |
| 49 // to by default system selection. The system will prefer a panel | 46 // to by default system selection. The system will prefer a panel |
| 50 // window over other application windows due to panels having a higher | 47 // window over other application windows due to panels having a higher |
| 51 // priority NSWindowLevel, so we distinguish between the two scenarios. | 48 // priority NSWindowLevel, so we distinguish between the two scenarios. |
| 52 BOOL activationRequestedByPanel_; | 49 BOOL activationRequestedByPanel_; |
| 53 scoped_nsobject<NSView> overlayView_; | 50 scoped_nsobject<NSView> overlayView_; |
| 54 } | 51 } |
| 55 | 52 |
| 56 // Load the window nib and do any Cocoa-specific initialization. | 53 // Load the window nib and do any Cocoa-specific initialization. |
| 57 - (id)initWithPanel:(NativePanelCocoa*)window; | 54 - (id)initWithPanel:(PanelCocoa*)window; |
| 58 | 55 |
| 59 - (ui::ThemeProvider*)themeProvider; | 56 - (ui::ThemeProvider*)themeProvider; |
| 60 - (ThemedWindowStyle)themedWindowStyle; | 57 - (ThemedWindowStyle)themedWindowStyle; |
| 61 - (NSPoint)themePatternPhase; | 58 - (NSPoint)themePatternPhase; |
| 62 | 59 |
| 63 - (void)webContentsInserted:(content::WebContents*)contents; | 60 - (void)webContentsInserted:(content::WebContents*)contents; |
| 64 - (void)webContentsDetached:(content::WebContents*)contents; | 61 - (void)webContentsDetached:(content::WebContents*)contents; |
| 65 | 62 |
| 66 // Sometimes (when we animate the size of the window) we want to stop resizing | 63 // Sometimes (when we animate the size of the window) we want to stop resizing |
| 67 // the WebContents's Cocoa view to avoid unnecessary rendering and issues | 64 // the WebContents's Cocoa view to avoid unnecessary rendering and issues |
| 68 // that can be caused by sizes near 0. | 65 // that can be caused by sizes near 0. |
| 69 - (void)disableTabContentsViewAutosizing; | 66 - (void)disableTabContentsViewAutosizing; |
| 70 - (void)enableTabContentsViewAutosizing; | 67 - (void)enableTabContentsViewAutosizing; |
| 71 | 68 |
| 72 // Shows the window for the first time. Only happens once. | 69 // Shows the window for the first time. Only happens once. |
| 73 - (void)revealAnimatedWithFrame:(const NSRect&)frame; | 70 - (void)revealAnimatedWithFrame:(const NSRect&)frame; |
| 74 | 71 |
| 75 - (void)updateTitleBar; | 72 - (void)updateTitleBar; |
| 76 - (void)updateIcon; | 73 - (void)updateIcon; |
| 77 - (void)updateThrobber:(BOOL)shouldSpin; | 74 - (void)updateThrobber:(BOOL)shouldSpin; |
| 78 - (void)updateTitleBarMinimizeRestoreButtonVisibility; | 75 - (void)updateTitleBarMinimizeRestoreButtonVisibility; |
| 79 | 76 |
| 80 // Adds the FindBar controller's view to this Panel. Must only be | |
| 81 // called once per PanelWindowControllerCocoa. | |
| 82 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController; | |
| 83 | |
| 84 // Initiate the closing of the panel, starting from the platform-independent | 77 // Initiate the closing of the panel, starting from the platform-independent |
| 85 // layer. This will take care of PanelManager, other panels and close the | 78 // layer. This will take care of PanelManager, other panels and close the |
| 86 // native window at the end. | 79 // native window at the end. |
| 87 - (void)closePanel; | 80 - (void)closePanel; |
| 88 | 81 |
| 89 // Minimize/Restore the panel or all panels, depending on the modifier. | 82 // Minimize/Restore the panel or all panels, depending on the modifier. |
| 90 // Invoked when the minimize/restore button is clicked. | 83 // Invoked when the minimize/restore button is clicked. |
| 91 - (void)minimizeButtonClicked:(int)modifierFlags; | 84 - (void)minimizeButtonClicked:(int)modifierFlags; |
| 92 - (void)restoreButtonClicked:(int)modifierFlags; | 85 - (void)restoreButtonClicked:(int)modifierFlags; |
| 93 | 86 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 108 // Accessor for titlebar view. | 101 // Accessor for titlebar view. |
| 109 - (PanelTitlebarViewCocoa*)titlebarView; | 102 - (PanelTitlebarViewCocoa*)titlebarView; |
| 110 // Returns the height of titlebar, used to show the titlebar in | 103 // Returns the height of titlebar, used to show the titlebar in |
| 111 // "Draw Attention" state. | 104 // "Draw Attention" state. |
| 112 - (int)titlebarHeightInScreenCoordinates; | 105 - (int)titlebarHeightInScreenCoordinates; |
| 113 | 106 |
| 114 // Invoked when user clicks on the titlebar. Attempts to flip the | 107 // Invoked when user clicks on the titlebar. Attempts to flip the |
| 115 // Minimized/Restored states. | 108 // Minimized/Restored states. |
| 116 - (void)onTitlebarMouseClicked:(int)modifierFlags; | 109 - (void)onTitlebarMouseClicked:(int)modifierFlags; |
| 117 | 110 |
| 118 // Executes the command in the context of the current browser. | |
| 119 // |command| is an integer value containing one of the constants defined in the | |
| 120 // "chrome/app/chrome_command_ids.h" file. | |
| 121 - (void)executeCommand:(int)command; | |
| 122 | |
| 123 // NSAnimationDelegate method, invoked when bounds animation is finished. | 111 // NSAnimationDelegate method, invoked when bounds animation is finished. |
| 124 - (void)animationDidEnd:(NSAnimation*)animation; | 112 - (void)animationDidEnd:(NSAnimation*)animation; |
| 125 // Terminates current bounds animation, if any. | 113 // Terminates current bounds animation, if any. |
| 126 - (void)terminateBoundsAnimation; | 114 - (void)terminateBoundsAnimation; |
| 127 | 115 |
| 128 - (BOOL)isAnimatingBounds; | 116 - (BOOL)isAnimatingBounds; |
| 129 | 117 |
| 130 // Sets/Removes the Key status from the panel to some other window. | 118 // Sets/Removes the Key status from the panel to some other window. |
| 131 - (void)activate; | 119 - (void)activate; |
| 132 - (void)deactivate; | 120 - (void)deactivate; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 154 | 142 |
| 155 // Turns on user-resizable corners/sides indications and enables live resize. | 143 // Turns on user-resizable corners/sides indications and enables live resize. |
| 156 - (void)enableResizeByMouse:(BOOL)enable; | 144 - (void)enableResizeByMouse:(BOOL)enable; |
| 157 | 145 |
| 158 - (NSRect)frameRectForContentRect:(NSRect)contentRect; | 146 - (NSRect)frameRectForContentRect:(NSRect)contentRect; |
| 159 - (NSRect)contentRectForFrameRect:(NSRect)frameRect; | 147 - (NSRect)contentRectForFrameRect:(NSRect)frameRect; |
| 160 | 148 |
| 161 @end // @interface PanelWindowController | 149 @end // @interface PanelWindowController |
| 162 | 150 |
| 163 #endif // CHROME_BROWSER_UI_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ | 151 #endif // CHROME_BROWSER_UI_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ |
| OLD | NEW |