Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa.mm

Issue 790043002: Hosted apps on OS X now act more like a native app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@creating-app-shims-2
Patch Set: Moved functions, cleaned up code and created CloseBrowsersForApp function Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| 130 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:|
131 // until we return to the runloop. Therefore any calls to 131 // until we return to the runloop. Therefore any calls to
132 // |chrome::FindLastActiveWithHostDesktopType| will return the previous 132 // |chrome::FindLastActiveWithHostDesktopType| will return the previous
133 // browser instead if we don't explicitly set it here. 133 // browser instead if we don't explicitly set it here.
134 BrowserList::SetLastActive(browser_); 134 BrowserList::SetLastActive(browser_);
135 135
136 bool is_session_restore = browser_->is_session_restore(); 136 bool is_session_restore = browser_->is_session_restore();
137 NSWindowAnimationBehavior saved_animation_behavior = 137 NSWindowAnimationBehavior saved_animation_behavior =
138 NSWindowAnimationBehaviorDefault; 138 NSWindowAnimationBehaviorDefault;
139 bool did_save_animation_behavior = false; 139 bool did_save_animation_behavior = false;
140 // Turn off swishing when restoring windows. 140 // Turn off swishing when restoring windows or showing an app.
141 if (is_session_restore && 141 if ((is_session_restore || browser_->is_app()) &&
142 [window() respondsToSelector:@selector(animationBehavior)] && 142 [window() respondsToSelector:@selector(animationBehavior)] &&
143 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { 143 [window() respondsToSelector:@selector(setAnimationBehavior:)]) {
144 did_save_animation_behavior = true; 144 did_save_animation_behavior = true;
145 saved_animation_behavior = [window() animationBehavior]; 145 saved_animation_behavior = [window() animationBehavior];
146 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; 146 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone];
147 } 147 }
148 148
149 { 149 {
150 TRACE_EVENT0("ui", "BrowserWindowCocoa::Show makeKeyAndOrderFront"); 150 TRACE_EVENT0("ui", "BrowserWindowCocoa::Show makeKeyAndOrderFront");
151 // This call takes up a substantial part of startup time, and an even more 151 // This call takes up a substantial part of startup time, and an even more
(...skipping 18 matching lines...) Expand all
170 [window() setAnimationBehavior:saved_animation_behavior]; 170 [window() setAnimationBehavior:saved_animation_behavior];
171 171
172 browser_->OnWindowDidShow(); 172 browser_->OnWindowDidShow();
173 } 173 }
174 174
175 void BrowserWindowCocoa::ShowInactive() { 175 void BrowserWindowCocoa::ShowInactive() {
176 [window() orderFront:controller_]; 176 [window() orderFront:controller_];
177 } 177 }
178 178
179 void BrowserWindowCocoa::Hide() { 179 void BrowserWindowCocoa::Hide() {
180 // Not implemented. 180 [window() orderOut:controller_];
181 } 181 }
182 182
183 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { 183 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
184 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; 184 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds];
185 185
186 ExitFullscreen(); 186 ExitFullscreen();
187 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0, 187 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0,
188 real_bounds.width(), 188 real_bounds.width(),
189 real_bounds.height()); 189 real_bounds.height());
190 // Flip coordinates based on the primary screen. 190 // Flip coordinates based on the primary screen.
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) 807 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED)
808 return 0; 808 return 0;
809 return 40; 809 return 40;
810 } 810 }
811 811
812 void BrowserWindowCocoa::ExecuteExtensionCommand( 812 void BrowserWindowCocoa::ExecuteExtensionCommand(
813 const extensions::Extension* extension, 813 const extensions::Extension* extension,
814 const extensions::Command& command) { 814 const extensions::Command& command) {
815 [cocoa_controller() executeExtensionCommand:extension->id() command:command]; 815 [cocoa_controller() executeExtensionCommand:extension->id() command:command];
816 } 816 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698