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

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: Fix positioning after resize from top, don't allow interaction with tab WebContents while certifica… Created 4 years, 8 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..5a86206df9f28dddbb4ee8244afd4139d36c3c8b
--- /dev/null
+++ b/chrome/browser/ui/cocoa/certificate_viewer_mac_views.mm
@@ -0,0 +1,61 @@
+// 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_delegate.cc"
tapted 2016/05/04 03:29:24 .cc ? :)
Patti Lor 2016/05/11 01:35:18 Done - oops!
+
+using namespace web_modal;
tapted 2016/05/04 03:29:24 remove? it's uncommon to use `using namespace` exc
Patti Lor 2016/05/11 01:35:18 Done.
+
+// 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(content::WebContents* webContents) {}
tapted 2016/05/04 03:29:24 the |webContents| argument can be removed
Patti Lor 2016/05/11 01:35:18 Done.
+ ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_CHILD; }
tapted 2016/05/04 03:29:25 nit: // WidgetDelegate:
Patti Lor 2016/05/11 01:35:18 Done.
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate);
+};
+
+@implementation SSLCertificateViewerViewsMac
+
+- (void)sheetDidEnd:(NSWindow*)parent
+ returnCode:(NSInteger)returnCode
+ context:(void*)context {
+ [self closeSheetWithAnimation:YES];
+ dialog_->Close();
+}
+
+- (void)displayForWebContents:(content::WebContents*)webContents {
+ [super displayForWebContents:webContents];
+
+ delegate_ = new CertificateAnchorWidgetDelegate(webContents);
+ dialog_.reset(constrained_window::ShowWebModalDialogViews(delegate_,
+ webContents));
+
+ // Because the animation of SFCertificatePanel will change depending on the
+ // size of the parent, i.e. |dialog_|, make sure the dialog size is the same
+ // as the tab view size. The origin of the dialog then also needs to be
+ // updated to position the certificate viewer in the middle horizontally.
+ int windowWidth = [webContents->GetTopLevelNativeWindow() frame].size.width;
tapted 2016/05/04 03:29:24 nit GGFloat windowWidth = NSWidth([webContents->G
Patti Lor 2016/05/11 01:35:18 Done.
+ gfx::Rect tabViewSize = webContents->GetContainerBounds();
+ dialog_->SetBounds(gfx::Rect(tabViewSize.x(),
tapted 2016/05/04 03:29:24 is OnPositionRequiresUpdate() called during constr
Patti Lor 2016/05/11 01:35:18 Done - it isn't, but have added a call to it after
+ dialog_->GetWindowBoundsInScreen().y(),
+ windowWidth, tabViewSize.height()));
+ [self showSheetForWindow:dialog_->GetNativeWindow()];
+}
+
+@end
+
+void ShowCertificateViewer(content::WebContents* web_contents,
+ gfx::NativeWindow parent,
+ net::X509Certificate* cert) {
+ SSLCertificateViewerViewsMac* viewer =
+ [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert];
+ [viewer displayForWebContents:web_contents];
+}

Powered by Google App Engine
This is Rietveld 408576698