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

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

Issue 1779383002: MacViews: Remove constrained window dependencies for certificate viewer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase & address review comments. Created 4 years, 7 months 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
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return; 90 return;
91 91
92 views::Widget* widget = GetWidget(dialog()); 92 views::Widget* widget = GetWidget(dialog());
93 #if defined(USE_AURA) 93 #if defined(USE_AURA)
94 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend; 94 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend;
95 if (shown_widgets_.find(widget) != shown_widgets_.end()) { 95 if (shown_widgets_.find(widget) != shown_widgets_.end()) {
96 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations( 96 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations(
97 widget->GetNativeWindow()->parent())); 97 widget->GetNativeWindow()->parent()));
98 } 98 }
99 #endif 99 #endif
100 // Host may be NULL during tab drag on Views/Win32. 100 ShowWidget(widget);
101 if (host_)
102 constrained_window::UpdateWebContentsModalDialogPosition(widget, host_);
103 widget->Show();
104 Focus(); 101 Focus();
105 102
106 #if defined(USE_AURA) 103 #if defined(USE_AURA)
107 // TODO(pkotwicz): Control the z-order of the constrained dialog via 104 // TODO(pkotwicz): Control the z-order of the constrained dialog via
108 // views::kHostViewKey. We will need to ensure that the parent window's 105 // views::kHostViewKey. We will need to ensure that the parent window's
109 // shadows are below the constrained dialog in z-order when we do this. 106 // shadows are below the constrained dialog in z-order when we do this.
110 shown_widgets_.insert(widget); 107 shown_widgets_.insert(widget);
111 #endif 108 #endif
112 } 109 }
113 110
114 void NativeWebContentsModalDialogManagerViews::Hide() { 111 void NativeWebContentsModalDialogManagerViews::Hide() {
115 views::Widget* widget = GetWidget(dialog()); 112 views::Widget* widget = GetWidget(dialog());
116 #if defined(USE_AURA) 113 #if defined(USE_AURA)
117 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend; 114 std::unique_ptr<wm::SuspendChildWindowVisibilityAnimations> suspend;
118 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations( 115 suspend.reset(new wm::SuspendChildWindowVisibilityAnimations(
119 widget->GetNativeWindow()->parent())); 116 widget->GetNativeWindow()->parent()));
120 #endif 117 #endif
121 widget->Hide(); 118 HideWidget(widget);
122 } 119 }
123 120
124 void NativeWebContentsModalDialogManagerViews::Close() { 121 void NativeWebContentsModalDialogManagerViews::Close() {
125 GetWidget(dialog())->Close(); 122 GetWidget(dialog())->Close();
126 } 123 }
127 124
128 void NativeWebContentsModalDialogManagerViews::Focus() { 125 void NativeWebContentsModalDialogManagerViews::Focus() {
129 views::Widget* widget = GetWidget(dialog()); 126 views::Widget* widget = GetWidget(dialog());
130 if (widget->widget_delegate() && 127 if (widget->widget_delegate() &&
131 widget->widget_delegate()->GetInitiallyFocusedView()) 128 widget->widget_delegate()->GetInitiallyFocusedView())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 183 }
187 184
188 OnPositionRequiresUpdate(); 185 OnPositionRequiresUpdate();
189 } 186 }
190 } 187 }
191 188
192 gfx::NativeWindow NativeWebContentsModalDialogManagerViews::dialog() { 189 gfx::NativeWindow NativeWebContentsModalDialogManagerViews::dialog() {
193 return dialog_; 190 return dialog_;
194 } 191 }
195 192
193 web_modal::SingleWebContentsDialogManagerDelegate*
194 NativeWebContentsModalDialogManagerViews::native_delegate() {
195 return native_delegate_;
196 }
197
198 void NativeWebContentsModalDialogManagerViews::ShowWidget(
199 views::Widget* widget) {
200 // |host_| may be NULL during tab drag on Views/Win32.
201 if (host_)
202 constrained_window::UpdateWebContentsModalDialogPosition(widget, host_);
203 widget->Show();
204 }
205
206 void NativeWebContentsModalDialogManagerViews::HideWidget(
207 views::Widget* widget) {
208 widget->Hide();
209 }
210
196 views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget( 211 views::Widget* NativeWebContentsModalDialogManagerViews::GetWidget(
197 gfx::NativeWindow dialog) { 212 gfx::NativeWindow dialog) {
198 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog); 213 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(dialog);
199 DCHECK(widget); 214 DCHECK(widget);
200 return widget; 215 return widget;
201 } 216 }
202 217
203 void NativeWebContentsModalDialogManagerViews::WidgetClosing( 218 void NativeWebContentsModalDialogManagerViews::WidgetClosing(
204 views::Widget* widget) { 219 views::Widget* widget) {
205 #if defined(USE_AURA) 220 #if defined(USE_AURA)
(...skipping 16 matching lines...) Expand all
222 namespace web_modal { 237 namespace web_modal {
223 238
224 SingleWebContentsDialogManager* 239 SingleWebContentsDialogManager*
225 WebContentsModalDialogManager::CreateNativeWebModalManager( 240 WebContentsModalDialogManager::CreateNativeWebModalManager(
226 gfx::NativeWindow dialog, 241 gfx::NativeWindow dialog,
227 SingleWebContentsDialogManagerDelegate* native_delegate) { 242 SingleWebContentsDialogManagerDelegate* native_delegate) {
228 return new NativeWebContentsModalDialogManagerViews(dialog, native_delegate); 243 return new NativeWebContentsModalDialogManagerViews(dialog, native_delegate);
229 } 244 }
230 245
231 } // namespace web_modal 246 } // namespace web_modal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698