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/cocoa/browser_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 | 85 |
| 86 void BrowserWindowCocoa::Show() { | 86 void BrowserWindowCocoa::Show() { |
| 87 // The Browser associated with this browser window must become the active | 87 // The Browser associated with this browser window must become the active |
| 88 // browser at the time |Show()| is called. This is the natural behaviour under | 88 // browser at the time |Show()| is called. This is the natural behaviour under |
| 89 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| | 89 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| |
| 90 // until we return to the runloop. Therefore any calls to | 90 // until we return to the runloop. Therefore any calls to |
| 91 // |BrowserList::GetLastActive()| (for example, in bookmark_util), will return | 91 // |BrowserList::GetLastActive()| (for example, in bookmark_util), will return |
| 92 // the previous browser instead if we don't explicitly set it here. | 92 // the previous browser instead if we don't explicitly set it here. |
| 93 BrowserList::SetLastActive(browser_); | 93 BrowserList::SetLastActive(browser_); |
| 94 | 94 |
| 95 ui::WindowShowState show_state = browser_->GetSavedWindowShowState(); | 95 bool is_session_restore = browser_->is_session_restore(); |
| 96 if (show_state == ui::SHOW_STATE_MINIMIZED) { | 96 NSWindowAnimationBehavior saved_animation_behavior; |
|
Nico
2011/09/01 16:28:41
In gcc release builds (which is what the valgrind
| |
| 97 // Turn off swishing when restoring minimized windows. When creating | 97 bool did_save_animation_behavior = false; |
| 98 // windows from nibs it is necessary to |orderFront:| prior to |orderOut:| | 98 // Turn off swishing when restoring windows. |
| 99 // then |miniaturize:| when restoring windows in the minimized state. | 99 if (is_session_restore && |
| 100 NSWindowAnimationBehavior savedAnimationBehavior = 0; | 100 [window() respondsToSelector:@selector(animationBehavior)] && |
| 101 if ([window() respondsToSelector:@selector(animationBehavior)] && | 101 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { |
| 102 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { | 102 did_save_animation_behavior = true; |
| 103 savedAnimationBehavior = [window() animationBehavior]; | 103 saved_animation_behavior = [window() animationBehavior]; |
| 104 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; | 104 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; |
| 105 } | 105 } |
| 106 | 106 |
| 107 [window() makeKeyAndOrderFront:controller_]; | 107 [window() makeKeyAndOrderFront:controller_]; |
| 108 | 108 |
| 109 // When creating windows from nibs it is necessary to |makeKeyAndOrderFront:| | |
| 110 // prior to |orderOut:| then |miniaturize:| when restoring windows in the | |
| 111 // minimized state. | |
| 112 if (browser_->GetSavedWindowShowState() == ui::SHOW_STATE_MINIMIZED) { | |
| 109 [window() orderOut:controller_]; | 113 [window() orderOut:controller_]; |
| 110 [window() miniaturize:controller_]; | 114 [window() miniaturize:controller_]; |
| 115 } | |
| 111 | 116 |
| 112 // Restore window animation behavior. | 117 // Restore window animation behavior. |
| 113 if ([window() respondsToSelector:@selector(animationBehavior)] && | 118 if (did_save_animation_behavior) |
| 114 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { | 119 [window() setAnimationBehavior:saved_animation_behavior]; |
| 115 [window() setAnimationBehavior:savedAnimationBehavior]; | |
| 116 } | |
| 117 } else { | |
| 118 [window() makeKeyAndOrderFront:controller_]; | |
| 119 } | |
| 120 } | 120 } |
| 121 | 121 |
| 122 void BrowserWindowCocoa::ShowInactive() { | 122 void BrowserWindowCocoa::ShowInactive() { |
| 123 [window() orderFront:controller_]; | 123 [window() orderFront:controller_]; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { | 126 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { |
| 127 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; | 127 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; |
| 128 | 128 |
| 129 SetFullscreen(false); | 129 SetFullscreen(false); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 | 577 |
| 578 NSWindow* BrowserWindowCocoa::window() const { | 578 NSWindow* BrowserWindowCocoa::window() const { |
| 579 return [controller_ window]; | 579 return [controller_ window]; |
| 580 } | 580 } |
| 581 | 581 |
| 582 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { | 582 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { |
| 583 if (tab_contents == browser_->GetSelectedTabContents()) { | 583 if (tab_contents == browser_->GetSelectedTabContents()) { |
| 584 [controller_ updateSidebarForContents:tab_contents]; | 584 [controller_ updateSidebarForContents:tab_contents]; |
| 585 } | 585 } |
| 586 } | 586 } |
| OLD | NEW |