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

Unified Diff: chrome/browser/ui/cocoa/certificate_viewer_mac.mm

Issue 2034993002: Fix Hiding Issue with Certificate Viewer Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert the old CL's change on the browser test Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/certificate_viewer_mac.mm
diff --git a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm b/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
index 1adb0f166bd8687c67f8d0aa8155bed3b1d21f63..1a079cac5723e8e6dc1df15863bd4d3c51d4dd17 100644
--- a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
@@ -168,10 +168,30 @@ void ShowCertificateViewer(content::WebContents* web_contents,
oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews];
[[sheetWindow contentView] setAutoresizesSubviews:NO];
+
+ oldSheetFrame_ = [sheetWindow frame];
+ NSRect overlayFrame = [overlayWindow_ frame];
+ oldSheetFrame_.origin.x -= NSMinX(overlayFrame);
+ oldSheetFrame_.origin.y -= NSMinY(overlayFrame);
+ oldOverlaySize_ = [overlayWindow_ frame].size;
+ [sheetWindow setFrame:ui::kWindowSizeDeterminedLater display:NO];
}
- (void)unhideSheet {
NSWindow* sheetWindow = [overlayWindow_ attachedSheet];
+ NSRect overlayFrame = [overlayWindow_ frame];
+
+ // If the overlay frame's size has changed, the position offsets need to be
+ // calculated. Since the certificate is horizontally centered, so the x
+ // offset is calculated by halving the width difference. In addition,
+ // because the certificate is located directly below the toolbar, the y
+ // offset is just the difference in height.
+ CGFloat yOffset = (NSHeight(overlayFrame) - oldOverlaySize_.height);
+ CGFloat xOffset = (NSWidth(overlayFrame) - oldOverlaySize_.width) / 2;
+
+ oldSheetFrame_.origin.x += NSMinX(overlayFrame) + xOffset;
+ oldSheetFrame_.origin.y += NSMinY(overlayFrame) + yOffset;
+ [sheetWindow setFrame:oldSheetFrame_ display:NO];
[[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_];
[[overlayWindow_ attachedSheet] setAlphaValue:1.0];
« no previous file with comments | « chrome/browser/ui/cocoa/certificate_viewer_mac.h ('k') | chrome/browser/ui/cocoa/certificate_viewer_mac_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698