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_views.h" | |
| 6 | |
| 7 #include "chrome/browser/certificate_viewer.h" | |
| 8 #include "components/constrained_window/constrained_window_views.h" | |
| 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
| 10 #include "ui/views/widget/widget.h" | |
| 11 #include "ui/views/widget/widget_delegate.h" | |
| 12 | |
| 13 // A fully transparent, borderless web-modal dialog used to display the | |
| 14 // OS-provided window-modal sheet that displays certificate information. | |
| 15 class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView { | |
| 16 public: | |
| 17 CertificateAnchorWidgetDelegate() {} | |
| 18 | |
| 19 // WidgetDelegate: | |
| 20 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; } | |
| 21 | |
| 22 private: | |
| 23 DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate); | |
| 24 }; | |
| 25 | |
| 26 @implementation SSLCertificateViewerViewsMac | |
| 27 | |
| 28 - (void)sheetDidEnd:(NSWindow*)parent | |
| 29 returnCode:(NSInteger)returnCode | |
| 30 context:(void*)context { | |
| 31 [self closeSheetWithAnimation:YES]; | |
|
tapted
2016/05/19 01:53:25
Does this need to check [self closePending] and re
Patti Lor
2016/05/25 05:43:00
Done, have moved closePending to the Cocoa version
| |
| 32 overlayWindow_->Close(); | |
| 33 } | |
| 34 | |
| 35 - (void)displayForWebContents:(content::WebContents*)webContents { | |
| 36 [super displayForWebContents:webContents]; | |
| 37 | |
| 38 views::WidgetDelegateView* delegate_ = new CertificateAnchorWidgetDelegate(); | |
| 39 overlayWindow_.reset(constrained_window::ShowWebModalDialogWithOverlayViews( | |
| 40 delegate_, webContents)); | |
| 41 [self showSheetForWindow:overlayWindow_->GetNativeWindow()]; | |
| 42 } | |
| 43 | |
| 44 @end | |
| 45 | |
| 46 void ShowCertificateViewer(content::WebContents* web_contents, | |
| 47 gfx::NativeWindow parent, | |
| 48 net::X509Certificate* cert) { | |
| 49 SSLCertificateViewerViewsMac* viewer = | |
|
tapted
2016/05/19 01:53:25
So I think this allocation is currently leaked. Ei
Patti Lor
2016/05/25 05:43:00
Done, have taken the second approach you suggested
| |
| 50 [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert]; | |
| 51 [viewer displayForWebContents:web_contents]; | |
| 52 } | |
| OLD | NEW |