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

Side by Side Diff: chrome/browser/ui/panels/panel_window_controller_cocoa.mm

Issue 8205017: Fix crash when reloading extension with more than one panel open. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | « no previous file | 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) 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/panels/panel_window_controller_cocoa.h" 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // the renderer the proper size to work with earlier, avoiding a resize 131 // the renderer the proper size to work with earlier, avoiding a resize
132 // after the window is revealed. 132 // after the window is revealed.
133 gfx::Rect panelBounds = windowShim_->GetPanelBounds(); 133 gfx::Rect panelBounds = windowShim_->GetPanelBounds();
134 NSRect frame = [window frame]; 134 NSRect frame = [window frame];
135 frame.size.width = panelBounds.width(); 135 frame.size.width = panelBounds.width();
136 frame.size.height = panelBounds.height(); 136 frame.size.height = panelBounds.height();
137 [window setFrame:frame display:NO]; 137 [window setFrame:frame display:NO];
138 138
139 // Attach the RenderWigetHostView to the view hierarchy, it will render 139 // Attach the RenderWigetHostView to the view hierarchy, it will render
140 // HTML content. 140 // HTML content.
141 [[window contentView] addSubview:[self tabContentsView]]; 141 NSView* tabContentsView = [self tabContentsView];
142 DCHECK(tabContentsView);
143 [[window contentView] addSubview:tabContentsView];
142 [self enableTabContentsViewAutosizing]; 144 [self enableTabContentsViewAutosizing];
143 } 145 }
144 146
145 - (void)mouseEntered:(NSEvent*)event { 147 - (void)mouseEntered:(NSEvent*)event {
146 [titlebar_view_ updateSettingsButtonVisibility:YES]; 148 [titlebar_view_ updateSettingsButtonVisibility:YES];
147 } 149 }
148 150
149 - (void)mouseExited:(NSEvent*)event { 151 - (void)mouseExited:(NSEvent*)event {
150 [titlebar_view_ updateSettingsButtonVisibility:NO]; 152 [titlebar_view_ updateSettingsButtonVisibility:NO];
151 } 153 }
152 154
153 - (void)disableTabContentsViewAutosizing { 155 - (void)disableTabContentsViewAutosizing {
154 NSView* tabContentView = [self tabContentsView]; 156 NSView* tabContentView = [self tabContentsView];
157 if (!tabContentView)
158 return;
159
155 DCHECK([tabContentView superview] == [[self window] contentView]); 160 DCHECK([tabContentView superview] == [[self window] contentView]);
156 [tabContentView setAutoresizingMask:NSViewNotSizable]; 161 [tabContentView setAutoresizingMask:NSViewNotSizable];
157 } 162 }
158 163
159 - (void)enableTabContentsViewAutosizing { 164 - (void)enableTabContentsViewAutosizing {
160 NSView* tabContentView = [self tabContentsView]; 165 NSView* tabContentView = [self tabContentsView];
166 if (!tabContentView)
167 return;
168
161 DCHECK([tabContentView superview] == [[self window] contentView]); 169 DCHECK([tabContentView superview] == [[self window] contentView]);
162 170
163 // Parent's bounds is child's frame. 171 // Parent's bounds is child's frame.
164 NSRect frame = [[[self window] contentView] bounds]; 172 NSRect frame = [[[self window] contentView] bounds];
165 [tabContentView setFrame:frame]; 173 [tabContentView setFrame:frame];
166 [tabContentView 174 [tabContentView
167 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; 175 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
168 } 176 }
169 177
170 - (void)revealAnimatedWithFrame:(const NSRect&)frame { 178 - (void)revealAnimatedWithFrame:(const NSRect&)frame {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 NSView* contentView = [[self window] contentView]; 248 NSView* contentView = [[self window] contentView];
241 [contentView addSubview:[findBarCocoaController view]]; 249 [contentView addSubview:[findBarCocoaController view]];
242 250
243 CGFloat maxY = NSMaxY([contentView frame]); 251 CGFloat maxY = NSMaxY([contentView frame]);
244 CGFloat maxWidth = NSWidth([contentView frame]); 252 CGFloat maxWidth = NSWidth([contentView frame]);
245 [findBarCocoaController positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; 253 [findBarCocoaController positionFindBarViewAtMaxY:maxY maxWidth:maxWidth];
246 } 254 }
247 255
248 - (NSView*)tabContentsView { 256 - (NSView*)tabContentsView {
249 TabContents* contents = windowShim_->browser()->GetSelectedTabContents(); 257 TabContents* contents = windowShim_->browser()->GetSelectedTabContents();
250 CHECK(contents); 258 if (contents)
251 NSView* tabContentView = contents->GetNativeView(); 259 return contents->GetNativeView();
252 CHECK(tabContentView); 260 return NULL;
253 return tabContentView;
254 } 261 }
255 262
256 - (PanelTitlebarViewCocoa*)titlebarView { 263 - (PanelTitlebarViewCocoa*)titlebarView {
257 return titlebar_view_; 264 return titlebar_view_;
258 } 265 }
259 266
260 // Called to validate menu and toolbar items when this window is key. All the 267 // Called to validate menu and toolbar items when this window is key. All the
261 // items we care about have been set with the |-commandDispatch:| or 268 // items we care about have been set with the |-commandDispatch:| or
262 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder 269 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder
263 // in IB. If it's not one of those, let it continue up the responder chain to be 270 // in IB. If it's not one of those, let it continue up the responder chain to be
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 NotificationService::NoDetails()); 542 NotificationService::NoDetails());
536 } 543 }
537 544
538 // TestingAPI interface implementation 545 // TestingAPI interface implementation
539 546
540 + (void)enableBoundsAnimationNotifications { 547 + (void)enableBoundsAnimationNotifications {
541 g_reportAnimationStatus = YES; 548 g_reportAnimationStatus = YES;
542 } 549 }
543 550
544 @end 551 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698