Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/certificate_viewer_mac.h" | |
| 6 | |
| 7 #import "base/mac/scoped_nsobject.h" | |
| 8 #include "chrome/browser/certificate_viewer.h" | |
| 9 #include "components/constrained_window/constrained_window_views.h" | |
| 10 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
| 11 #include "ui/views/widget/widget.h" | |
| 12 #include "ui/views/widget/widget_delegate.h" | |
| 13 | |
| 14 // Certificate viewer class for MacViews which handles displaying and closing | |
| 15 // the Cocoa certificate viewer. | |
| 16 @interface SSLCertificateViewerMacViews : SSLCertificateViewerMac | |
| 17 | |
|
tapted
2016/05/31 07:44:48
nit: remove vertical whitespace
Patti Lor
2016/06/06 06:52:46
Done.
| |
| 18 - (void)setOverlayWindow:(views::Widget*)overlay; | |
|
tapted
2016/05/31 07:44:48
nit: overlay -> overlayWindow
Patti Lor
2016/06/06 06:52:46
Done.
| |
| 19 | |
| 20 @end | |
| 21 | |
| 22 // A fully transparent, borderless web-modal dialog used to display the | |
| 23 // OS-provided window-modal sheet that displays certificate information. | |
| 24 class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView { | |
| 25 public: | |
| 26 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.
| |
| 27 net::X509Certificate* cert) | |
| 28 : certificate_viewer_( | |
| 29 [[SSLCertificateViewerMacViews alloc] initWithCertificate:cert]) { | |
| 30 [certificate_viewer_ displayForWebContents:web_contents]; | |
| 31 views::Widget* overlayWindow = | |
| 32 constrained_window::ShowWebModalDialogWithOverlayViews(this, | |
| 33 web_contents); | |
| 34 [certificate_viewer_ showCertificateSheet:overlayWindow->GetNativeWindow()]; | |
| 35 [certificate_viewer_ setOverlayWindow:overlayWindow]; | |
| 36 } | |
| 37 | |
| 38 // WidgetDelegate: | |
| 39 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; } | |
| 40 | |
| 41 private: | |
| 42 base::scoped_nsobject<SSLCertificateViewerMacViews> certificate_viewer_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate); | |
| 45 }; | |
| 46 | |
| 47 @implementation SSLCertificateViewerMacViews { | |
| 48 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.
| |
| 49 } | |
| 50 | |
| 51 - (void)sheetDidEnd:(NSWindow*)parent | |
| 52 returnCode:(NSInteger)returnCode | |
| 53 context:(void*)context { | |
| 54 [self closeCertificateSheet:YES]; | |
| 55 overlayWindow_->Close(); // Asynchronously releases |self|. | |
| 56 [self releaseSheetWindow]; | |
| 57 } | |
| 58 | |
| 59 - (void)setOverlayWindow:(views::Widget*)overlay { | |
| 60 overlayWindow_ = overlay; | |
| 61 } | |
| 62 | |
| 63 @end | |
| 64 | |
| 65 void ShowCertificateViewer(content::WebContents* web_contents, | |
| 66 gfx::NativeWindow parent, | |
| 67 net::X509Certificate* cert) { | |
| 68 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.
| |
| 69 } | |
| OLD | NEW |