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

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

Issue 2562653002: Mac: Fix window ordering for certificate viewer/selector sheets and overlays.
Patch Set: Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/constrained_window/native_web_contents_modal_dialog_manager _views_mac.h" 5 #include "components/constrained_window/native_web_contents_modal_dialog_manager _views_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "components/constrained_window/constrained_window_views.h" 9 #include "components/constrained_window/constrained_window_views.h"
10 #include "components/guest_view/browser/guest_view_base.h" 10 #include "components/guest_view/browser/guest_view_base.h"
11 #include "components/web_modal/web_contents_modal_dialog_manager.h" 11 #include "components/web_modal/web_contents_modal_dialog_manager.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #import "ui/gfx/mac/coordinate_conversion.h" 13 #import "ui/gfx/mac/coordinate_conversion.h"
14 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
15 #include "ui/views/widget/widget_delegate.h" 15 #include "ui/views/widget/widget_delegate.h"
16 16
17 using web_modal::WebContentsModalDialogManager; 17 using web_modal::WebContentsModalDialogManager;
18 using web_modal::SingleWebContentsDialogManager; 18 using web_modal::SingleWebContentsDialogManager;
19 19
20 namespace { 20 namespace {
21 21
22 // Sets visibility and mouse events for a Cocoa NSWindow* and an attached sheet. 22 // Sets visibility and mouse events for a Cocoa NSWindow* and an attached sheet.
23 void SetSheetVisible(gfx::NativeWindow overlay, bool visible) { 23 void SetSheetVisible(gfx::NativeWindow overlay, bool visible) {
24 CGFloat alpha = visible ? 1.0 : 0.0;
25 BOOL ignore_events = visible ? NO : YES; 24 BOOL ignore_events = visible ? NO : YES;
26 25
27 // Don't allow interaction with the tab underneath the overlay. 26 // Don't allow interaction with the tab underneath the overlay.
28 [overlay setIgnoresMouseEvents:ignore_events]; 27 [overlay setIgnoresMouseEvents:ignore_events];
29 28
30 [[overlay attachedSheet] setAlphaValue:alpha]; 29 [[overlay attachedSheet] setAlphaValue:visible ? 1.0 : 0.0];
31 [[overlay attachedSheet] setIgnoresMouseEvents:ignore_events]; 30 [[overlay attachedSheet] setIgnoresMouseEvents:ignore_events];
31
32 // Make sure overlay layers for hidden Cocoa dialogs are always behind
33 // overlays which are in use. If they are not hidden, the attached sheet needs
34 // to be in front of its corresponding overlay window to accept mouse clicks.
35 [overlay setLevel:visible ? 1 : 0];
36 [[overlay attachedSheet] setLevel:visible ? 2 : 0];
32 } 37 }
33 38
34 } // namespace 39 } // namespace
35 40
36 namespace constrained_window { 41 namespace constrained_window {
37 42
38 NativeWebContentsModalDialogManagerViewsMac:: 43 NativeWebContentsModalDialogManagerViewsMac::
39 NativeWebContentsModalDialogManagerViewsMac( 44 NativeWebContentsModalDialogManagerViewsMac(
40 gfx::NativeWindow dialog, 45 gfx::NativeWindow dialog,
41 web_modal::SingleWebContentsDialogManagerDelegate* native_delegate) 46 web_modal::SingleWebContentsDialogManagerDelegate* native_delegate)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void NativeWebContentsModalDialogManagerViewsMac::HideWidget( 94 void NativeWebContentsModalDialogManagerViewsMac::HideWidget(
90 views::Widget* widget) { 95 views::Widget* widget) {
91 NSWindow* dialog_window = widget->GetNativeWindow(); 96 NSWindow* dialog_window = widget->GetNativeWindow();
92 // Avoid views::Widget::Hide(), as a call to orderOut: on a NSWindow with an 97 // Avoid views::Widget::Hide(), as a call to orderOut: on a NSWindow with an
93 // attached sheet will close the sheet. Instead, just set the sheet to 0 98 // attached sheet will close the sheet. Instead, just set the sheet to 0
94 // opacity and don't accept click events. 99 // opacity and don't accept click events.
95 SetSheetVisible(dialog_window, false); 100 SetSheetVisible(dialog_window, false);
96 } 101 }
97 102
98 } // namespace constrained_window 103 } // namespace constrained_window
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698