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

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

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore overlayWindow method for SSLCertificateViewerCocoa, fix test, other nits. Created 4 years, 7 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..ae1c1e370bdbae60ebcbc93ccf94d11caa0eff02 100644
--- a/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac.mm
@@ -4,77 +4,22 @@
#import "chrome/browser/ui/cocoa/certificate_viewer_mac.h"
-#include <Security/Security.h>
-#include <SecurityInterface/SFCertificatePanel.h>
-#include <vector>
-
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
-#include "chrome/browser/certificate_viewer.h"
-#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
-#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h"
-#import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h"
+#include "content/public/browser/web_contents.h"
#include "net/cert/x509_certificate.h"
#include "net/cert/x509_util_mac.h"
-#import "ui/base/cocoa/window_size_constants.h"
-
-class SSLCertificateViewerCocoaBridge;
-
-@interface SFCertificatePanel (SystemPrivate)
-// A system-private interface that dismisses a panel whose sheet was started by
-// -beginSheetForWindow:
-// modalDelegate:
-// didEndSelector:
-// contextInfo:
-// certificates:
-// showGroup:
-// as though the user clicked the button identified by returnCode. Verified
-// present in 10.8.
-- (void)_dismissWithCode:(NSInteger)code;
-@end
-
-@interface SSLCertificateViewerCocoa ()
-- (void)onConstrainedWindowClosed;
-@end
-
-class SSLCertificateViewerCocoaBridge : public ConstrainedWindowMacDelegate {
- public:
- explicit SSLCertificateViewerCocoaBridge(SSLCertificateViewerCocoa *
- controller)
- : controller_(controller) {
- }
-
- virtual ~SSLCertificateViewerCocoaBridge() {}
-
- // ConstrainedWindowMacDelegate implementation:
- void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override {
- // |onConstrainedWindowClosed| will delete the sheet which might be still
- // in use higher up the call stack. Wait for the next cycle of the event
- // loop to call this function.
- [controller_ performSelector:@selector(onConstrainedWindowClosed)
- withObject:nil
- afterDelay:0];
- }
- private:
- SSLCertificateViewerCocoa* controller_; // weak
-
- DISALLOW_COPY_AND_ASSIGN(SSLCertificateViewerCocoaBridge);
-};
-
-void ShowCertificateViewer(content::WebContents* web_contents,
- gfx::NativeWindow parent,
- net::X509Certificate* cert) {
- // SSLCertificateViewerCocoa will manage its own lifetime and will release
- // itself when the dialog is closed.
- // See -[SSLCertificateViewerCocoa onConstrainedWindowClosed].
- SSLCertificateViewerCocoa* viewer =
- [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert];
- [viewer displayForWebContents:web_contents];
+@implementation SSLCertificateViewerMac {
+ // The corresponding list of certificates.
+ base::scoped_nsobject<NSArray> certificates_;
+ base::scoped_nsobject<SFCertificatePanel> panel_;
+ BOOL closePending_;
+ BOOL oldResizesSubviews_;
tapted 2016/05/19 01:53:25 Can this move into certificate_viewer_mac_cocoa.mm
Patti Lor 2016/05/25 05:43:00 Done.
}
-@implementation SSLCertificateViewerCocoa
+@synthesize closePending = closePending_;
+@synthesize oldResizesSubviews = oldResizesSubviews_;
- (id)initWithCertificate:(net::X509Certificate*)certificate {
if ((self = [super init])) {
@@ -86,11 +31,8 @@ void ShowCertificateViewer(content::WebContents* web_contents,
return self;
}
-- (void)sheetDidEnd:(NSWindow*)parent
- returnCode:(NSInteger)returnCode
- context:(void*)context {
- if (!closePending_)
- constrainedWindow_->CloseWebContentsModalDialog();
+- (void)sheetDidEnd:(NSWindow*)parent {
tapted 2016/05/19 01:53:25 this should be the full prototype - (void)sheetDi
Patti Lor 2016/05/25 05:43:00 Done.
+ NOTREACHED(); // Subclasses must implement this.
}
- (void)displayForWebContents:(content::WebContents*)webContents {
@@ -133,17 +75,15 @@ void ShowCertificateViewer(content::WebContents* web_contents,
panel_.reset([[SFCertificatePanel alloc] init]);
[panel_ setPolicies:(id) policies.get()];
-
- constrainedWindow_ =
- CreateAndShowWebModalDialogMac(observer_.get(), webContents, self);
}
-- (NSWindow*)overlayWindow {
- return overlayWindow_;
+- (void)deleteSheetWindow {
+ panel_.reset();
}
+// ConstrainedWindowSheet protocol implementation.
+
- (void)showSheetForWindow:(NSWindow*)window {
tapted 2016/05/19 01:53:25 Rename this method to showCertificateSheet
Patti Lor 2016/05/25 05:43:00 This is a method declared in the ConstrainedWindow
- overlayWindow_.reset([window retain]);
[panel_ beginSheetForWindow:window
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:
@@ -156,25 +96,17 @@ void ShowCertificateViewer(content::WebContents* web_contents,
- (void)closeSheetWithAnimation:(BOOL)withAnimation {
tapted 2016/05/19 01:53:25 Rename this method to closeCertificateSheet
Patti Lor 2016/05/25 05:43:00 See comment on showSheetForWindow.
closePending_ = YES;
- overlayWindow_.reset();
// Closing the sheet using -[NSApp endSheet:] doesn't work so use the private
// method.
[panel_ _dismissWithCode:NSFileHandlingPanelCancelButton];
tapted 2016/05/19 01:53:25 try a panel_.reset() after this?
Patti Lor 2016/05/25 05:43:00 As discussed offline this doesn't work for the Coc
}
- (void)hideSheet {
- NSWindow* sheetWindow = [overlayWindow_ attachedSheet];
- [sheetWindow setAlphaValue:0.0];
-
- oldResizesSubviews_ = [[sheetWindow contentView] autoresizesSubviews];
- [[sheetWindow contentView] setAutoresizesSubviews:NO];
+ NOTREACHED(); // Subclasses must implement this.
}
- (void)unhideSheet {
- NSWindow* sheetWindow = [overlayWindow_ attachedSheet];
-
- [[sheetWindow contentView] setAutoresizesSubviews:oldResizesSubviews_];
- [[overlayWindow_ attachedSheet] setAlphaValue:1.0];
+ NOTREACHED(); // Subclasses must implement this.
}
- (void)pulseSheet {
@@ -182,7 +114,7 @@ void ShowCertificateViewer(content::WebContents* web_contents,
}
- (void)makeSheetKeyAndOrderFront {
- [[overlayWindow_ attachedSheet] makeKeyAndOrderFront:nil];
+ NOTREACHED(); // Subclasses must implement this.
}
- (void)updateSheetPosition {
@@ -197,10 +129,4 @@ void ShowCertificateViewer(content::WebContents* web_contents,
return panel_;
}
-- (void)onConstrainedWindowClosed {
- panel_.reset();
- constrainedWindow_.reset();
- [self release];
-}
-
@end

Powered by Google App Engine
This is Rietveld 408576698