| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 void BrowserWindowCocoa::Show() { | 87 void BrowserWindowCocoa::Show() { |
| 88 // The Browser associated with this browser window must become the active | 88 // The Browser associated with this browser window must become the active |
| 89 // browser at the time |Show()| is called. This is the natural behaviour under | 89 // browser at the time |Show()| is called. This is the natural behaviour under |
| 90 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| | 90 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| |
| 91 // until we return to the runloop. Therefore any calls to | 91 // until we return to the runloop. Therefore any calls to |
| 92 // |BrowserList::GetLastActive()| (for example, in bookmark_util), will return | 92 // |BrowserList::GetLastActive()| (for example, in bookmark_util), will return |
| 93 // the previous browser instead if we don't explicitly set it here. | 93 // the previous browser instead if we don't explicitly set it here. |
| 94 BrowserList::SetLastActive(browser_); | 94 BrowserList::SetLastActive(browser_); |
| 95 | 95 |
| 96 ui::WindowShowState show_state = browser_->GetSavedWindowShowState(); | 96 bool is_session_restore = browser_->is_session_restore(); |
| 97 if (show_state == ui::SHOW_STATE_MINIMIZED) { | 97 NSWindowAnimationBehavior savedAnimationBehavior = 0; |
| 98 // Turn off swishing when restoring minimized windows. When creating | 98 if (is_session_restore) { |
| 99 // windows from nibs it is necessary to |orderFront:| prior to |orderOut:| | 99 // Turn off swishing when restoring windows. |
| 100 // then |miniaturize:| when restoring windows in the minimized state. | |
| 101 NSWindowAnimationBehavior savedAnimationBehavior = 0; | |
| 102 if ([window() respondsToSelector:@selector(animationBehavior)] && | 100 if ([window() respondsToSelector:@selector(animationBehavior)] && |
| 103 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { | 101 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { |
| 104 savedAnimationBehavior = [window() animationBehavior]; | 102 savedAnimationBehavior = [window() animationBehavior]; |
| 105 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; | 103 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; |
| 106 } | 104 } |
| 105 } |
| 107 | 106 |
| 108 [window() makeKeyAndOrderFront:controller_]; | 107 [window() makeKeyAndOrderFront:controller_]; |
| 109 | 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) { |
| 110 [window() orderOut:controller_]; | 113 [window() orderOut:controller_]; |
| 111 [window() miniaturize:controller_]; | 114 [window() miniaturize:controller_]; |
| 115 } |
| 112 | 116 |
| 117 if (is_session_restore) { |
| 113 // Restore window animation behavior. | 118 // Restore window animation behavior. |
| 114 if ([window() respondsToSelector:@selector(animationBehavior)] && | 119 if ([window() respondsToSelector:@selector(animationBehavior)] && |
| 115 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { | 120 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { |
| 116 [window() setAnimationBehavior:savedAnimationBehavior]; | 121 [window() setAnimationBehavior:savedAnimationBehavior]; |
| 117 } | 122 } |
| 118 } else { | |
| 119 [window() makeKeyAndOrderFront:controller_]; | |
| 120 } | 123 } |
| 124 |
| 125 // Once the window has been shown, clear the session restore flag. |
| 126 browser_->set_is_session_restore(false); |
| 121 } | 127 } |
| 122 | 128 |
| 123 void BrowserWindowCocoa::ShowInactive() { | 129 void BrowserWindowCocoa::ShowInactive() { |
| 124 [window() orderFront:controller_]; | 130 [window() orderFront:controller_]; |
| 125 } | 131 } |
| 126 | 132 |
| 127 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { | 133 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { |
| 128 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; | 134 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; |
| 129 | 135 |
| 130 SetFullscreen(false); | 136 SetFullscreen(false); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 584 |
| 579 NSWindow* BrowserWindowCocoa::window() const { | 585 NSWindow* BrowserWindowCocoa::window() const { |
| 580 return [controller_ window]; | 586 return [controller_ window]; |
| 581 } | 587 } |
| 582 | 588 |
| 583 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { | 589 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { |
| 584 if (tab_contents == browser_->GetSelectedTabContents()) { | 590 if (tab_contents == browser_->GetSelectedTabContents()) { |
| 585 [controller_ updateSidebarForContents:tab_contents]; | 591 [controller_ updateSidebarForContents:tab_contents]; |
| 586 } | 592 } |
| 587 } | 593 } |
| OLD | NEW |