Chromium Code Reviews| 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..adbdf213ff8d456fb97a8a44f8962d62d806587e |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm |
| @@ -0,0 +1,52 @@ |
| +// 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_views.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" |
| + |
| +// 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() {} |
| + |
| + // WidgetDelegate: |
| + ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate); |
| +}; |
| + |
| +@implementation SSLCertificateViewerViewsMac |
| + |
| +- (void)sheetDidEnd:(NSWindow*)parent |
| + returnCode:(NSInteger)returnCode |
| + context:(void*)context { |
| + [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
|
| + overlayWindow_->Close(); |
| +} |
| + |
| +- (void)displayForWebContents:(content::WebContents*)webContents { |
| + [super displayForWebContents:webContents]; |
| + |
| + views::WidgetDelegateView* delegate_ = new CertificateAnchorWidgetDelegate(); |
| + overlayWindow_.reset(constrained_window::ShowWebModalDialogWithOverlayViews( |
| + delegate_, webContents)); |
| + [self showSheetForWindow:overlayWindow_->GetNativeWindow()]; |
| +} |
| + |
| +@end |
| + |
| +void ShowCertificateViewer(content::WebContents* web_contents, |
| + gfx::NativeWindow parent, |
| + net::X509Certificate* cert) { |
| + 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
|
| + [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert]; |
| + [viewer displayForWebContents:web_contents]; |
| +} |