Chromium Code Reviews| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 closePending_ = YES; | 158 closePending_ = YES; |
| 159 overlayWindow_.reset(); | 159 overlayWindow_.reset(); |
| 160 // Closing the sheet using -[NSApp endSheet:] doesn't work so use the private | 160 // Closing the sheet using -[NSApp endSheet:] doesn't work so use the private |
| 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 [sheetWindow setIgnoresMouseEvents:YES]; | |
| 168 | 169 |
| 169 oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews]; | 170 oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews]; |
| 170 [[sheetWindow contentView] setAutoresizesSubviews:NO]; | 171 [[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]; | |
| 178 } | 172 } |
| 179 | 173 |
| 180 - (void)unhideSheet { | 174 - (void)unhideSheet { |
| 181 NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; | 175 NSWindow* sheetWindow = [overlayWindow_ attachedSheet]; |
| 182 NSRect overlayFrame = [overlayWindow_ frame]; | 176 [sheetWindow setIgnoresMouseEvents:NO]; |
| 183 | |
| 184 // If the overlay frame's size has changed, the position offsets need to be | |
|
tapted
2016/06/17 06:11:33
So does this happen automatically? (i.e. does the
Patti Lor
2016/06/20 03:42:28
Yep, the certificate viewer position is controlled
| |
| 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]; | |
| 195 | 177 |
| 196 [[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_]; | 178 [[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_]; |
| 197 [[overlayWindow_ attachedSheet] setAlphaValue:1.0]; | 179 [[overlayWindow_ attachedSheet] setAlphaValue:1.0]; |
| 198 } | 180 } |
| 199 | 181 |
| 200 - (void)pulseSheet { | 182 - (void)pulseSheet { |
| 201 // NOOP | 183 // NOOP |
| 202 } | 184 } |
| 203 | 185 |
| 204 - (void)makeSheetKeyAndOrderFront { | 186 - (void)makeSheetKeyAndOrderFront { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 217 return panel_; | 199 return panel_; |
| 218 } | 200 } |
| 219 | 201 |
| 220 - (void)onConstrainedWindowClosed { | 202 - (void)onConstrainedWindowClosed { |
| 221 panel_.reset(); | 203 panel_.reset(); |
| 222 constrainedWindow_.reset(); | 204 constrainedWindow_.reset(); |
| 223 [self release]; | 205 [self release]; |
| 224 } | 206 } |
| 225 | 207 |
| 226 @end | 208 @end |
| OLD | NEW |