| 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 16 matching lines...) Expand all Loading... |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 using web_modal::SingleWebContentsDialogManager; | 29 using web_modal::SingleWebContentsDialogManager; |
| 30 using web_modal::SingleWebContentsDialogManagerDelegate; | 30 using web_modal::SingleWebContentsDialogManagerDelegate; |
| 31 using web_modal::WebContentsModalDialogHost; | 31 using web_modal::WebContentsModalDialogHost; |
| 32 using web_modal::ModalDialogHostObserver; | 32 using web_modal::ModalDialogHostObserver; |
| 33 | 33 |
| 34 NativeWebContentsModalDialogManagerViews:: | 34 NativeWebContentsModalDialogManagerViews:: |
| 35 NativeWebContentsModalDialogManagerViews( | 35 NativeWebContentsModalDialogManagerViews( |
| 36 gfx::NativeWindow dialog, | 36 gfx::NativeWindow dialog, |
| 37 SingleWebContentsDialogManagerDelegate* native_delegate) | 37 SingleWebContentsDialogManagerDelegate* native_delegate, |
| 38 bool* independent_bounds, |
| 39 const char * kHasIndependentBoundsKey) |
| 38 : native_delegate_(native_delegate), | 40 : native_delegate_(native_delegate), |
| 39 dialog_(dialog), | 41 dialog_(dialog), |
| 40 host_(NULL), | 42 host_(NULL), |
| 41 host_destroying_(false) { | 43 host_destroying_(false) { |
| 42 ManageDialog(); | 44 ManageDialog(independent_bounds, kHasIndependentBoundsKey); |
| 43 } | 45 } |
| 44 | 46 |
| 45 NativeWebContentsModalDialogManagerViews:: | 47 NativeWebContentsModalDialogManagerViews:: |
| 46 ~NativeWebContentsModalDialogManagerViews() { | 48 ~NativeWebContentsModalDialogManagerViews() { |
| 47 if (host_) | 49 if (host_) |
| 48 host_->RemoveObserver(this); | 50 host_->RemoveObserver(this); |
| 49 | 51 |
| 50 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin(); | 52 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin(); |
| 51 it != observed_widgets_.end(); ++it) { | 53 it != observed_widgets_.end(); ++it) { |
| 52 (*it)->RemoveObserver(this); | 54 (*it)->RemoveObserver(this); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| 56 void NativeWebContentsModalDialogManagerViews::ManageDialog() { | 58 void NativeWebContentsModalDialogManagerViews::ManageDialog( |
| 59 bool* independent_bounds, const char * kHasIndependentBoundsKey) { |
| 57 views::Widget* widget = GetWidget(dialog()); | 60 views::Widget* widget = GetWidget(dialog()); |
| 58 widget->AddObserver(this); | 61 widget->AddObserver(this); |
| 59 observed_widgets_.insert(widget); | 62 observed_widgets_.insert(widget); |
| 60 widget->set_movement_disabled(true); | 63 widget->set_movement_disabled(true); |
| 61 | 64 |
| 62 #if defined(USE_AURA) | 65 #if defined(USE_AURA) |
| 63 // TODO(wittman): remove once the new visual style is complete | 66 // TODO(wittman): remove once the new visual style is complete |
| 64 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, | 67 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, |
| 65 true); | 68 true); |
| 66 | 69 |
| 67 wm::SetWindowVisibilityAnimationType( | 70 wm::SetWindowVisibilityAnimationType( |
| 68 widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); | 71 widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); |
| 69 | 72 |
| 70 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); | 73 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); |
| 71 wm::SetChildWindowVisibilityChangesAnimated(parent); | 74 wm::SetChildWindowVisibilityChangesAnimated(parent); |
| 72 // No animations should get performed on the window since that will re-order | 75 // No animations should get performed on the window since that will re-order |
| 73 // the window stack which will then cause many problems. | 76 // the window stack which will then cause many problems. |
| 74 if (parent && parent->parent()) { | 77 if (parent && parent->parent()) { |
| 75 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); | 78 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); |
| 76 } | 79 } |
| 77 | 80 |
| 78 wm::SetModalParent(widget->GetNativeWindow(), | 81 wm::SetModalParent(widget->GetNativeWindow(), |
| 79 native_delegate_->GetWebContents()->GetNativeView()); | 82 native_delegate_->GetWebContents()->GetNativeView(), |
| 83 independent_bounds, kHasIndependentBoundsKey); |
| 80 #endif | 84 #endif |
| 81 } | 85 } |
| 82 | 86 |
| 83 // SingleWebContentsDialogManager: | 87 // SingleWebContentsDialogManager: |
| 84 | 88 |
| 85 void NativeWebContentsModalDialogManagerViews::Show() { | 89 void NativeWebContentsModalDialogManagerViews::Show() { |
| 86 // The host destroying means the dialogs will be destroyed in short order. | 90 // The host destroying means the dialogs will be destroyed in short order. |
| 87 // Avoid showing dialogs at this point as the necessary native window | 91 // Avoid showing dialogs at this point as the necessary native window |
| 88 // services may not be present. | 92 // services may not be present. |
| 89 if (host_destroying_) | 93 if (host_destroying_) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 widget->RemoveObserver(this); | 215 widget->RemoveObserver(this); |
| 212 observed_widgets_.erase(widget); | 216 observed_widgets_.erase(widget); |
| 213 | 217 |
| 214 #if defined(USE_AURA) | 218 #if defined(USE_AURA) |
| 215 shown_widgets_.erase(widget); | 219 shown_widgets_.erase(widget); |
| 216 #endif | 220 #endif |
| 217 | 221 |
| 218 // Will cause this object to be deleted. | 222 // Will cause this object to be deleted. |
| 219 native_delegate_->WillClose(widget->GetNativeWindow()); | 223 native_delegate_->WillClose(widget->GetNativeWindow()); |
| 220 } | 224 } |
| OLD | NEW |