OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
tapted
2016/05/04 03:29:24
(c) 2012 -> 2016? Otherwise, can you play with `gi
Patti Lor
2016/05/11 01:35:18
Done.
| |
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_cocoa.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/mac/foundation_util.h" | |
tapted
2016/05/04 03:29:24
nit: import
Patti Lor
2016/05/11 01:35:18
Done.
| |
9 #include "chrome/browser/certificate_viewer.h" | |
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet.h" | |
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" | |
12 | |
13 class SSLCertificateViewerCocoaBridge : public ConstrainedWindowMacDelegate { | |
14 public: | |
15 explicit SSLCertificateViewerCocoaBridge(SSLCertificateViewerCocoa * | |
tapted
2016/05/04 03:29:24
no space between SSLCertificateViewerCocoa and "*"
Patti Lor
2016/05/11 01:35:18
Done.
| |
16 controller) | |
17 : controller_(controller) { | |
18 } | |
19 | |
20 virtual ~SSLCertificateViewerCocoaBridge() {} | |
21 | |
22 // ConstrainedWindowMacDelegate implementation: | |
23 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { | |
24 // |onConstrainedWindowClosed| will delete the sheet which might be still | |
tapted
2016/05/04 03:29:24
nit: still -> still be
Patti Lor
2016/05/11 01:35:18
Done.
| |
25 // in use higher up the call stack. Wait for the next cycle of the event | |
26 // loop to call this function. | |
27 [controller_ performSelector:@selector(onConstrainedWindowClosed) | |
28 withObject:nil | |
29 afterDelay:0]; | |
30 } | |
31 | |
32 private: | |
33 SSLCertificateViewerCocoa* controller_; // weak | |
tapted
2016/05/04 03:29:24
nit: // Weak. Owns this.
Patti Lor
2016/05/11 01:35:18
Done.
| |
34 | |
35 DISALLOW_COPY_AND_ASSIGN(SSLCertificateViewerCocoaBridge); | |
36 }; | |
37 | |
38 @implementation SSLCertificateViewerCocoa | |
39 | |
40 - (void)sheetDidEnd:(NSWindow*)parent | |
41 returnCode:(NSInteger)returnCode | |
42 context:(void*)context { | |
43 if (!closePending_) | |
44 constrainedWindow_->CloseWebContentsModalDialog(); | |
45 } | |
46 | |
47 - (void)displayForWebContents:(content::WebContents*)webContents { | |
48 [super displayForWebContents:webContents]; | |
49 | |
50 constrainedWindow_ = | |
51 CreateAndShowWebModalDialogMac(observer_.get(), webContents, self); | |
52 } | |
53 | |
54 - (void)onConstrainedWindowClosed { | |
55 panel_.reset(); | |
56 constrainedWindow_.reset(); | |
57 [self release]; | |
58 } | |
59 | |
60 @end | |
61 | |
62 void ShowCertificateViewer(content::WebContents* web_contents, | |
63 gfx::NativeWindow parent, | |
64 net::X509Certificate* cert) { | |
65 // SSLCertificateViewerCocoa will manage its own lifetime and will release | |
66 // itself when the dialog is closed. | |
67 // See -[SSLCertificateViewerCocoa onConstrainedWindowClosed]. | |
68 SSLCertificateViewerCocoa* viewer = | |
69 [[SSLCertificateViewerCocoa alloc] initWithCertificate:cert]; | |
70 [viewer displayForWebContents:web_contents]; | |
71 } | |
OLD | NEW |