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

Side by Side Diff: chrome/browser/cocoa/browser_window_controller.mm

Issue 70001: Force c++ dtors to get called in objc interfaces (it was always on since gcc4... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/app/chrome_dll_resource.h" // IDC_* 5 #include "chrome/app/chrome_dll_resource.h" // IDC_*
6 #include "chrome/browser/browser.h" 6 #include "chrome/browser/browser.h"
7 #include "chrome/browser/browser_list.h" 7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/tab_contents/web_contents.h" 8 #include "chrome/browser/tab_contents/web_contents.h"
9 #include "chrome/browser/tab_contents/web_contents_view.h" 9 #include "chrome/browser/tab_contents/web_contents_view.h"
10 #include "chrome/browser/tabs/tab_strip_model.h" 10 #include "chrome/browser/tabs/tab_strip_model.h"
11 #import "chrome/browser/cocoa/browser_window_cocoa.h" 11 #import "chrome/browser/cocoa/browser_window_cocoa.h"
12 #import "chrome/browser/cocoa/browser_window_controller.h" 12 #import "chrome/browser/cocoa/browser_window_controller.h"
13 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" 13 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
14 #import "chrome/browser/cocoa/tab_strip_view.h" 14 #import "chrome/browser/cocoa/tab_strip_view.h"
15 #import "chrome/browser/cocoa/tab_strip_controller.h" 15 #import "chrome/browser/cocoa/tab_strip_controller.h"
16 #import "chrome/browser/cocoa/tab_view.h" 16 #import "chrome/browser/cocoa/tab_view.h"
17 #import "chrome/browser/cocoa/toolbar_controller.h" 17 #import "chrome/browser/cocoa/toolbar_controller.h"
18 18
19 @interface BrowserWindowController(Private) 19 @interface BrowserWindowController(Private)
20 - (void)positionToolbar; 20 - (void)positionToolbar;
21 @end 21 @end
22 22
23 @implementation BrowserWindowController 23 @implementation BrowserWindowController
24 24
25 // Load the browser window nib and do any Cocoa-specific initialization. 25 // Load the browser window nib and do any Cocoa-specific initialization.
26 // Takes ownership of |browser|. Note that the nib also sets this controller 26 // Takes ownership of |browser|. Note that the nib also sets this controller
27 // up as the window's delegate. 27 // up as the window's delegate.
28 - (id)initWithBrowser:(Browser*)browser { 28 - (id)initWithBrowser:(Browser*)browser {
29 if ((self = [super initWithWindowNibName:@"BrowserWindow"])) { 29 if ((self = [super initWithWindowNibName:@"BrowserWindow"])) {
30 browser_ = browser; 30 browser_.reset(browser);
31 DCHECK(browser_); 31 DCHECK(browser_.get());
Mark Mentovai 2009/04/10 15:23:29 Eliminate a .get() if you DCHCEK on browser instea
32 tabObserver_ = new TabStripModelObserverBridge(browser->tabstrip_model(), 32 tabObserver_.reset(
33 self); 33 new TabStripModelObserverBridge(browser->tabstrip_model(), self));
34 windowShim_ = new BrowserWindowCocoa(browser, self, [self window]); 34 windowShim_.reset(new BrowserWindowCocoa(browser, self, [self window]));
35 35
36 // The window is now fully realized and |-windowDidLoad:| has been 36 // The window is now fully realized and |-windowDidLoad:| has been
37 // called. We shouldn't do much in wDL because |windowShim_| won't yet 37 // called. We shouldn't do much in wDL because |windowShim_| won't yet
38 // be initialized (as it's called in response to |[self window]| above). 38 // be initialized (as it's called in response to |[self window]| above).
39 39
40 // Get the most appropriate size for the window. The window shim will handle 40 // Get the most appropriate size for the window. The window shim will handle
41 // flipping the coordinates for us so we can use it to save some code. 41 // flipping the coordinates for us so we can use it to save some code.
42 gfx::Rect windowRect = browser_->GetSavedWindowBounds(); 42 gfx::Rect windowRect = browser_->GetSavedWindowBounds();
43 windowShim_->SetBounds(windowRect); 43 windowShim_->SetBounds(windowRect);
44 44
45 // Create a controller for the tab strip, giving it the model object for 45 // Create a controller for the tab strip, giving it the model object for
46 // this window's Browser and the tab strip view. The controller will handle 46 // this window's Browser and the tab strip view. The controller will handle
47 // registering for the appropriate tab notifications from the back-end and 47 // registering for the appropriate tab notifications from the back-end and
48 // managing the creation of new tabs. 48 // managing the creation of new tabs.
49 tabStripController_ = [[TabStripController alloc] 49 tabStripController_.reset([[TabStripController alloc]
50 initWithView:[self tabStripView] 50 initWithView:[self tabStripView]
51 switchView:[self tabContentArea] 51 switchView:[self tabContentArea]
52 browser:browser_]; 52 browser:browser_.get()]);
53 53
54 // Create a controller for the toolbar, giving it the toolbar model object 54 // Create a controller for the toolbar, giving it the toolbar model object
55 // and the toolbar view from the nib. The controller will handle 55 // and the toolbar view from the nib. The controller will handle
56 // registering for the appropriate command state changes from the back-end. 56 // registering for the appropriate command state changes from the back-end.
57 toolbarController_ = [[ToolbarController alloc] 57 toolbarController_.reset([[ToolbarController alloc]
58 initWithModel:browser->toolbar_model() 58 initWithModel:browser->toolbar_model()
59 commands:browser->command_updater()]; 59 commands:browser->command_updater()]);
60 [self positionToolbar]; 60 [self positionToolbar];
61 } 61 }
62 return self; 62 return self;
63 } 63 }
64 64
65 - (void)dealloc { 65 - (void)dealloc {
66 browser_->CloseAllTabs(); 66 browser_->CloseAllTabs();
67 [tabStripController_ release];
68 [toolbarController_ release];
69 delete windowShim_;
70 delete tabObserver_;
71 delete browser_;
72 [super dealloc]; 67 [super dealloc];
73 } 68 }
74 69
75 // Access the C++ bridge between the NSWindow and the rest of Chromium 70 // Access the C++ bridge between the NSWindow and the rest of Chromium
76 - (BrowserWindow*)browserWindow { 71 - (BrowserWindow*)browserWindow {
77 return windowShim_; 72 return windowShim_.get();
78 } 73 }
79 74
80 // Position |toolbarView_| below the tab strip, but not as a sibling. The 75 // Position |toolbarView_| below the tab strip, but not as a sibling. The
81 // toolbar is part of the window's contentView, mainly because we want the 76 // toolbar is part of the window's contentView, mainly because we want the
82 // opacity during drags to be the same as the web content. 77 // opacity during drags to be the same as the web content.
83 - (void)positionToolbar { 78 - (void)positionToolbar {
84 NSView* contentView = [self tabContentArea]; 79 NSView* contentView = [self tabContentArea];
85 NSRect contentFrame = [contentView frame]; 80 NSRect contentFrame = [contentView frame];
86 NSView* toolbarView = [toolbarController_ view]; 81 NSView* toolbarView = [toolbarController_ view];
87 NSRect toolbarFrame = [toolbarView frame]; 82 NSRect toolbarFrame = [toolbarView frame];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 browser_->OnWindowClosing(); 135 browser_->OnWindowClosing();
141 return NO; 136 return NO;
142 } 137 }
143 138
144 // the tab strip is empty, it's ok to close the window 139 // the tab strip is empty, it's ok to close the window
145 return YES; 140 return YES;
146 } 141 }
147 142
148 // Called right after our window became the main window. 143 // Called right after our window became the main window.
149 - (void)windowDidBecomeMain:(NSNotification *)notification { 144 - (void)windowDidBecomeMain:(NSNotification *)notification {
150 BrowserList::SetLastActive(browser_); 145 BrowserList::SetLastActive(browser_.get());
151 } 146 }
152 147
153 // Update a toggle state for an NSMenuItem if modified. 148 // Update a toggle state for an NSMenuItem if modified.
154 // Take care to insure |item| looks like a NSMenuItem. 149 // Take care to insure |item| looks like a NSMenuItem.
155 // Called by validateUserInterfaceItem:. 150 // Called by validateUserInterfaceItem:.
156 - (void)updateToggleStateWithTag:(NSInteger)tag forItem:(id)item { 151 - (void)updateToggleStateWithTag:(NSInteger)tag forItem:(id)item {
157 if (![item respondsToSelector:@selector(state)] || 152 if (![item respondsToSelector:@selector(state)] ||
158 ![item respondsToSelector:@selector(setState:)]) 153 ![item respondsToSelector:@selector(setState:)])
159 return; 154 return;
160 155
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // TODO(pinkerton):Update as more things become window-specific 340 // TODO(pinkerton):Update as more things become window-specific
346 // Update all the UI bits. 341 // Update all the UI bits.
347 UpdateTitleBar(); 342 UpdateTitleBar();
348 toolbar_->SetProfile(new_contents->profile()); 343 toolbar_->SetProfile(new_contents->profile());
349 UpdateToolbar(new_contents, true); 344 UpdateToolbar(new_contents, true);
350 UpdateUIForContents(new_contents); 345 UpdateUIForContents(new_contents);
351 #endif 346 #endif
352 } 347 }
353 348
354 @end 349 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698