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

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

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix positioning after resize from top, don't allow interaction with tab WebContents while certifica… Created 4 years, 7 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 (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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698