Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 5 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 9 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
| 11 #include "chrome/browser/ui/panels/panel_manager.h" | |
| 11 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" | 12 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Use this instead of 0 for minimum size of a window when doing opening and | 16 // Use this instead of 0 for minimum size of a window when doing opening and |
| 16 // closing animations, since OSX window manager does not like 0-sized windows | 17 // closing animations, since OSX window manager does not like 0-sized windows |
| 17 // (according to avi@). | 18 // (according to avi@). |
| 18 const int kMinimumWindowSize = 1; | 19 const int kMinimumWindowSize = 1; |
| 19 | 20 |
| 20 // TODO(dcheng): Move elsewhere so BrowserWindowCocoa can use them too. | 21 // TODO(dcheng): Move elsewhere so BrowserWindowCocoa can use them too. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 int mouse_y) const { | 96 int mouse_y) const { |
| 96 NOTIMPLEMENTED(); | 97 NOTIMPLEMENTED(); |
| 97 return false; | 98 return false; |
| 98 } | 99 } |
| 99 | 100 |
| 100 void PanelBrowserWindowCocoa::ClosePanel() { | 101 void PanelBrowserWindowCocoa::ClosePanel() { |
| 101 if (isClosed()) | 102 if (isClosed()) |
| 102 return; | 103 return; |
| 103 | 104 |
| 104 NSWindow* window = [controller_ window]; | 105 NSWindow* window = [controller_ window]; |
| 105 NSRect frame = [window frame]; | 106 [window performClose:controller_]; |
|
jennb
2011/08/19 21:46:12
I prefer to animate the window offscreen here, the
Dmitry Titov
2011/08/22 18:34:56
See comment at the top.
| |
| 106 frame.size.height = kMinimumWindowSize; | |
| 107 // TODO(dimich): make this async. Currently, multiple panels will serially | |
| 108 // (and annoyingly) close when user exits Chrome. | |
| 109 [window setFrame:frame display:YES animate:YES]; | |
| 110 browser_->OnWindowClosing(); | |
| 111 DestroyPanelBrowser(); // not immediately, though. | |
| 112 } | 107 } |
| 113 | 108 |
| 114 void PanelBrowserWindowCocoa::ActivatePanel() { | 109 void PanelBrowserWindowCocoa::ActivatePanel() { |
| 115 NOTIMPLEMENTED(); | 110 NOTIMPLEMENTED(); |
| 116 } | 111 } |
| 117 | 112 |
| 118 void PanelBrowserWindowCocoa::DeactivatePanel() { | 113 void PanelBrowserWindowCocoa::DeactivatePanel() { |
| 119 NOTIMPLEMENTED(); | 114 NOTIMPLEMENTED(); |
| 120 } | 115 } |
| 121 | 116 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 NOTIMPLEMENTED(); | 152 NOTIMPLEMENTED(); |
| 158 return false; | 153 return false; |
| 159 } | 154 } |
| 160 | 155 |
| 161 Browser* PanelBrowserWindowCocoa::GetPanelBrowser() const { | 156 Browser* PanelBrowserWindowCocoa::GetPanelBrowser() const { |
| 162 return browser(); | 157 return browser(); |
| 163 } | 158 } |
| 164 | 159 |
| 165 void PanelBrowserWindowCocoa::DestroyPanelBrowser() { | 160 void PanelBrowserWindowCocoa::DestroyPanelBrowser() { |
| 166 [controller_ close]; | 161 [controller_ close]; |
| 162 } | |
| 163 | |
| 164 void PanelBrowserWindowCocoa::didCloseNativeWindow() { | |
| 165 DCHECK(!isClosed()); | |
| 166 panel_->manager()->Remove(panel_.get()); | |
| 167 controller_ = NULL; | 167 controller_ = NULL; |
| 168 } | 168 } |
| 169 | |
| 170 // NativePanelTesting implementation. | 169 // NativePanelTesting implementation. |
| 171 | 170 |
| 172 // static | 171 // static |
| 173 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { | 172 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
| 174 NOTIMPLEMENTED(); | 173 NOTIMPLEMENTED(); |
| 175 return NULL; | 174 return NULL; |
| 176 } | 175 } |
| OLD | NEW |