Chromium Code Reviews| 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 "components/constrained_window/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 "components/constrained_window/constrained_window_views.h" | 9 #include "components/constrained_window/constrained_window_views.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_host.h" | 10 #include "components/web_modal/web_contents_modal_dialog_host.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 "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/widget/widget_delegate.h" | 16 #include "ui/views/widget/widget_delegate.h" |
| 17 #include "ui/views/window/dialog_delegate.h" | 17 #include "ui/views/window/dialog_delegate.h" |
| 18 #include "ui/views/window/non_client_view.h" | 18 #include "ui/views/window/non_client_view.h" |
| 19 | 19 |
| 20 #if defined(USE_AURA) | 20 #if defined(USE_AURA) |
| 21 #include "ui/aura/client/aura_constants.h" | 21 #include "ui/aura/client/aura_constants.h" |
| 22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_targeter.h" | |
| 23 #include "ui/wm/core/visibility_controller.h" | 24 #include "ui/wm/core/visibility_controller.h" |
| 24 #include "ui/wm/core/window_animations.h" | 25 #include "ui/wm/core/window_animations.h" |
| 25 #include "ui/wm/core/window_modality_controller.h" | 26 #include "ui/wm/core/window_modality_controller.h" |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 using web_modal::SingleWebContentsDialogManager; | 29 using web_modal::SingleWebContentsDialogManager; |
| 29 using web_modal::SingleWebContentsDialogManagerDelegate; | 30 using web_modal::SingleWebContentsDialogManagerDelegate; |
| 30 using web_modal::WebContentsModalDialogHost; | 31 using web_modal::WebContentsModalDialogHost; |
| 31 using web_modal::ModalDialogHostObserver; | 32 using web_modal::ModalDialogHostObserver; |
| 32 | 33 |
| 33 namespace constrained_window { | 34 namespace constrained_window { |
| 34 | 35 |
| 35 NativeWebContentsModalDialogManagerViews:: | 36 NativeWebContentsModalDialogManagerViews:: |
| 36 NativeWebContentsModalDialogManagerViews( | 37 NativeWebContentsModalDialogManagerViews( |
| 37 gfx::NativeWindow dialog, | 38 gfx::NativeWindow dialog, |
| 38 SingleWebContentsDialogManagerDelegate* native_delegate) | 39 SingleWebContentsDialogManagerDelegate* native_delegate, |
| 40 bool is_nonclipped) | |
| 39 : native_delegate_(native_delegate), | 41 : native_delegate_(native_delegate), |
| 40 dialog_(dialog), | 42 dialog_(dialog), |
| 41 host_(NULL), | 43 host_(NULL), |
| 42 host_destroying_(false) { | 44 host_destroying_(false) { |
| 43 ManageDialog(); | 45 ManageDialog(is_nonclipped); |
| 44 } | 46 } |
| 45 | 47 |
| 46 NativeWebContentsModalDialogManagerViews:: | 48 NativeWebContentsModalDialogManagerViews:: |
| 47 ~NativeWebContentsModalDialogManagerViews() { | 49 ~NativeWebContentsModalDialogManagerViews() { |
| 48 if (host_) | 50 if (host_) |
| 49 host_->RemoveObserver(this); | 51 host_->RemoveObserver(this); |
| 50 | 52 |
| 51 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin(); | 53 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin(); |
| 52 it != observed_widgets_.end(); ++it) { | 54 it != observed_widgets_.end(); ++it) { |
| 53 (*it)->RemoveObserver(this); | 55 (*it)->RemoveObserver(this); |
| 54 } | 56 } |
| 55 } | 57 } |
| 56 | 58 |
| 57 void NativeWebContentsModalDialogManagerViews::ManageDialog() { | 59 void NativeWebContentsModalDialogManagerViews:: |
| 60 ManageDialog(bool is_nonclipped) { | |
|
Mike Wittman
2016/08/19 19:46:57
nit: line break after open paren rather than befor
rbpotter
2016/08/19 21:43:38
Done.
| |
| 58 views::Widget* widget = GetWidget(dialog()); | 61 views::Widget* widget = GetWidget(dialog()); |
| 59 widget->AddObserver(this); | 62 widget->AddObserver(this); |
| 60 observed_widgets_.insert(widget); | 63 observed_widgets_.insert(widget); |
| 61 widget->set_movement_disabled(true); | 64 widget->set_movement_disabled(true); |
| 62 | 65 |
| 63 #if defined(USE_AURA) | 66 #if defined(USE_AURA) |
| 64 // TODO(wittman): remove once the new visual style is complete | 67 // TODO(wittman): remove once the new visual style is complete |
| 65 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, | 68 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, |
| 66 true); | 69 true); |
| 67 | 70 |
| 68 wm::SetWindowVisibilityAnimationType( | 71 wm::SetWindowVisibilityAnimationType( |
| 69 widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); | 72 widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); |
| 70 | 73 |
| 71 gfx::NativeView parent = widget->GetNativeView()->parent(); | 74 gfx::NativeView parent = widget->GetNativeView()->parent(); |
| 72 wm::SetChildWindowVisibilityChangesAnimated(parent); | 75 wm::SetChildWindowVisibilityChangesAnimated(parent); |
| 73 // No animations should get performed on the window since that will re-order | 76 // No animations should get performed on the window since that will re-order |
| 74 // the window stack which will then cause many problems. | 77 // the window stack which will then cause many problems. |
| 75 if (parent && parent->parent()) { | 78 if (parent && parent->parent()) { |
| 76 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); | 79 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); |
| 77 } | 80 } |
| 78 | 81 |
| 79 wm::SetModalParent(widget->GetNativeWindow(), | 82 wm::SetModalParent(widget->GetNativeWindow(), |
| 80 native_delegate_->GetWebContents()->GetNativeView()); | 83 native_delegate_->GetWebContents()->GetNativeView()); |
| 81 #endif | 84 #if defined(OS_CHROMEOS) |
| 85 if (is_nonclipped) { | |
| 86 widget->SetNativeWindowProperty(aura::kHasIndependentBoundsKey, | |
| 87 reinterpret_cast<void*>(true)); | |
| 88 } | |
| 89 #endif // defined(OS_CHROMEOS) | |
| 90 #endif // defined(USE_AURA) | |
| 82 } | 91 } |
| 83 | 92 |
| 84 // SingleWebContentsDialogManager: | 93 // SingleWebContentsDialogManager: |
| 85 | 94 |
| 86 void NativeWebContentsModalDialogManagerViews::Show() { | 95 void NativeWebContentsModalDialogManagerViews::Show() { |
| 87 // The host destroying means the dialogs will be destroyed in short order. | 96 // The host destroying means the dialogs will be destroyed in short order. |
| 88 // Avoid showing dialogs at this point as the necessary native window | 97 // Avoid showing dialogs at this point as the necessary native window |
| 89 // services may not be present. | 98 // services may not be present. |
| 90 if (host_destroying_) | 99 if (host_destroying_) |
| 91 return; | 100 return; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 | 223 |
| 215 #if defined(USE_AURA) | 224 #if defined(USE_AURA) |
| 216 shown_widgets_.erase(widget); | 225 shown_widgets_.erase(widget); |
| 217 #endif | 226 #endif |
| 218 | 227 |
| 219 // Will cause this object to be deleted. | 228 // Will cause this object to be deleted. |
| 220 native_delegate_->WillClose(widget->GetNativeWindow()); | 229 native_delegate_->WillClose(widget->GetNativeWindow()); |
| 221 } | 230 } |
| 222 | 231 |
| 223 } // namespace constrained_window | 232 } // namespace constrained_window |
| OLD | NEW |