The find bar should be owned and managed from the BrowserView, not the WebContentsVie...
[chromium-blink-merge.git] / chrome / browser / cocoa / browser_window_cocoa.mm
blob6af331b685df551447df7c995e937aa513cd0846
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
3 // found in the LICENSE file.
5 #include "base/gfx/rect.h"
6 #include "base/logging.h"
7 #include "chrome/browser/cocoa/browser_window_cocoa.h"
8 #include "chrome/browser/cocoa/browser_window_controller.h"
10 BrowserWindowCocoa::BrowserWindowCocoa(BrowserWindowController* controller, 
11                                        NSWindow* window)
12     : controller_(controller), window_(window) {
15 BrowserWindowCocoa::~BrowserWindowCocoa() {
18 void BrowserWindowCocoa::Init() {
21 void BrowserWindowCocoa::Show() {
22   [window_ makeKeyAndOrderFront:controller_];
25 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
26   NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, bounds.width(),
27                                    bounds.height());
28   // flip coordinates
29   NSScreen* screen = [window_ screen];
30   cocoa_bounds.origin.y = 
31       [screen frame].size.height - bounds.height() - bounds.y();
34 // Callers assume that this doesn't immediately delete the Browser object.
35 // The controller implementing the window delegate methods called from
36 // |-performClose:| must take precautiions to ensure that.
37 void BrowserWindowCocoa::Close() {
38   [window_ orderOut:controller_];
39   [window_ performClose:controller_];
42 void BrowserWindowCocoa::Activate() {
43   [window_ makeKeyAndOrderFront:controller_];
46 void BrowserWindowCocoa::FlashFrame() {
47   [[NSApplication sharedApplication] 
48       requestUserAttention:NSInformationalRequest];
51 void* BrowserWindowCocoa::GetNativeHandle() {
52   return [controller_ window];
55 BrowserWindowTesting* BrowserWindowCocoa::GetBrowserWindowTesting() {
56   return NULL;
59 StatusBubble* BrowserWindowCocoa::GetStatusBubble() {
60   return NULL;
63 void BrowserWindowCocoa::SelectedTabToolbarSizeChanged(bool is_animating) {
64   NOTIMPLEMENTED();
67 void BrowserWindowCocoa::UpdateTitleBar() {
68   NOTIMPLEMENTED();
71 void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) {
72   NOTIMPLEMENTED();
75 void BrowserWindowCocoa::SetStarredState(bool is_starred) {
76   [controller_ setStarredState:is_starred ? YES : NO];
79 gfx::Rect BrowserWindowCocoa::GetNormalBounds() const {
80   // TODO(pinkerton): not sure if we can get the non-zoomed bounds, or if it
81   // really matters. We may want to let Cocoa handle all this for us.
82   NSRect frame = [window_ frame];
83   NSScreen* screen = [window_ screen];
84   gfx::Rect bounds(frame.origin.x, 0, frame.size.width, frame.size.height);
85   bounds.set_y([screen frame].size.height + frame.size.height + frame.origin.y);
86   return bounds;
89 bool BrowserWindowCocoa::IsMaximized() const {
90   return [window_ isZoomed];
93 void BrowserWindowCocoa::SetFullscreen(bool fullscreen) {
94   NOTIMPLEMENTED();
97 bool BrowserWindowCocoa::IsFullscreen() const {
98   NOTIMPLEMENTED();
99   return false;
102 gfx::Rect BrowserWindowCocoa::GetRootWindowResizerRect() const {
103   NSRect tabRect = [controller_ selectedTabGrowBoxRect];
104   return gfx::Rect(NSRectToCGRect(tabRect));
107 LocationBar* BrowserWindowCocoa::GetLocationBar() const {
108   return [controller_ locationBar];
111 void BrowserWindowCocoa::SetFocusToLocationBar() {
112   NOTIMPLEMENTED();
115 void BrowserWindowCocoa::UpdateStopGoState(bool is_loading) {
116   NOTIMPLEMENTED();
119 void BrowserWindowCocoa::UpdateToolbar(TabContents* contents,
120                                        bool should_restore_state) {
121   [controller_ updateToolbarWithContents:contents 
122                       shouldRestoreState:should_restore_state ? YES : NO];
125 void BrowserWindowCocoa::FocusToolbar() {
126   NOTIMPLEMENTED();
129 bool BrowserWindowCocoa::IsBookmarkBarVisible() const {
130   NOTIMPLEMENTED();
131   return true;
134 void BrowserWindowCocoa::ToggleBookmarkBar() {
135   NOTIMPLEMENTED();
138 void BrowserWindowCocoa::ShowFindBar() {
139   NOTIMPLEMENTED();
142 void BrowserWindowCocoa::ShowAboutChromeDialog() {
143   NOTIMPLEMENTED();
146 void BrowserWindowCocoa::ShowBookmarkManager() {
147   NOTIMPLEMENTED();
150 void BrowserWindowCocoa::ShowBookmarkBubble(const GURL& url,
151                                             bool already_bookmarked) {
152   NOTIMPLEMENTED();
155 void BrowserWindowCocoa::ShowReportBugDialog() {
156   NOTIMPLEMENTED();
159 void BrowserWindowCocoa::ShowClearBrowsingDataDialog() {
160   NOTIMPLEMENTED();
163 void BrowserWindowCocoa::ShowImportDialog() {
164   NOTIMPLEMENTED();
167 void BrowserWindowCocoa::ShowSearchEnginesDialog() {
168   NOTIMPLEMENTED();
171 void BrowserWindowCocoa::ShowPasswordManager() {
172   NOTIMPLEMENTED();
175 void BrowserWindowCocoa::ShowSelectProfileDialog() {
176   NOTIMPLEMENTED();
179 void BrowserWindowCocoa::ShowNewProfileDialog() {
180   NOTIMPLEMENTED();
183 void BrowserWindowCocoa::ShowHTMLDialog(HtmlDialogContentsDelegate* delegate,
184                                         void* parent_window) {
185   NOTIMPLEMENTED();
187                             
188 void BrowserWindowCocoa::DestroyBrowser() {
189   [controller_ destroyBrowser];
191   // at this point the controller is dead (autoreleased), so
192   // make sure we don't try to reference it any more.