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

Side by Side Diff: ui/views/window/dialog_client_view.cc

Issue 1953943003: In dialogs & dialog-like bubbles, make the escape button just close (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review 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 (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 "ui/views/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // Layout the contents view to the top and side edges of the contents bounds. 208 // Layout the contents view to the top and side edges of the contents bounds.
209 // NOTE: The local insets do not apply to the contents view sides or top. 209 // NOTE: The local insets do not apply to the contents view sides or top.
210 const gfx::Rect contents_bounds = GetContentsBounds(); 210 const gfx::Rect contents_bounds = GetContentsBounds();
211 contents_view()->SetBounds(contents_bounds.x(), contents_bounds.y(), 211 contents_view()->SetBounds(contents_bounds.x(), contents_bounds.y(),
212 contents_bounds.width(), bounds.bottom() - contents_bounds.y()); 212 contents_bounds.width(), bounds.bottom() - contents_bounds.y());
213 } 213 }
214 214
215 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) { 215 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) {
216 DCHECK_EQ(accelerator.key_code(), ui::VKEY_ESCAPE); 216 DCHECK_EQ(accelerator.key_code(), ui::VKEY_ESCAPE);
217 217
218 // If there's a cancel button, it handles escape.
msw 2016/05/10 18:23:32 I like this behavior with the bookmark bubble, and
219 if (cancel_button_)
220 return cancel_button_->AcceleratorPressed(accelerator);
221
222 GetWidget()->Close(); 218 GetWidget()->Close();
223 return true; 219 return true;
224 } 220 }
225 221
226 void DialogClientView::ViewHierarchyChanged( 222 void DialogClientView::ViewHierarchyChanged(
227 const ViewHierarchyChangedDetails& details) { 223 const ViewHierarchyChangedDetails& details) {
228 ClientView::ViewHierarchyChanged(details); 224 ClientView::ViewHierarchyChanged(details);
229 if (details.is_add && details.child == this) { 225 if (details.is_add && details.child == this) {
230 UpdateDialogButtons(); 226 UpdateDialogButtons();
231 CreateExtraView(); 227 CreateExtraView();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 std::remove(child_views.begin(), child_views.end(), nullptr), 356 std::remove(child_views.begin(), child_views.end(), nullptr),
361 child_views.end()); 357 child_views.end());
362 358
363 // Setup focus by reordering views. It is not safe to use SetNextFocusableView 359 // Setup focus by reordering views. It is not safe to use SetNextFocusableView
364 // since child views may be added externally to this view. 360 // since child views may be added externally to this view.
365 for (size_t i = 0; i < child_views.size(); i++) 361 for (size_t i = 0; i < child_views.size(); i++)
366 ReorderChildView(child_views[i], i); 362 ReorderChildView(child_views[i], i);
367 } 363 }
368 364
369 } // namespace views 365 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698