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..e33117769782d69cdd9d60eb23088a932f835830 |
--- /dev/null |
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm |
@@ -0,0 +1,69 @@ |
+// 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" |
+ |
+#import "base/mac/scoped_nsobject.h" |
+#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 |
+ |
tapted
2016/05/31 07:44:48
nit: remove vertical whitespace
Patti Lor
2016/06/06 06:52:46
Done.
|
+- (void)setOverlayWindow:(views::Widget*)overlay; |
tapted
2016/05/31 07:44:48
nit: overlay -> overlayWindow
Patti Lor
2016/06/06 06:52:46
Done.
|
+ |
+@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: |
+ explicit CertificateAnchorWidgetDelegate(content::WebContents* web_contents, |
tapted
2016/05/31 07:44:48
nit: explicit no longer needed
Patti Lor
2016/06/06 06:52:46
Done.
|
+ net::X509Certificate* cert) |
+ : certificate_viewer_( |
+ [[SSLCertificateViewerMacViews alloc] initWithCertificate:cert]) { |
+ [certificate_viewer_ displayForWebContents:web_contents]; |
+ views::Widget* overlayWindow = |
+ constrained_window::ShowWebModalDialogWithOverlayViews(this, |
+ web_contents); |
+ [certificate_viewer_ showCertificateSheet:overlayWindow->GetNativeWindow()]; |
+ [certificate_viewer_ setOverlayWindow:overlayWindow]; |
+ } |
+ |
+ // 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 { |
+ views::Widget* overlayWindow_; |
tapted
2016/05/31 07:44:48
since the interface is only in the .mm file, it's
Patti Lor
2016/06/06 06:52:46
Done.
|
+} |
+ |
+- (void)sheetDidEnd:(NSWindow*)parent |
+ returnCode:(NSInteger)returnCode |
+ context:(void*)context { |
+ [self closeCertificateSheet:YES]; |
+ overlayWindow_->Close(); // Asynchronously releases |self|. |
+ [self releaseSheetWindow]; |
+} |
+ |
+- (void)setOverlayWindow:(views::Widget*)overlay { |
+ overlayWindow_ = overlay; |
+} |
+ |
+@end |
+ |
+void ShowCertificateViewer(content::WebContents* web_contents, |
+ gfx::NativeWindow parent, |
+ net::X509Certificate* cert) { |
+ new CertificateAnchorWidgetDelegate(web_contents, cert); |
tapted
2016/05/31 07:44:48
ownership comment here, like
// Shows a new Widge
Patti Lor
2016/06/06 06:52:46
Done.
|
+} |