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

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

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comment. 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_views.mm
diff --git a/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm b/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm
new file mode 100644
index 0000000000000000000000000000000000000000..2a21ffb2f1904a0916e57f69be53237cf38beebd
--- /dev/null
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm
@@ -0,0 +1,74 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/certificate_viewer_mac.h"
+
+#include <memory>
+
+#include "chrome/browser/certificate_viewer.h"
+#include "components/constrained_window/constrained_window_views.h"
+#include "components/web_modal/web_contents_modal_dialog_manager.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+
+// Certificate viewer class for MacViews which handles displaying and closing
+// the Cocoa certificate viewer.
+@interface SSLCertificateViewerMacViews : SSLCertificateViewerMac {
+ @private
+ views::Widget* overlayWindow_;
+}
+
+// Closes the certificate viewer properly.
+- (void)sheetDidEnd:(NSWindow*)parent
tapted 2016/05/25 06:52:24 doesn't need to be redeclared
Patti Lor 2016/05/31 06:00:33 Done.
+ returnCode:(NSInteger)returnCode
+ context:(void*)context;
+
+@end
+
+// A fully transparent, borderless web-modal dialog used to display the
+// OS-provided window-modal sheet that displays certificate information.
+class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView {
+ public:
+ CertificateAnchorWidgetDelegate(
tapted 2016/05/25 06:52:24 nit: explicit.. but! The ownership is still a litt
Patti Lor 2016/05/31 06:00:33 Done.
+ SSLCertificateViewerMacViews* certificate_viewer)
+ : certificate_viewer_(certificate_viewer) {}
+
+ // WidgetDelegate:
+ ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
+
+ private:
+ base::scoped_nsobject<SSLCertificateViewerMacViews> certificate_viewer_;
+
+ DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate);
+};
+
+@implementation SSLCertificateViewerMacViews
+
+- (void)sheetDidEnd:(NSWindow*)parent
+ returnCode:(NSInteger)returnCode
+ context:(void*)context {
+ [self closeSheetWithAnimation:YES];
+ overlayWindow_->Close(); // Asynchronously releases |self|.
+ [self releaseSheetWindow];
+}
+
+- (void)displayForWebContents:(content::WebContents*)webContents {
+ [super displayForWebContents:webContents];
+
+ views::WidgetDelegateView* delegate_ =
+ new CertificateAnchorWidgetDelegate(self);
+ overlayWindow_ = constrained_window::ShowWebModalDialogWithOverlayViews(
+ delegate_, webContents);
+ [self showSheetForWindow:overlayWindow_->GetNativeWindow()];
+}
+
+@end
+
+void ShowCertificateViewer(content::WebContents* web_contents,
+ gfx::NativeWindow parent,
+ net::X509Certificate* cert) {
+ SSLCertificateViewerMacViews* viewer =
+ [[SSLCertificateViewerMacViews alloc] initWithCertificate:cert];
+ [viewer displayForWebContents:web_contents];
+}

Powered by Google App Engine
This is Rietveld 408576698