OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COCOA_BROWSER_WINDOW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ |
6 #define CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ |
7 | 7 |
8 // A class acting as the Objective-C controller for the Browser | 8 // A class acting as the Objective-C controller for the Browser |
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 toolbar and, by virtue of being a | 10 // code. Each window has a single toolbar and, by virtue of being a |
11 // TabWindowController, a tab strip along the top. | 11 // TabWindowController, a tab strip along the top. |
12 | 12 |
13 #import <Cocoa/Cocoa.h> | 13 #import <Cocoa/Cocoa.h> |
14 | 14 |
15 #include "base/scoped_nsobject.h" | 15 #include "base/scoped_nsobject.h" |
16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
17 #import "chrome/browser/cocoa/tab_window_controller.h" | 17 #import "chrome/browser/cocoa/tab_window_controller.h" |
18 #import "chrome/browser/cocoa/bookmark_bar_controller.h" | 18 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
| 19 #import "chrome/browser/cocoa/bookmark_bubble_controller.h" |
19 #import "chrome/browser/cocoa/view_resizer.h" | 20 #import "chrome/browser/cocoa/view_resizer.h" |
20 #import "third_party/GTM/AppKit/GTMTheme.h" | 21 #import "third_party/GTM/AppKit/GTMTheme.h" |
21 | 22 |
22 class Browser; | 23 class Browser; |
23 class BrowserWindow; | 24 class BrowserWindow; |
24 class BrowserWindowCocoa; | 25 class BrowserWindowCocoa; |
25 class ConstrainedWindowMac; | 26 class ConstrainedWindowMac; |
26 @class DownloadShelfController; | 27 @class DownloadShelfController; |
27 @class FindBarCocoaController; | 28 @class FindBarCocoaController; |
28 @class GTMWindowSheetController; | 29 @class GTMWindowSheetController; |
29 @class InfoBarContainerController; | 30 @class InfoBarContainerController; |
30 class LocationBar; | 31 class LocationBar; |
31 class StatusBubble; | 32 class StatusBubble; |
32 class TabContents; | 33 class TabContents; |
33 @class TabContentsController; | 34 @class TabContentsController; |
34 @class TabStripController; | 35 @class TabStripController; |
35 class TabStripModelObserverBridge; | 36 class TabStripModelObserverBridge; |
36 @class TabStripView; | 37 @class TabStripView; |
37 @class ToolbarController; | 38 @class ToolbarController; |
38 @class TitlebarController; | 39 @class TitlebarController; |
39 | 40 |
40 @interface BrowserWindowController : | 41 @interface BrowserWindowController : |
41 TabWindowController<NSUserInterfaceValidations, | 42 TabWindowController<NSUserInterfaceValidations, |
42 BookmarkURLOpener, | 43 BookmarkURLOpener, |
| 44 BookmarkBubbleControllerDelegate, |
43 ViewResizer, | 45 ViewResizer, |
44 GTMThemeDelegate> { | 46 GTMThemeDelegate> { |
45 @private | 47 @private |
46 // The ordering of these members is important as it determines the order in | 48 // The ordering of these members is important as it determines the order in |
47 // which they are destroyed. |browser_| needs to be destroyed last as most of | 49 // which they are destroyed. |browser_| needs to be destroyed last as most of |
48 // the other objects hold weak references to it or things it owns | 50 // the other objects hold weak references to it or things it owns |
49 // (tab/toolbar/bookmark models, profiles, etc). We hold a strong ref to the | 51 // (tab/toolbar/bookmark models, profiles, etc). We hold a strong ref to the |
50 // window so that it will live after the NSWindowController dealloc has run | 52 // window so that it will live after the NSWindowController dealloc has run |
51 // (which happens *before* these scoped pointers are torn down). Keeping it | 53 // (which happens *before* these scoped pointers are torn down). Keeping it |
52 // alive ensures that weak view or window pointers remain valid through | 54 // alive ensures that weak view or window pointers remain valid through |
53 // their destruction sequence. | 55 // their destruction sequence. |
54 scoped_ptr<Browser> browser_; | 56 scoped_ptr<Browser> browser_; |
55 scoped_nsobject<NSWindow> window_; | 57 scoped_nsobject<NSWindow> window_; |
56 scoped_nsobject<NSWindow> fullscreen_window_; | 58 scoped_nsobject<NSWindow> fullscreen_window_; |
57 scoped_ptr<TabStripModelObserverBridge> tabObserver_; | 59 scoped_ptr<TabStripModelObserverBridge> tabObserver_; |
58 scoped_ptr<BrowserWindowCocoa> windowShim_; | 60 scoped_ptr<BrowserWindowCocoa> windowShim_; |
59 scoped_nsobject<ToolbarController> toolbarController_; | 61 scoped_nsobject<ToolbarController> toolbarController_; |
60 scoped_nsobject<TitlebarController> titlebarController_; | 62 scoped_nsobject<TitlebarController> titlebarController_; |
61 scoped_nsobject<TabStripController> tabStripController_; | 63 scoped_nsobject<TabStripController> tabStripController_; |
62 scoped_nsobject<FindBarCocoaController> findBarCocoaController_; | 64 scoped_nsobject<FindBarCocoaController> findBarCocoaController_; |
63 scoped_nsobject<InfoBarContainerController> infoBarContainerController_; | 65 scoped_nsobject<InfoBarContainerController> infoBarContainerController_; |
64 scoped_ptr<StatusBubble> statusBubble_; | 66 scoped_ptr<StatusBubble> statusBubble_; |
65 scoped_nsobject<DownloadShelfController> downloadShelfController_; | 67 scoped_nsobject<DownloadShelfController> downloadShelfController_; |
| 68 scoped_nsobject<BookmarkBubbleController> bookmarkBubbleController_; |
66 scoped_nsobject<GTMTheme> theme_; | 69 scoped_nsobject<GTMTheme> theme_; |
67 BOOL ownsBrowser_; // Only ever NO when testing | 70 BOOL ownsBrowser_; // Only ever NO when testing |
68 BOOL fullscreen_; | 71 BOOL fullscreen_; |
69 } | 72 } |
70 | 73 |
71 // Load the browser window nib and do any Cocoa-specific initialization. | 74 // Load the browser window nib and do any Cocoa-specific initialization. |
72 // Takes ownership of |browser|. | 75 // Takes ownership of |browser|. |
73 - (id)initWithBrowser:(Browser*)browser; | 76 - (id)initWithBrowser:(Browser*)browser; |
74 | 77 |
75 // Call to make the browser go away from other places in the cross-platform | 78 // Call to make the browser go away from other places in the cross-platform |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 - (void)userChangedTheme; | 135 - (void)userChangedTheme; |
133 | 136 |
134 // Executes the command in the context of the current browser. | 137 // Executes the command in the context of the current browser. |
135 // |command| is an integer value containing one of the constants defined in the | 138 // |command| is an integer value containing one of the constants defined in the |
136 // "chrome/app/chrome_dll_resource.h" file. | 139 // "chrome/app/chrome_dll_resource.h" file. |
137 - (void)executeCommand:(int)command; | 140 - (void)executeCommand:(int)command; |
138 | 141 |
139 // Delegate method for the status bubble to query about its vertical offset. | 142 // Delegate method for the status bubble to query about its vertical offset. |
140 - (float)verticalOffsetForStatusBubble; | 143 - (float)verticalOffsetForStatusBubble; |
141 | 144 |
| 145 // Show the bookmark bubble (e.g. user just clicked on the STAR) |
| 146 - (void)showBookmarkBubbleForURL:(const GURL&)url |
| 147 alreadyBookmarked:(BOOL)alreadyBookmarked; |
| 148 |
142 // Returns the (lazily created) window sheet controller of this window. Used | 149 // Returns the (lazily created) window sheet controller of this window. Used |
143 // for the per-tab sheets. | 150 // for the per-tab sheets. |
144 - (GTMWindowSheetController*)sheetController; | 151 - (GTMWindowSheetController*)sheetController; |
145 | 152 |
146 // Checks if there are any tabs with sheets open, and if so, raises one of | 153 // Checks if there are any tabs with sheets open, and if so, raises one of |
147 // the tabs with a sheet and returns NO. | 154 // the tabs with a sheet and returns NO. |
148 - (BOOL)shouldCloseWithOpenPerTabSheets; | 155 - (BOOL)shouldCloseWithOpenPerTabSheets; |
149 | 156 |
150 - (void)attachConstrainedWindow:(ConstrainedWindowMac*)window; | 157 - (void)attachConstrainedWindow:(ConstrainedWindowMac*)window; |
151 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window; | 158 - (void)removeConstrainedWindow:(ConstrainedWindowMac*)window; |
152 | 159 |
153 @end | 160 @end |
154 | 161 |
155 | 162 |
156 @interface BrowserWindowController(TestingAPI) | 163 @interface BrowserWindowController(TestingAPI) |
157 | 164 |
158 // Put the incognito badge on the browser and adjust the tab strip | 165 // Put the incognito badge on the browser and adjust the tab strip |
159 // accordingly. | 166 // accordingly. |
160 - (void)installIncognitoBadge; | 167 - (void)installIncognitoBadge; |
161 | 168 |
162 // Allows us to initWithBrowser withOUT taking ownership of the browser. | 169 // Allows us to initWithBrowser withOUT taking ownership of the browser. |
163 - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt; | 170 - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt; |
164 | 171 |
165 // Return an autoreleased NSWindow suitable for fullscreen use. | 172 // Return an autoreleased NSWindow suitable for fullscreen use. |
166 - (NSWindow*)fullscreenWindow; | 173 - (NSWindow*)fullscreenWindow; |
167 | 174 |
| 175 // Return a point suitable for the topLeft for a bookmark bubble. |
| 176 - (NSPoint)topLeftForBubble; |
| 177 |
168 @end // BrowserWindowController(TestingAPI) | 178 @end // BrowserWindowController(TestingAPI) |
169 | 179 |
170 #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ | 180 #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ |
OLD | NEW |