OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <numeric> | 8 #include <numeric> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 | 295 |
296 // Create a sub-controller for the docked devTools and add its view to the | 296 // Create a sub-controller for the docked devTools and add its view to the |
297 // hierarchy. | 297 // hierarchy. |
298 devToolsController_.reset([[DevToolsController alloc] init]); | 298 devToolsController_.reset([[DevToolsController alloc] init]); |
299 [[devToolsController_ view] setFrame:[[self tabContentArea] bounds]]; | 299 [[devToolsController_ view] setFrame:[[self tabContentArea] bounds]]; |
300 [[self tabContentArea] addSubview:[devToolsController_ view]]; | 300 [[self tabContentArea] addSubview:[devToolsController_ view]]; |
301 | 301 |
302 // Create the overlayable contents controller. This provides the switch | 302 // Create the overlayable contents controller. This provides the switch |
303 // view that TabStripController needs. | 303 // view that TabStripController needs. |
304 overlayableContentsController_.reset( | 304 overlayableContentsController_.reset( |
305 [[OverlayableContentsController alloc] initWithBrowser:browser]); | 305 [[OverlayableContentsController alloc] init]); |
306 [[overlayableContentsController_ view] | 306 [[overlayableContentsController_ view] |
307 setFrame:[[devToolsController_ view] bounds]]; | 307 setFrame:[[devToolsController_ view] bounds]]; |
308 [[devToolsController_ view] | 308 [[devToolsController_ view] |
309 addSubview:[overlayableContentsController_ view]]; | 309 addSubview:[overlayableContentsController_ view]]; |
310 | 310 |
311 // Create a controller for the tab strip, giving it the model object for | 311 // Create a controller for the tab strip, giving it the model object for |
312 // this window's Browser and the tab strip view. The controller will handle | 312 // this window's Browser and the tab strip view. The controller will handle |
313 // registering for the appropriate tab notifications from the back-end and | 313 // registering for the appropriate tab notifications from the back-end and |
314 // managing the creation of new tabs. | 314 // managing the creation of new tabs. |
315 [self createTabStripController]; | 315 [self createTabStripController]; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 // before releasing the controller. | 432 // before releasing the controller. |
433 [presentationModeController_ exitPresentationMode]; | 433 [presentationModeController_ exitPresentationMode]; |
434 presentationModeController_.reset(); | 434 presentationModeController_.reset(); |
435 | 435 |
436 // Under certain testing configurations we may not actually own the browser. | 436 // Under certain testing configurations we may not actually own the browser. |
437 if (ownsBrowser_ == NO) | 437 if (ownsBrowser_ == NO) |
438 ignore_result(browser_.release()); | 438 ignore_result(browser_.release()); |
439 | 439 |
440 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 440 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
441 | 441 |
442 // Inform reference counted objects that the Browser will be destroyed. This | |
443 // insures they invalidate their weak Browser* to prevent use-after-free. | |
tapted
2015/07/06 07:26:17
insures -> ensures?
jackhou1
2015/07/07 03:27:26
Done.
| |
444 // These may outlive the Browser if they are retained by something else, e.g. | |
445 // an autorelease NSView or an NSEvent. | |
446 [toolbarController_ browserWillBeDestroyed]; | |
447 [tabStripController_ browserWillBeDestroyed]; | |
448 [findBarCocoaController_ browserWillBeDestroyed]; | |
449 [downloadShelfController_ browserWillBeDestroyed]; | |
450 [bookmarkBarController_ browserWillBeDestroyed]; | |
451 [avatarButtonController_ browserWillBeDestroyed]; | |
452 | |
442 [super dealloc]; | 453 [super dealloc]; |
443 } | 454 } |
444 | 455 |
445 - (gfx::Rect)enforceMinWindowSize:(gfx::Rect)bounds { | 456 - (gfx::Rect)enforceMinWindowSize:(gfx::Rect)bounds { |
446 gfx::Rect checkedBounds = bounds; | 457 gfx::Rect checkedBounds = bounds; |
447 | 458 |
448 NSSize minSize = [[self window] minSize]; | 459 NSSize minSize = [[self window] minSize]; |
449 if (bounds.width() < minSize.width) | 460 if (bounds.width() < minSize.width) |
450 checkedBounds.set_width(minSize.width); | 461 checkedBounds.set_width(minSize.width); |
451 if (bounds.height() < minSize.height) | 462 if (bounds.height() < minSize.height) |
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2245 | 2256 |
2246 - (BOOL)supportsBookmarkBar { | 2257 - (BOOL)supportsBookmarkBar { |
2247 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2258 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2248 } | 2259 } |
2249 | 2260 |
2250 - (BOOL)isTabbedWindow { | 2261 - (BOOL)isTabbedWindow { |
2251 return browser_->is_type_tabbed(); | 2262 return browser_->is_type_tabbed(); |
2252 } | 2263 } |
2253 | 2264 |
2254 @end // @implementation BrowserWindowController(WindowType) | 2265 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |