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 "chrome/browser/platform_util.h" | 7 #include "chrome/browser/platform_util.h" |
8 #include "chrome/browser/ui/native_web_contents_modal_dialog_manager.h" | 8 #include "chrome/browser/ui/native_web_contents_modal_dialog_manager.h" |
9 #include "chrome/browser/ui/views/constrained_window_views.h" | 9 #include "chrome/browser/ui/views/constrained_window_views.h" |
10 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" | 10 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 virtual ~NativeWebContentsModalDialogManagerViews() { | 39 virtual ~NativeWebContentsModalDialogManagerViews() { |
40 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin(); | 40 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin(); |
41 it != observed_widgets_.end(); | 41 it != observed_widgets_.end(); |
42 ++it) { | 42 ++it) { |
43 (*it)->RemoveObserver(this); | 43 (*it)->RemoveObserver(this); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 // NativeWebContentsModalDialogManager overrides | 47 // NativeWebContentsModalDialogManager overrides |
48 virtual void ManageDialog(gfx::NativeWindow window) OVERRIDE { | 48 virtual void ManageDialog(gfx::NativeView view) OVERRIDE { |
49 views::Widget* widget = GetWidget(window); | 49 views::Widget* widget = GetWidget(view); |
50 widget->AddObserver(this); | 50 widget->AddObserver(this); |
51 observed_widgets_.insert(widget); | 51 observed_widgets_.insert(widget); |
52 widget->set_movement_disabled(true); | 52 widget->set_movement_disabled(true); |
53 | 53 |
54 #if defined(USE_AURA) | 54 #if defined(USE_AURA) |
55 // TODO(wittman): remove once the new visual style is complete | 55 // TODO(wittman): remove once the new visual style is complete |
56 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, | 56 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, |
57 true); | 57 true); |
58 #endif | 58 #endif |
59 | 59 |
60 #if defined(USE_ASH) | 60 #if defined(USE_ASH) |
61 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); | 61 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); |
62 views::corewm::SetChildWindowVisibilityChangesAnimated(parent); | 62 views::corewm::SetChildWindowVisibilityChangesAnimated(parent); |
63 // No animations should get performed on the window since that will re-order | 63 // No animations should get performed on the window since that will re-order |
64 // the window stack which will then cause many problems. | 64 // the window stack which will then cause many problems. |
65 if (parent && parent->parent()) { | 65 if (parent && parent->parent()) { |
66 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); | 66 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); |
67 } | 67 } |
68 | 68 |
69 // TODO(wittman): remove once the new visual style is complete | 69 // TODO(wittman): remove once the new visual style is complete |
70 widget->GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true); | 70 widget->GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true); |
71 views::corewm::SetModalParent( | 71 views::corewm::SetModalParent( |
72 widget->GetNativeWindow(), | 72 widget->GetNativeWindow(), |
73 platform_util::GetParent(widget->GetNativeView())); | 73 platform_util::GetParent(widget->GetNativeView())); |
74 #endif | 74 #endif |
75 } | 75 } |
76 | 76 |
77 virtual void CloseDialog(gfx::NativeWindow window) OVERRIDE { | 77 virtual void CloseDialog(gfx::NativeView view) OVERRIDE { |
78 views::Widget* widget = GetWidget(window); | 78 views::Widget* widget = GetWidget(view); |
79 #if defined(USE_ASH) | 79 #if defined(USE_ASH) |
80 gfx::NativeView view = platform_util::GetParent(widget->GetNativeView()); | 80 gfx::NativeView view = platform_util::GetParent(widget->GetNativeView()); |
81 // Allow the parent to animate again. | 81 // Allow the parent to animate again. |
82 if (view && view->parent()) | 82 if (view && view->parent()) |
83 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); | 83 view->parent()->ClearProperty(aura::client::kAnimationsDisabledKey); |
84 #endif | 84 #endif |
85 widget->Close(); | 85 widget->Close(); |
86 } | 86 } |
87 | 87 |
88 // views::WidgetObserver overrides | 88 // views::WidgetObserver overrides |
89 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { | 89 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { |
90 manager_->WillClose(static_cast<ConstrainedWindowViews*>(widget)); | 90 manager_->WillClose(static_cast<ConstrainedWindowViews*>(widget)); |
91 observed_widgets_.erase(widget); | 91 observed_widgets_.erase(widget); |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 static views::Widget* GetWidget(gfx::NativeWindow window) { | 95 static views::Widget* GetWidget(gfx::NativeView view) { |
96 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 96 views::Widget* widget = views::Widget::GetWidgetForNativeView(view); |
97 DCHECK(widget); | 97 DCHECK(widget); |
98 return widget; | 98 return widget; |
99 } | 99 } |
100 | 100 |
101 WebContentsModalDialogManager* manager_; | 101 WebContentsModalDialogManager* manager_; |
102 std::set<views::Widget*> observed_widgets_; | 102 std::set<views::Widget*> observed_widgets_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerViews); | 104 DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerViews); |
105 }; | 105 }; |
106 | 106 |
107 } // namespace | 107 } // namespace |
108 | 108 |
109 NativeWebContentsModalDialogManager* WebContentsModalDialogManager:: | 109 NativeWebContentsModalDialogManager* WebContentsModalDialogManager:: |
110 CreateNativeManager(WebContentsModalDialogManager* manager) { | 110 CreateNativeManager(WebContentsModalDialogManager* manager) { |
111 return new NativeWebContentsModalDialogManagerViews(manager); | 111 return new NativeWebContentsModalDialogManagerViews(manager); |
112 } | 112 } |
OLD | NEW |