OLD | NEW |
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 "chrome/browser/ui/views/native_web_contents_modal_dialog_manager_views
.h" | 5 #include "chrome/browser/ui/views/native_web_contents_modal_dialog_manager_views
.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "chrome/browser/platform_util.h" | 9 #include "chrome/browser/platform_util.h" |
10 #include "components/constrained_window/constrained_window_views.h" | 10 #include "components/constrained_window/constrained_window_views.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return; | 90 return; |
91 | 91 |
92 views::Widget* widget = GetWidget(dialog()); | 92 views::Widget* widget = GetWidget(dialog()); |
93 #if defined(USE_AURA) | 93 #if defined(USE_AURA) |
94 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend; | 94 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend; |
95 if (shown_widgets_.find(widget) != shown_widgets_.end()) { | 95 if (shown_widgets_.find(widget) != shown_widgets_.end()) { |
96 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations( | 96 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations( |
97 widget->GetNativeWindow()->parent())); | 97 widget->GetNativeWindow()->parent())); |
98 } | 98 } |
99 #endif | 99 #endif |
100 // Host may be NULL during tab drag on Views/Win32. | 100 ShowWidget(widget); |
101 if (host_) | |
102 constrained_window::UpdateWebContentsModalDialogPosition(widget, host_); | |
103 widget->Show(); | |
104 Focus(); | 101 Focus(); |
105 | 102 |
106 #if defined(USE_AURA) | 103 #if defined(USE_AURA) |
107 // TODO(pkotwicz): Control the z-order of the constrained dialog via | 104 // TODO(pkotwicz): Control the z-order of the constrained dialog via |
108 // views::kHostViewKey. We will need to ensure that the parent window's | 105 // views::kHostViewKey. We will need to ensure that the parent window's |
109 // shadows are below the constrained dialog in z-order when we do this. | 106 // shadows are below the constrained dialog in z-order when we do this. |
110 shown_widgets_.insert(widget); | 107 shown_widgets_.insert(widget); |
111 #endif | 108 #endif |
112 } | 109 } |
113 | 110 |
114 void NativeWebContentsModalDialogManagerViews::Hide() { | 111 void NativeWebContentsModalDialogManagerViews::Hide() { |
115 views::Widget* widget = GetWidget(dialog()); | 112 views::Widget* widget = GetWidget(dialog()); |
116 #if defined(USE_AURA) | 113 #if defined(USE_AURA) |
117 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend; | 114 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend; |
118 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations( | 115 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations( |
119 widget->GetNativeWindow()->parent())); | 116 widget->GetNativeWindow()->parent())); |
120 #endif | 117 #endif |
121 widget->Hide(); | 118 HideWidget(widget); |
122 } | 119 } |
123 | 120 |
124 void NativeWebContentsModalDialogManagerViews::Close() { | 121 void NativeWebContentsModalDialogManagerViews::Close() { |
125 GetWidget(dialog())->Close(); | 122 GetWidget(dialog())->Close(); |
126 } | 123 } |
127 | 124 |
128 void NativeWebContentsModalDialogManagerViews::Focus() { | 125 void NativeWebContentsModalDialogManagerViews::Focus() { |
129 views::Widget* widget = GetWidget(dialog()); | 126 views::Widget* widget = GetWidget(dialog()); |
130 if (widget->widget_delegate() && | 127 if (widget->widget_delegate() && |
131 widget->widget_delegate()->GetInitiallyFocusedView()) | 128 widget->widget_delegate()->GetInitiallyFocusedView()) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 183 } |
187 | 184 |
188 OnPositionRequiresUpdate(); | 185 OnPositionRequiresUpdate(); |
189 } | 186 } |
190 } | 187 } |
191 | 188 |
192 gfx::NativeWindow NativeWebContentsModalDialogManagerViews::dialog() { | 189 gfx::NativeWindow NativeWebContentsModalDialogManagerViews::dialog() { |
193 return dialog_; | 190 return dialog_; |
194 } | 191 } |
195 | 192 |
| 193 void NativeWebContentsModalDialogManagerViews::ShowWidget( |
| 194 views::Widget* widget) { |
| 195 // |host_| may be NULL during tab drag on Views/Win32. |
| 196 if (host_) |
| 197 constrained_window::UpdateWebContentsModalDialogPosition(widget, host_); |
| 198 widget->Show(); |
| 199 } |
| 200 |
| 201 void NativeWebContentsModalDialogManagerViews::HideWidget( |
| 202 views::Widget* widget) { |
| 203 widget->Hide(); |
| 204 } |
| 205 |
196 views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget( | 206 views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget( |
197 gfx::NativeWindow dialog) { | 207 gfx::NativeWindow dialog) { |
198 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog); | 208 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog); |
199 DCHECK(widget); | 209 DCHECK(widget); |
200 return widget; | 210 return widget; |
201 } | 211 } |
202 | 212 |
203 void NativeWebContentsModalDialogManagerViews::WidgetClosing( | 213 void NativeWebContentsModalDialogManagerViews::WidgetClosing( |
204 views::Widget* widget) { | 214 views::Widget* widget) { |
205 #if defined(USE_AURA) | 215 #if defined(USE_AURA) |
206 gfx::NativeView view = platform_util::GetParent(widget->GetNativeView()); | 216 gfx::NativeView view = platform_util::GetParent(widget->GetNativeView()); |
207 // Allow the parent to animate again. | 217 // Allow the parent to animate again. |
208 if (view && view->parent()) | 218 if (view && view->parent()) |
209 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); | 219 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); |
210 #endif | 220 #endif |
211 widget->RemoveObserver(this); | 221 widget->RemoveObserver(this); |
212 observed_widgets_.erase(widget); | 222 observed_widgets_.erase(widget); |
213 | 223 |
214 #if defined(USE_AURA) | 224 #if defined(USE_AURA) |
215 shown_widgets_.erase(widget); | 225 shown_widgets_.erase(widget); |
216 #endif | 226 #endif |
217 | 227 |
218 // Will cause this object to be deleted. | 228 // Will cause this object to be deleted. |
219 native_delegate_->WillClose(widget->GetNativeWindow()); | 229 native_delegate_->WillClose(widget->GetNativeWindow()); |
220 } | 230 } |
OLD | NEW |