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

Side by Side Diff: chrome/browser/ui/views/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: msw@ & rsesek@ review, move sheetDidEnd::: into separate SSLCertificateViewerMac declaration. Created 4 years, 3 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
« no previous file with comments | « chrome/browser/ui/cocoa/certificate_viewer_mac_cocoa.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 // Invisible overlay window used to block interaction with the tab underneath.
18 views::Widget* overlayWindow_;
19 }
20
21 - (void)setOverlayWindow:(views::Widget*)overlayWindow;
22 @end
23
24 // A fully transparent, borderless web-modal dialog used to display the
25 // OS-provided window-modal sheet that displays certificate information.
26 class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView {
27 public:
28 CertificateAnchorWidgetDelegate(content::WebContents* web_contents,
29 net::X509Certificate* cert)
30 : certificate_viewer_([[SSLCertificateViewerMacViews alloc]
31 initWithCertificate:cert
32 forWebContents:web_contents]) {
33 views::Widget* overlayWindow =
34 constrained_window::ShowWebModalDialogWithOverlayViews(this,
35 web_contents);
36 [certificate_viewer_ showCertificateSheet:overlayWindow->GetNativeWindow()];
37 [certificate_viewer_ setOverlayWindow:overlayWindow];
38 }
39
40 // WidgetDelegate:
41 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
42
43 private:
44 base::scoped_nsobject<SSLCertificateViewerMacViews> certificate_viewer_;
45
46 DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate);
47 };
48
49 @implementation SSLCertificateViewerMacViews
50
51 - (void)sheetDidEnd:(NSWindow*)parent
52 returnCode:(NSInteger)returnCode
53 context:(void*)context {
54 [self closeCertificateSheet];
55 overlayWindow_->Close(); // Asynchronously releases |self|.
56 [self releaseSheetWindow];
57 }
58
59 - (void)setOverlayWindow:(views::Widget*)overlayWindow {
60 overlayWindow_ = overlayWindow;
61 }
62
63 @end
64
65 void ShowCertificateViewer(content::WebContents* web_contents,
66 gfx::NativeWindow parent,
67 net::X509Certificate* cert) {
68 // Shows a new widget, which owns the delegate.
69 new CertificateAnchorWidgetDelegate(web_contents, cert);
70 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/certificate_viewer_mac_cocoa.mm ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698