Chromium Code Reviews| Index: chrome/browser/ui/views/mac/certificate_viewer_views_mac.mm |
| diff --git a/chrome/browser/ui/views/mac/certificate_viewer_views_mac.mm b/chrome/browser/ui/views/mac/certificate_viewer_views_mac.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3d3237a962339ce178497a08412ded4592deab3e |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/mac/certificate_viewer_views_mac.mm |
| @@ -0,0 +1,82 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/views/mac/certificate_viewer_views_mac.h" |
| + |
| +#include "chrome/browser/certificate_viewer.h" |
| +#import "chrome/browser/ui/views/mac/web_contents_modal_dialog_manager_views_mac.h" |
| +#include "components/web_modal/web_contents_modal_dialog_manager.h" |
| + |
| + |
|
tapted
2016/03/21 02:47:13
no blank line
Patti Lor
2016/05/03 00:05:00
Done.
|
| +using namespace web_modal; |
| + |
| +@implementation SSLCertificateViewerViewsMac |
| + |
| +- (void)displayForWebContents:(content::WebContents*)webContents { |
| + [super displayForWebContents:webContents]; |
| + |
| + constrainedWindow_.reset( |
| + 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
|
| + |
| + [[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.
|
| + addObserver:self |
| + selector:@selector(onParentWindowSizeDidChange:) |
| + name:NSWindowDidResizeNotification |
| + object:overlayWindow_]; |
| + [webContents->GetNativeView() |
| + addObserver:self |
| + forKeyPath:NSStringFromSelector(@selector(hidden)) |
| + options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) |
| + context:nullptr]; |
| + |
| + constrainedWindow_->Show(); |
| + webContents_ = webContents; |
| +} |
| + |
| +- (void)observeValueForKeyPath:(NSString*)keyPath |
| + ofObject:(id)object |
| + change:(NSDictionary*)change |
| + context:(void*)context { |
| + if (![keyPath isEqualToString:NSStringFromSelector(@selector(hidden))]) |
| + return; |
| + |
| + bool oldValue = [[change objectForKey:NSKeyValueChangeOldKey] intValue]; |
| + bool newValue = [[change objectForKey:NSKeyValueChangeNewKey] intValue]; |
| + if (oldValue != newValue) { |
| + if (newValue) |
| + constrainedWindow_->Hide(); |
| + else |
| + constrainedWindow_->Unhide(); |
| + } |
| +} |
| + |
| +- (void)onParentWindowSizeDidChange:(NSNotification*)notification { |
| + constrainedWindow_->UpdateSheetPosition(); |
| +} |
| + |
| +- (void)sheetDidEnd:(NSWindow*)parent |
| + returnCode:(NSInteger)returnCode |
| + context:(void*)context { |
| + [[NSNotificationCenter defaultCenter] |
| + removeObserver:self |
| + name:NSWindowDidResizeNotification |
| + object:overlayWindow_]; |
| + [webContents_->GetNativeView() |
| + removeObserver:self |
| + forKeyPath:NSStringFromSelector(@selector(hidden))]; |
| + webContents_ = nullptr; |
| + |
| + if (!closePending_) |
| + constrainedWindow_->Close(); |
| +} |
| + |
| +@end |
| + |
| +void ShowCertificateViewer(content::WebContents* web_contents, |
| + gfx::NativeWindow parent, |
| + net::X509Certificate* cert) { |
| + SSLCertificateViewerViewsMac* viewer = |
| + [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert]; |
| + [viewer displayForWebContents:web_contents]; |
| +} |