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

Side by Side Diff: components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.mm

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert random change that was made accidentally? Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(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 #include "components/constrained_window/native_web_contents_modal_dialog_manager _views_mac.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "components/constrained_window/constrained_window_views.h"
10 #include "components/guest_view/browser/guest_view_base.h"
11 #include "components/web_modal/web_contents_modal_dialog_manager.h"
12 #include "content/public/browser/web_contents.h"
13 #import "ui/gfx/mac/coordinate_conversion.h"
14 #include "ui/views/widget/widget.h"
15 #include "ui/views/widget/widget_delegate.h"
16
17 using web_modal::WebContentsModalDialogManager;
18 using web_modal::SingleWebContentsDialogManager;
19
20 namespace constrained_window {
21
22 // NativeWebContentsModalDialogManagerViews:
23 void NativeWebContentsModalDialogManagerViewsMac::OnPositionRequiresUpdate() {
24 NativeWebContentsModalDialogManagerViews::OnPositionRequiresUpdate();
25
26 views::Widget* widget = GetWidget(dialog());
27 // Because the animation of SFCertificatePanel will change depending on the
28 // size of the parent, i.e. |widget|, make sure its size is the same as the
29 // area under the chrome UI. The origin of the dialog then also needs to be
msw 2016/08/22 23:01:19 nit: capitalize Chrome
Patti Lor 2016/08/25 08:25:12 Done.
30 // updated to position the certificate viewer in the middle horizontally.
31 content::WebContents* web_contents = native_delegate()->GetWebContents();
32 CGFloat window_width =
33 NSWidth([web_contents->GetTopLevelNativeWindow() frame]);
msw 2016/08/22 23:01:19 q: could this just use the web_contents->GetContai
Patti Lor 2016/08/25 08:25:12 The width of the WebContents isn't what we want si
msw 2016/08/25 15:30:47 Please add a short comment to that effect. (includ
Patti Lor 2016/08/26 07:38:29 Done.
34 gfx::Rect tab_view_size = web_contents->GetContainerBounds();
35 widget->SetBounds(gfx::Rect(tab_view_size.x(),
36 widget->GetWindowBoundsInScreen().y(),
37 window_width, tab_view_size.height()));
38 }
39
40 void NativeWebContentsModalDialogManagerViewsMac::ShowWidget(
41 views::Widget* widget) {
42 NSWindow* dialog_window = widget->GetNativeWindow();
43 // Detect whether this is the first call to open the dialog. If yes, do this
44 // via the normal views method. If not, overlay and sheet are both already
45 // opened, and should be invisible, so return the sheet to full opacity.
46 if (![dialog_window attachedSheet]) {
47 NativeWebContentsModalDialogManagerViews::ShowWidget(widget);
48 // Make sure the dialog is sized correctly for the correct animations.
49 OnPositionRequiresUpdate();
50 return;
51 }
52
53 // Account for window resizes that happen while another tab is open.
54 OnPositionRequiresUpdate();
55 [dialog_window setAlphaValue:0.0];
56 SetSheetVisible(dialog_window, true);
57 }
58
59 void NativeWebContentsModalDialogManagerViewsMac::HideWidget(
60 views::Widget* widget) {
61 NSWindow* dialog_window = widget->GetNativeWindow();
62 // Avoid views::Widget::Hide(), as a call to orderOut: on a NSWindow with an
63 // attached sheet will close the sheet. Instead, just set the sheet to 0
64 // opacity and don't accept click events.
65 SetSheetVisible(dialog_window, false);
66 }
67
68 // Sets visibility and mouse events for the overlay and its sheet.
69 void NativeWebContentsModalDialogManagerViewsMac::SetSheetVisible(
msw 2016/08/22 23:01:19 Could this just be a file-local anon-namespace hel
Patti Lor 2016/08/25 08:25:12 Done.
70 gfx::NativeWindow overlay,
71 bool visible) {
72 CGFloat alpha = visible ? 1.0 : 0.0;
73 BOOL ignore_events = visible ? NO : YES;
74
75 // Don't allow interaction with the tab underneath the overlay.
76 [overlay setIgnoresMouseEvents:ignore_events];
77
78 [[overlay attachedSheet] setAlphaValue:alpha];
79 [[overlay attachedSheet] setIgnoresMouseEvents:ignore_events];
80 }
81
82 } // namespace constrained_window
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698