OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
tapted
2016/03/21 02:47:13
nit: no (c)
Patti Lor
2016/05/03 00:05:01
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/views/mac/certificate_viewer_views_mac.h" | |
6 | |
7 #include "chrome/browser/certificate_viewer.h" | |
8 #import "chrome/browser/ui/views/mac/web_contents_modal_dialog_manager_views_mac .h" | |
9 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
10 | |
11 | |
tapted
2016/03/21 02:47:13
no blank line
Patti Lor
2016/05/03 00:05:00
Done.
| |
12 using namespace web_modal; | |
13 | |
14 @implementation SSLCertificateViewerViewsMac | |
15 | |
16 - (void)displayForWebContents:(content::WebContents*)webContents { | |
17 [super displayForWebContents:webContents]; | |
18 | |
19 constrainedWindow_.reset( | |
20 new SingleWebContentsDialogManagerViewsMac(self, webContents)); | |
tapted
2016/03/21 02:47:13
SingleWebContentsDialogManagerViewsMac isn't the r
Patti Lor
2016/05/03 00:05:01
Done - switched to using the dialog created by the
| |
21 | |
22 [[NSNotificationCenter defaultCenter] | |
tapted
2016/03/21 02:47:13
Hopefully these bits won't be needed -- calling co
Patti Lor
2016/05/03 00:05:01
Done.
| |
23 addObserver:self | |
24 selector:@selector(onParentWindowSizeDidChange:) | |
25 name:NSWindowDidResizeNotification | |
26 object:overlayWindow_]; | |
27 [webContents->GetNativeView() | |
28 addObserver:self | |
29 forKeyPath:NSStringFromSelector(@selector(hidden)) | |
30 options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) | |
31 context:nullptr]; | |
32 | |
33 constrainedWindow_->Show(); | |
34 webContents_ = webContents; | |
35 } | |
36 | |
37 - (void)observeValueForKeyPath:(NSString*)keyPath | |
38 ofObject:(id)object | |
39 change:(NSDictionary*)change | |
40 context:(void*)context { | |
41 if (![keyPath isEqualToString:NSStringFromSelector(@selector(hidden))]) | |
42 return; | |
43 | |
44 bool oldValue = [[change objectForKey:NSKeyValueChangeOldKey] intValue]; | |
45 bool newValue = [[change objectForKey:NSKeyValueChangeNewKey] intValue]; | |
46 if (oldValue != newValue) { | |
47 if (newValue) | |
48 constrainedWindow_->Hide(); | |
49 else | |
50 constrainedWindow_->Unhide(); | |
51 } | |
52 } | |
53 | |
54 - (void)onParentWindowSizeDidChange:(NSNotification*)notification { | |
55 constrainedWindow_->UpdateSheetPosition(); | |
56 } | |
57 | |
58 - (void)sheetDidEnd:(NSWindow*)parent | |
59 returnCode:(NSInteger)returnCode | |
60 context:(void*)context { | |
61 [[NSNotificationCenter defaultCenter] | |
62 removeObserver:self | |
63 name:NSWindowDidResizeNotification | |
64 object:overlayWindow_]; | |
65 [webContents_->GetNativeView() | |
66 removeObserver:self | |
67 forKeyPath:NSStringFromSelector(@selector(hidden))]; | |
68 webContents_ = nullptr; | |
69 | |
70 if (!closePending_) | |
71 constrainedWindow_->Close(); | |
72 } | |
73 | |
74 @end | |
75 | |
76 void ShowCertificateViewer(content::WebContents* web_contents, | |
77 gfx::NativeWindow parent, | |
78 net::X509Certificate* cert) { | |
79 SSLCertificateViewerViewsMac* viewer = | |
80 [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert]; | |
81 [viewer displayForWebContents:web_contents]; | |
82 } | |
OLD | NEW |