Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/ui/views/web_contents_modal_dialog_manager_views.cc

Issue 63343004: Remove DialogDelegate::UseNewStyle and unused code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore [D]CHECKs and loop scoping. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/native_web_contents_modal_dialog_manager.h" 10 #include "components/web_modal/native_web_contents_modal_dialog_manager.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 views::Widget* widget = GetWidget(dialog); 70 views::Widget* widget = GetWidget(dialog);
71 widget->AddObserver(this); 71 widget->AddObserver(this);
72 observed_widgets_.insert(widget); 72 observed_widgets_.insert(widget);
73 widget->set_movement_disabled(true); 73 widget->set_movement_disabled(true);
74 74
75 #if defined(USE_AURA) 75 #if defined(USE_AURA)
76 // TODO(wittman): remove once the new visual style is complete 76 // TODO(wittman): remove once the new visual style is complete
77 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey, 77 widget->GetNativeWindow()->SetProperty(aura::client::kConstrainedWindowKey,
78 true); 78 true);
79 79
80 if (views::DialogDelegate::UseNewStyle()) { 80 views::corewm::SetWindowVisibilityAnimationType(
81 views::corewm::SetWindowVisibilityAnimationType( 81 widget->GetNativeWindow(),
82 widget->GetNativeWindow(), 82 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE);
83 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE);
84 }
85 #endif 83 #endif
86 84
87 #if defined(USE_ASH) 85 #if defined(USE_ASH)
88 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView()); 86 gfx::NativeView parent = platform_util::GetParent(widget->GetNativeView());
89 views::corewm::SetChildWindowVisibilityChangesAnimated(parent); 87 views::corewm::SetChildWindowVisibilityChangesAnimated(parent);
90 // No animations should get performed on the window since that will re-order 88 // No animations should get performed on the window since that will re-order
91 // the window stack which will then cause many problems. 89 // the window stack which will then cause many problems.
92 if (parent && parent->parent()) { 90 if (parent && parent->parent()) {
93 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true); 91 parent->parent()->SetProperty(aura::client::kAnimationsDisabledKey, true);
94 } 92 }
95 93
96 // TODO(wittman): remove once the new visual style is complete 94 // TODO(wittman): remove once the new visual style is complete
97 widget->GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true); 95 widget->GetNativeWindow()->SetProperty(ash::kConstrainedWindowKey, true);
98 views::corewm::SetModalParent( 96 views::corewm::SetModalParent(
99 widget->GetNativeWindow(), 97 widget->GetNativeWindow(),
100 platform_util::GetParent(widget->GetNativeView())); 98 platform_util::GetParent(widget->GetNativeView()));
101 #endif 99 #endif
102 } 100 }
103 101
104 virtual void ShowDialog(NativeWebContentsModalDialog dialog) OVERRIDE { 102 virtual void ShowDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
105 views::Widget* widget = GetWidget(dialog); 103 views::Widget* widget = GetWidget(dialog);
106 #if defined(USE_AURA) 104 #if defined(USE_AURA)
107 scoped_ptr<views::corewm::SuspendChildWindowVisibilityAnimations> suspend; 105 scoped_ptr<views::corewm::SuspendChildWindowVisibilityAnimations> suspend;
108 if (views::DialogDelegate::UseNewStyle() && 106 if (shown_widgets_.find(widget) != shown_widgets_.end()) {
109 shown_widgets_.find(widget) != shown_widgets_.end()) {
110 suspend.reset(new views::corewm::SuspendChildWindowVisibilityAnimations( 107 suspend.reset(new views::corewm::SuspendChildWindowVisibilityAnimations(
111 widget->GetNativeWindow()->parent())); 108 widget->GetNativeWindow()->parent()));
112 } 109 }
113 #endif 110 #endif
114 // Host may be NULL during tab drag on Views/Win32. 111 // Host may be NULL during tab drag on Views/Win32.
115 if (host_) 112 if (host_)
116 UpdateWebContentsModalDialogPosition(widget, host_); 113 UpdateWebContentsModalDialogPosition(widget, host_);
117 widget->Show(); 114 widget->Show();
118 FocusDialog(dialog); 115 FocusDialog(dialog);
119 116
120 #if defined(USE_AURA) 117 #if defined(USE_AURA)
121 // TODO(pkotwicz): Control the z-order of the constrained dialog via 118 // TODO(pkotwicz): Control the z-order of the constrained dialog via
122 // views::kHostViewKey. We will need to ensure that the parent window's 119 // views::kHostViewKey. We will need to ensure that the parent window's
123 // shadows are below the constrained dialog in z-order when we do this. 120 // shadows are below the constrained dialog in z-order when we do this.
124 shown_widgets_.insert(widget); 121 shown_widgets_.insert(widget);
125 #endif 122 #endif
126 } 123 }
127 124
128 virtual void HideDialog(NativeWebContentsModalDialog dialog) OVERRIDE { 125 virtual void HideDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
129 views::Widget* widget = GetWidget(dialog); 126 views::Widget* widget = GetWidget(dialog);
130 #if defined(USE_AURA) 127 #if defined(USE_AURA)
131 scoped_ptr<views::corewm::SuspendChildWindowVisibilityAnimations> suspend; 128 scoped_ptr<views::corewm::SuspendChildWindowVisibilityAnimations> suspend;
132 if (views::DialogDelegate::UseNewStyle()) { 129 suspend.reset(new views::corewm::SuspendChildWindowVisibilityAnimations(
133 suspend.reset(new views::corewm::SuspendChildWindowVisibilityAnimations( 130 widget->GetNativeWindow()->parent()));
134 widget->GetNativeWindow()->parent()));
135 }
136 #endif 131 #endif
137 widget->Hide(); 132 widget->Hide();
138 } 133 }
139 134
140 virtual void CloseDialog(NativeWebContentsModalDialog dialog) OVERRIDE { 135 virtual void CloseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
141 GetWidget(dialog)->Close(); 136 GetWidget(dialog)->Close();
142 } 137 }
143 138
144 virtual void FocusDialog(NativeWebContentsModalDialog dialog) OVERRIDE { 139 virtual void FocusDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
145 views::Widget* widget = GetWidget(dialog); 140 views::Widget* widget = GetWidget(dialog);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 WidgetClosing(widget); 185 WidgetClosing(widget);
191 } 186 }
192 187
193 virtual void HostChanged( 188 virtual void HostChanged(
194 web_modal::WebContentsModalDialogHost* new_host) OVERRIDE { 189 web_modal::WebContentsModalDialogHost* new_host) OVERRIDE {
195 if (host_) 190 if (host_)
196 host_->RemoveObserver(this); 191 host_->RemoveObserver(this);
197 192
198 host_ = new_host; 193 host_ = new_host;
199 194
200 if (host_) 195 // |host_| may be null during WebContents destruction or Win32 tab dragging.
196 if (host_) {
201 host_->AddObserver(this); 197 host_->AddObserver(this);
202 198
203 // Old-style dialogs are parented to the web contents view and don't need
204 // reparenting. The host_ may be null during tab drag under Views/Win32 or
205 // when destroying the WebContents.
206 if (views::DialogDelegate::UseNewStyle() && host_) {
207 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin(); 199 for (std::set<views::Widget*>::iterator it = observed_widgets_.begin();
208 it != observed_widgets_.end(); 200 it != observed_widgets_.end();
209 ++it) { 201 ++it) {
210 views::Widget::ReparentNativeView((*it)->GetNativeView(), 202 views::Widget::ReparentNativeView((*it)->GetNativeView(),
211 host_->GetHostView()); 203 host_->GetHostView());
212 } 204 }
213 205
214 OnPositionRequiresUpdate(); 206 OnPositionRequiresUpdate();
215 } 207 }
216 } 208 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 241
250 namespace web_modal { 242 namespace web_modal {
251 243
252 NativeWebContentsModalDialogManager* WebContentsModalDialogManager:: 244 NativeWebContentsModalDialogManager* WebContentsModalDialogManager::
253 CreateNativeManager( 245 CreateNativeManager(
254 NativeWebContentsModalDialogManagerDelegate* native_delegate) { 246 NativeWebContentsModalDialogManagerDelegate* native_delegate) {
255 return new NativeWebContentsModalDialogManagerViews(native_delegate); 247 return new NativeWebContentsModalDialogManagerViews(native_delegate);
256 } 248 }
257 249
258 } // namespace web_modal 250 } // namespace web_modal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698