OLD | NEW |
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 #import "chrome/browser/ui/cocoa/certificate_viewer_mac.h" | 5 #import "chrome/browser/ui/cocoa/certificate_viewer_mac.h" |
6 | 6 |
7 #include <Security/Security.h> | 7 #include <Security/Security.h> |
8 #include <SecurityInterface/SFCertificatePanel.h> | 8 #include <SecurityInterface/SFCertificatePanel.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // method. | 161 // method. |
162 [panel_ _dismissWithCode:NSFileHandlingPanelCancelButton]; | 162 [panel_ _dismissWithCode:NSFileHandlingPanelCancelButton]; |
163 } | 163 } |
164 | 164 |
165 - (void)hideSheet { | 165 - (void)hideSheet { |
166 NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; | 166 NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; |
167 [sheetWindow setAlphaValue:0.0]; | 167 [sheetWindow setAlphaValue:0.0]; |
168 | 168 |
169 oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews]; | 169 oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews]; |
170 [[sheetWindow contentView] setAutoresizesSubviews:NO]; | 170 [[sheetWindow contentView] setAutoresizesSubviews:NO]; |
| 171 |
| 172 oldSheetFrame_ = [sheetWindow frame]; |
| 173 NSRect overlayFrame = [overlayWindow_ frame]; |
| 174 oldSheetFrame_.origin.x -= NSMinX(overlayFrame); |
| 175 oldSheetFrame_.origin.y -= NSMinY(overlayFrame); |
| 176 oldOverlaySize_ = [overlayWindow_ frame].size; |
| 177 [sheetWindow setFrame:ui::kWindowSizeDeterminedLater display:NO]; |
171 } | 178 } |
172 | 179 |
173 - (void)unhideSheet { | 180 - (void)unhideSheet { |
174 NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; | 181 NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; |
| 182 NSRect overlayFrame = [overlayWindow_ frame]; |
| 183 |
| 184 // If the overlay frame's size has changed, the position offsets need to be |
| 185 // calculated. Since the certificate is horizontally centered, so the x |
| 186 // offset is calculated by halving the width difference. In addition, |
| 187 // because the certificate is located directly below the toolbar, the y |
| 188 // offset is just the difference in height. |
| 189 CGFloat yOffset = (NSHeight(overlayFrame) - oldOverlaySize_.height); |
| 190 CGFloat xOffset = (NSWidth(overlayFrame) - oldOverlaySize_.width) / 2; |
| 191 |
| 192 oldSheetFrame_.origin.x += NSMinX(overlayFrame) + xOffset; |
| 193 oldSheetFrame_.origin.y += NSMinY(overlayFrame) + yOffset; |
| 194 [sheetWindow setFrame:oldSheetFrame_ display:NO]; |
175 | 195 |
176 [[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_]; | 196 [[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_]; |
177 [[overlayWindow_ attachedSheet] setAlphaValue:1.0]; | 197 [[overlayWindow_ attachedSheet] setAlphaValue:1.0]; |
178 } | 198 } |
179 | 199 |
180 - (void)pulseSheet { | 200 - (void)pulseSheet { |
181 // NOOP | 201 // NOOP |
182 } | 202 } |
183 | 203 |
184 - (void)makeSheetKeyAndOrderFront { | 204 - (void)makeSheetKeyAndOrderFront { |
(...skipping 12 matching lines...) Expand all Loading... |
197 return panel_; | 217 return panel_; |
198 } | 218 } |
199 | 219 |
200 - (void)onConstrainedWindowClosed { | 220 - (void)onConstrainedWindowClosed { |
201 panel_.reset(); | 221 panel_.reset(); |
202 constrainedWindow_.reset(); | 222 constrainedWindow_.reset(); |
203 [self release]; | 223 [self release]; |
204 } | 224 } |
205 | 225 |
206 @end | 226 @end |
OLD | NEW |