| 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..c6a1e390aa906ae968b145b134ea6b90cb5c3b9a
|
| --- /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];
|
| + overlayWindow_->Close();
|
| +}
|
| +
|
| +- (void)displayForWebContents:(content::WebContents*)webContents {
|
| + [super displayForWebContents:webContents];
|
| +
|
| + views::WidgetDelegateView* delegate_ = new CertificateAnchorWidgetDelegate();
|
| + overlayWindow_.reset(constrained_window::ShowParentedWebModalDialogViews(
|
| + delegate_, webContents));
|
| + [self showSheetForWindow:overlayWindow_->GetNativeWindow()];
|
| +}
|
| +
|
| +@end
|
| +
|
| +void ShowCertificateViewer(content::WebContents* web_contents,
|
| + gfx::NativeWindow parent,
|
| + net::X509Certificate* cert) {
|
| + SSLCertificateViewerViewsMac* viewer =
|
| + [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert];
|
| + [viewer displayForWebContents:web_contents];
|
| +}
|
|
|