OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/platform_util.h" | 8 #include "chrome/browser/platform_util.h" |
9 #include "chrome/browser/ui/views/constrained_window_views.h" | 9 #include "chrome/browser/ui/views/constrained_window_views.h" |
10 #include "components/web_modal/single_web_contents_dialog_manager.h" | 10 #include "components/web_modal/single_web_contents_dialog_manager.h" |
11 #include "components/web_modal/web_contents_modal_dialog_host.h" | 11 #include "components/web_modal/web_contents_modal_dialog_host.h" |
12 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 12 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 #include "ui/views/border.h" | 15 #include "ui/views/border.h" |
16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
17 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
18 #include "ui/views/widget/widget_observer.h" | 18 #include "ui/views/widget/widget_observer.h" |
19 #include "ui/views/window/dialog_delegate.h" | 19 #include "ui/views/window/dialog_delegate.h" |
20 #include "ui/views/window/non_client_view.h" | 20 #include "ui/views/window/non_client_view.h" |
21 | 21 |
22 #if defined(USE_AURA) | 22 #if defined(USE_AURA) |
23 #include "ui/aura/client/aura_constants.h" | 23 #include "ui/aura/client/aura_constants.h" |
24 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
25 #include "ui/wm/core/visibility_controller.h" | 25 #include "ui/wm/core/visibility_controller.h" |
26 #include "ui/wm/core/window_animations.h" | 26 #include "ui/wm/core/window_animations.h" |
27 #include "ui/wm/core/window_modality_controller.h" | 27 #include "ui/wm/core/window_modality_controller.h" |
28 #endif | 28 #endif |
29 | 29 |
30 // TODO(wittman): this code should not depend on ash. | |
31 #if defined(USE_ASH) | |
32 #include "ash/ash_constants.h" | |
33 #include "ash/frame/custom_frame_view_ash.h" | |
34 #include "ash/shell.h" | |
35 #endif | |
36 | |
37 using web_modal::NativeWebContentsModalDialog; | 30 using web_modal::NativeWebContentsModalDialog; |
38 using web_modal::SingleWebContentsDialogManager; | 31 using web_modal::SingleWebContentsDialogManager; |
39 using web_modal::SingleWebContentsDialogManagerDelegate; | 32 using web_modal::SingleWebContentsDialogManagerDelegate; |
40 using web_modal::WebContentsModalDialogHost; | 33 using web_modal::WebContentsModalDialogHost; |
41 using web_modal::ModalDialogHostObserver; | 34 using web_modal::ModalDialogHostObserver; |
42 | 35 |
43 namespace { | 36 namespace { |
44 | 37 |
45 class NativeWebContentsModalDialogManagerViews | 38 class NativeWebContentsModalDialogManagerViews |
46 : public SingleWebContentsDialogManager, | 39 : public SingleWebContentsDialogManager, |
(...skipping 29 matching lines...) Expand all Loading... |
76 widget->set_movement_disabled(true); | 69 widget->set_movement_disabled(true); |
77 | 70 |
78 #if defined(USE_AURA) | 71 #if defined(USE_AURA) |
79 // TODO(wittman): remove once the new visual style is complete | 72 // TODO(wittman): remove once the new visual style is complete |
80 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, | 73 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, |
81 true); | 74 true); |
82 | 75 |
83 wm::SetWindowVisibilityAnimationType( | 76 wm::SetWindowVisibilityAnimationType( |
84 widget->GetNativeWindow(), | 77 widget->GetNativeWindow(), |
85 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); | 78 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE); |
86 #endif | |
87 | 79 |
88 #if defined(USE_ASH) | |
89 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); | 80 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); |
90 wm::SetChildWindowVisibilityChangesAnimated(parent); | 81 wm::SetChildWindowVisibilityChangesAnimated(parent); |
91 // No animations should get performed on the window since that will re-order | 82 // No animations should get performed on the window since that will re-order |
92 // the window stack which will then cause many problems. | 83 // the window stack which will then cause many problems. |
93 if (parent && parent->parent()) { | 84 if (parent && parent->parent()) { |
94 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); | 85 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); |
95 } | 86 } |
96 | 87 |
97 wm::SetModalParent( | 88 wm::SetModalParent( |
98 widget->GetNativeWindow(), | 89 widget->GetNativeWindow(), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 127 |
137 virtual void Close() override { | 128 virtual void Close() override { |
138 GetWidget(dialog())->Close(); | 129 GetWidget(dialog())->Close(); |
139 } | 130 } |
140 | 131 |
141 virtual void Focus() override { | 132 virtual void Focus() override { |
142 views::Widget* widget = GetWidget(dialog()); | 133 views::Widget* widget = GetWidget(dialog()); |
143 if (widget->widget_delegate() && | 134 if (widget->widget_delegate() && |
144 widget->widget_delegate()->GetInitiallyFocusedView()) | 135 widget->widget_delegate()->GetInitiallyFocusedView()) |
145 widget->widget_delegate()->GetInitiallyFocusedView()->RequestFocus(); | 136 widget->widget_delegate()->GetInitiallyFocusedView()->RequestFocus(); |
146 #if defined(USE_ASH) | 137 #if defined(USE_AURA) |
147 // We don't necessarily have a RootWindow yet. | 138 // We don't necessarily have a RootWindow yet. |
148 if (widget->GetNativeView()->GetRootWindow()) | 139 if (widget->GetNativeView()->GetRootWindow()) |
149 widget->GetNativeView()->Focus(); | 140 widget->GetNativeView()->Focus(); |
150 #endif | 141 #endif |
151 } | 142 } |
152 | 143 |
153 virtual void Pulse() override { | 144 virtual void Pulse() override { |
154 } | 145 } |
155 | 146 |
156 // WebContentsModalDialogHostObserver overrides | 147 // WebContentsModalDialogHostObserver overrides |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 205 } |
215 | 206 |
216 private: | 207 private: |
217 static views::Widget* GetWidget(NativeWebContentsModalDialog dialog) { | 208 static views::Widget* GetWidget(NativeWebContentsModalDialog dialog) { |
218 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog); | 209 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog); |
219 DCHECK(widget); | 210 DCHECK(widget); |
220 return widget; | 211 return widget; |
221 } | 212 } |
222 | 213 |
223 void WidgetClosing(views::Widget* widget) { | 214 void WidgetClosing(views::Widget* widget) { |
224 #if defined(USE_ASH) | 215 #if defined(USE_AURA) |
225 gfx::NativeView view = platform_util::GetParent(widget->GetNativeView()); | 216 gfx::NativeView view = platform_util::GetParent(widget->GetNativeView()); |
226 // Allow the parent to animate again. | 217 // Allow the parent to animate again. |
227 if (view && view->parent()) | 218 if (view && view->parent()) |
228 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); | 219 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); |
229 #endif | 220 #endif |
230 widget->RemoveObserver(this); | 221 widget->RemoveObserver(this); |
231 observed_widgets_.erase(widget); | 222 observed_widgets_.erase(widget); |
232 | 223 |
233 #if defined(USE_AURA) | 224 #if defined(USE_AURA) |
234 shown_widgets_.erase(widget); | 225 shown_widgets_.erase(widget); |
(...skipping 17 matching lines...) Expand all Loading... |
252 namespace web_modal { | 243 namespace web_modal { |
253 | 244 |
254 SingleWebContentsDialogManager* WebContentsModalDialogManager:: | 245 SingleWebContentsDialogManager* WebContentsModalDialogManager:: |
255 CreateNativeWebModalManager( | 246 CreateNativeWebModalManager( |
256 NativeWebContentsModalDialog dialog, | 247 NativeWebContentsModalDialog dialog, |
257 SingleWebContentsDialogManagerDelegate* native_delegate) { | 248 SingleWebContentsDialogManagerDelegate* native_delegate) { |
258 return new NativeWebContentsModalDialogManagerViews(dialog, native_delegate); | 249 return new NativeWebContentsModalDialogManagerViews(dialog, native_delegate); |
259 } | 250 } |
260 | 251 |
261 } // namespace web_modal | 252 } // namespace web_modal |
OLD | NEW |