| 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 "components/constrained_window/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" | |
| 10 #include "components/constrained_window/constrained_window_views.h" | 9 #include "components/constrained_window/constrained_window_views.h" |
| 11 #include "components/web_modal/web_contents_modal_dialog_host.h" | 10 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 12 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 11 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 13 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
| 14 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 16 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 17 #include "ui/views/widget/widget_delegate.h" | 16 #include "ui/views/widget/widget_delegate.h" |
| 18 #include "ui/views/window/dialog_delegate.h" | 17 #include "ui/views/window/dialog_delegate.h" |
| 19 #include "ui/views/window/non_client_view.h" | 18 #include "ui/views/window/non_client_view.h" |
| 20 | 19 |
| 21 #if defined(USE_AURA) | 20 #if defined(USE_AURA) |
| 22 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
| 23 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 24 #include "ui/wm/core/visibility_controller.h" | 23 #include "ui/wm/core/visibility_controller.h" |
| 25 #include "ui/wm/core/window_animations.h" | 24 #include "ui/wm/core/window_animations.h" |
| 26 #include "ui/wm/core/window_modality_controller.h" | 25 #include "ui/wm/core/window_modality_controller.h" |
| 27 #endif | 26 #endif |
| 28 | 27 |
| 29 using web_modal::SingleWebContentsDialogManager; | 28 using web_modal::SingleWebContentsDialogManager; |
| 30 using web_modal::SingleWebContentsDialogManagerDelegate; | 29 using web_modal::SingleWebContentsDialogManagerDelegate; |
| 31 using web_modal::WebContentsModalDialogHost; | 30 using web_modal::WebContentsModalDialogHost; |
| 32 using web_modal::ModalDialogHostObserver; | 31 using web_modal::ModalDialogHostObserver; |
| 33 | 32 |
| 33 namespace constrained_window { |
| 34 |
| 34 NativeWebContentsModalDialogManagerViews:: | 35 NativeWebContentsModalDialogManagerViews:: |
| 35 NativeWebContentsModalDialogManagerViews( | 36 NativeWebContentsModalDialogManagerViews( |
| 36 gfx::NativeWindow dialog, | 37 gfx::NativeWindow dialog, |
| 37 SingleWebContentsDialogManagerDelegate* native_delegate) | 38 SingleWebContentsDialogManagerDelegate* native_delegate) |
| 38 : native_delegate_(native_delegate), | 39 : native_delegate_(native_delegate), |
| 39 dialog_(dialog), | 40 dialog_(dialog), |
| 40 host_(NULL), | 41 host_(NULL), |
| 41 host_destroying_(false) { | 42 host_destroying_(false) { |
| 42 ManageDialog(); | 43 ManageDialog(); |
| 43 } | 44 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 60 widget->set_movement_disabled(true); | 61 widget->set_movement_disabled(true); |
| 61 | 62 |
| 62 #if defined(USE_AURA) | 63 #if defined(USE_AURA) |
| 63 // TODO(wittman): remove once the new visual style is complete | 64 // TODO(wittman): remove once the new visual style is complete |
| 64 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, | 65 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, |
| 65 true); | 66 true); |
| 66 | 67 |
| 67 wm::SetWindowVisibilityAnimationType( | 68 wm::SetWindowVisibilityAnimationType( |
| 68 widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); | 69 widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); |
| 69 | 70 |
| 70 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); | 71 gfx::NativeView parent = widget->GetNativeView()->parent(); |
| 71 wm::SetChildWindowVisibilityChangesAnimated(parent); | 72 wm::SetChildWindowVisibilityChangesAnimated(parent); |
| 72 // No animations should get performed on the window since that will re-order | 73 // No animations should get performed on the window since that will re-order |
| 73 // the window stack which will then cause many problems. | 74 // the window stack which will then cause many problems. |
| 74 if (parent && parent->parent()) { | 75 if (parent && parent->parent()) { |
| 75 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); | 76 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); |
| 76 } | 77 } |
| 77 | 78 |
| 78 wm::SetModalParent(widget->GetNativeWindow(), | 79 wm::SetModalParent(widget->GetNativeWindow(), |
| 79 native_delegate_->GetWebContents()->GetNativeView()); | 80 native_delegate_->GetWebContents()->GetNativeView()); |
| 80 #endif | 81 #endif |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget( | 197 views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget( |
| 197 gfx::NativeWindow dialog) { | 198 gfx::NativeWindow dialog) { |
| 198 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog); | 199 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog); |
| 199 DCHECK(widget); | 200 DCHECK(widget); |
| 200 return widget; | 201 return widget; |
| 201 } | 202 } |
| 202 | 203 |
| 203 void NativeWebContentsModalDialogManagerViews::WidgetClosing( | 204 void NativeWebContentsModalDialogManagerViews::WidgetClosing( |
| 204 views::Widget* widget) { | 205 views::Widget* widget) { |
| 205 #if defined(USE_AURA) | 206 #if defined(USE_AURA) |
| 206 gfx::NativeView view = platform_util::GetParent(widget->GetNativeView()); | 207 gfx::NativeView view = widget->GetNativeView()->parent(); |
| 207 // Allow the parent to animate again. | 208 // Allow the parent to animate again. |
| 208 if (view && view->parent()) | 209 if (view && view->parent()) |
| 209 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); | 210 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); |
| 210 #endif | 211 #endif |
| 211 widget->RemoveObserver(this); | 212 widget->RemoveObserver(this); |
| 212 observed_widgets_.erase(widget); | 213 observed_widgets_.erase(widget); |
| 213 | 214 |
| 214 #if defined(USE_AURA) | 215 #if defined(USE_AURA) |
| 215 shown_widgets_.erase(widget); | 216 shown_widgets_.erase(widget); |
| 216 #endif | 217 #endif |
| 217 | 218 |
| 218 // Will cause this object to be deleted. | 219 // Will cause this object to be deleted. |
| 219 native_delegate_->WillClose(widget->GetNativeWindow()); | 220 native_delegate_->WillClose(widget->GetNativeWindow()); |
| 220 } | 221 } |
| 222 |
| 223 } // namespace constrained_window |
| OLD | NEW |