OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
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_views.h" | |
6 | |
7 #include "chrome/browser/certificate_viewer.h" | |
8 #include "components/constrained_window/constrained_window_views.h" | |
9 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
10 #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!
| |
11 | |
12 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.
| |
13 | |
14 // A fully transparent, borderless web-modal dialog used to display the | |
15 // OS-provided window-modal sheet that displays certificate information. | |
16 class CertificateAnchorWidgetDelegate : public views::WidgetDelegateView { | |
17 public: | |
18 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.
| |
19 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.
| |
20 | |
21 private: | |
22 DISALLOW_COPY_AND_ASSIGN(CertificateAnchorWidgetDelegate); | |
23 }; | |
24 | |
25 @implementation SSLCertificateViewerViewsMac | |
26 | |
27 - (void)sheetDidEnd:(NSWindow*)parent | |
28 returnCode:(NSInteger)returnCode | |
29 context:(void*)context { | |
30 [self closeSheetWithAnimation:YES]; | |
31 dialog_->Close(); | |
32 } | |
33 | |
34 - (void)displayForWebContents:(content::WebContents*)webContents { | |
35 [super displayForWebContents:webContents]; | |
36 | |
37 delegate_ = new CertificateAnchorWidgetDelegate(webContents); | |
38 dialog_.reset(constrained_window::ShowWebModalDialogViews(delegate_, | |
39 webContents)); | |
40 | |
41 // Because the animation of SFCertificatePanel will change depending on the | |
42 // size of the parent, i.e. |dialog_|, make sure the dialog size is the same | |
43 // as the tab view size. The origin of the dialog then also needs to be | |
44 // updated to position the certificate viewer in the middle horizontally. | |
45 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.
| |
46 gfx::Rect tabViewSize = webContents->GetContainerBounds(); | |
47 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
| |
48 dialog_->GetWindowBoundsInScreen().y(), | |
49 windowWidth, tabViewSize.height())); | |
50 [self showSheetForWindow:dialog_->GetNativeWindow()]; | |
51 } | |
52 | |
53 @end | |
54 | |
55 void ShowCertificateViewer(content::WebContents* web_contents, | |
56 gfx::NativeWindow parent, | |
57 net::X509Certificate* cert) { | |
58 SSLCertificateViewerViewsMac* viewer = | |
59 [[SSLCertificateViewerViewsMac alloc] initWithCertificate:cert]; | |
60 [viewer displayForWebContents:web_contents]; | |
61 } | |
OLD | NEW |