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

Unified Diff: chrome/browser/ui/cocoa/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: Restore overlayWindow method for SSLCertificateViewerCocoa, fix test, other nits. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm
diff --git a/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm b/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm
new file mode 100644
index 0000000000000000000000000000000000000000..adbdf213ff8d456fb97a8a44f8962d62d806587e
--- /dev/null
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm
@@ -0,0 +1,52 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/certificate_viewer_mac_views.h"
+
+#include "chrome/browser/certificate_viewer.h"
+#include "components/constrained_window/constrained_window_views.h"
+#include "components/web_modal/web_contents_modal_dialog_manager.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+
+// A fully transparent, borderless web-modal dialog used to display the
+// OS-provided window-modal sheet that displays certificate information.
+class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView {
+ public:
+ CertificateAnchorWidgetDelegate() {}
+
+ // WidgetDelegate:
+ ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate);
+};
+
+@implementation SSLCertificateViewerViewsMac
+
+- (void)sheetDidEnd:(NSWindow*)parent
+ returnCode:(NSInteger)returnCode
+ context:(void*)context {
+ [self closeSheetWithAnimation:YES];
tapted 2016/05/19 01:53:25 Does this need to check [self closePending] and re
Patti Lor 2016/05/25 05:43:00 Done, have moved closePending to the Cocoa version
+ overlayWindow_->Close();
+}
+
+- (void)displayForWebContents:(content::WebContents*)webContents {
+ [super displayForWebContents:webContents];
+
+ views::WidgetDelegateView* delegate_ = new CertificateAnchorWidgetDelegate();
+ overlayWindow_.reset(constrained_window::ShowWebModalDialogWithOverlayViews(
+ delegate_, webContents));
+ [self showSheetForWindow:overlayWindow_->GetNativeWindow()];
+}
+
+@end
+
+void ShowCertificateViewer(content::WebContents* web_contents,
+ gfx::NativeWindow parent,
+ net::X509Certificate* cert) {
+ SSLCertificateViewerViewsMac* viewer =
tapted 2016/05/19 01:53:25 So I think this allocation is currently leaked. Ei
Patti Lor 2016/05/25 05:43:00 Done, have taken the second approach you suggested
+ [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert];
+ [viewer displayForWebContents:web_contents];
+}

Powered by Google App Engine
This is Rietveld 408576698