Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Side by Side Diff: chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert random change that was made accidentally? Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 @private
18 // Invisible overlay window used to block interaction with the tab underneath.
19 views::Widget* overlayWindow_;
20 }
21
22 - (void)setOverlayWindow:(views::Widget*)overlayWindow;
23 @end
24
25 // A fully transparent, borderless web-modal dialog used to display the
26 // OS-provided window-modal sheet that displays certificate information.
27 class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView {
28 public:
29 CertificateAnchorWidgetDelegate(content::WebContents* web_contents,
30 net::X509Certificate* cert)
31 : certificate_viewer_(
32 [[SSLCertificateViewerMacViews alloc] initWithCertificate:cert]) {
33 [certificate_viewer_ displayForWebContents:web_contents];
34 views::Widget* overlayWindow =
35 constrained_window::ShowWebModalDialogWithOverlayViews(this,
36 web_contents);
37 [certificate_viewer_ showCertificateSheet:overlayWindow->GetNativeWindow()];
38 [certificate_viewer_ setOverlayWindow:overlayWindow];
39 }
40
41 // WidgetDelegate:
42 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
43
44 private:
45 base::scoped_nsobject<SSLCertificateViewerMacViews> certificate_viewer_;
46
47 DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate);
48 };
49
50 @implementation SSLCertificateViewerMacViews
51
52 - (void)sheetDidEnd:(NSWindow*)parent
53 returnCode:(NSInteger)returnCode
54 context:(void*)context {
55 [self closeCertificateSheet];
56 overlayWindow_->Close(); // Asynchronously releases |self|.
57 [self releaseSheetWindow];
58 }
59
60 - (void)setOverlayWindow:(views::Widget*)overlayWindow {
61 overlayWindow_ = overlayWindow;
62 }
63
64 @end
65
66 void ShowCertificateViewer(content::WebContents* web_contents,
67 gfx::NativeWindow parent,
68 net::X509Certificate* cert) {
69 // Shows a new widget, which owns the delegate.
70 new CertificateAnchorWidgetDelegate(web_contents, cert);
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698