| 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 "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/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // Layout the contents view to the top and side edges of the contents bounds. | 206 // Layout the contents view to the top and side edges of the contents bounds. |
| 207 // NOTE: The local insets do not apply to the contents view sides or top. | 207 // NOTE: The local insets do not apply to the contents view sides or top. |
| 208 const gfx::Rect contents_bounds = GetContentsBounds(); | 208 const gfx::Rect contents_bounds = GetContentsBounds(); |
| 209 contents_view()->SetBounds(contents_bounds.x(), contents_bounds.y(), | 209 contents_view()->SetBounds(contents_bounds.x(), contents_bounds.y(), |
| 210 contents_bounds.width(), bounds.bottom() - contents_bounds.y()); | 210 contents_bounds.width(), bounds.bottom() - contents_bounds.y()); |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) { | 213 bool DialogClientView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
| 214 DCHECK_EQ(accelerator.key_code(), ui::VKEY_ESCAPE); | 214 DCHECK_EQ(accelerator.key_code(), ui::VKEY_ESCAPE); |
| 215 | 215 |
| 216 // If there's a cancel button, it handles escape. | |
| 217 if (cancel_button_) | |
| 218 return cancel_button_->AcceleratorPressed(accelerator); | |
| 219 | |
| 220 GetWidget()->Close(); | 216 GetWidget()->Close(); |
| 221 return true; | 217 return true; |
| 222 } | 218 } |
| 223 | 219 |
| 224 void DialogClientView::ViewHierarchyChanged( | 220 void DialogClientView::ViewHierarchyChanged( |
| 225 const ViewHierarchyChangedDetails& details) { | 221 const ViewHierarchyChangedDetails& details) { |
| 226 ClientView::ViewHierarchyChanged(details); | 222 ClientView::ViewHierarchyChanged(details); |
| 227 if (details.is_add && details.child == this) { | 223 if (details.is_add && details.child == this) { |
| 228 UpdateDialogButtons(); | 224 UpdateDialogButtons(); |
| 229 CreateExtraView(); | 225 CreateExtraView(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 std::remove(child_views.begin(), child_views.end(), nullptr), | 349 std::remove(child_views.begin(), child_views.end(), nullptr), |
| 354 child_views.end()); | 350 child_views.end()); |
| 355 | 351 |
| 356 // Setup focus by reordering views. It is not safe to use SetNextFocusableView | 352 // Setup focus by reordering views. It is not safe to use SetNextFocusableView |
| 357 // since child views may be added externally to this view. | 353 // since child views may be added externally to this view. |
| 358 for (size_t i = 0; i < child_views.size(); i++) | 354 for (size_t i = 0; i < child_views.size(); i++) |
| 359 ReorderChildView(child_views[i], i); | 355 ReorderChildView(child_views[i], i); |
| 360 } | 356 } |
| 361 | 357 |
| 362 } // namespace views | 358 } // namespace views |
| OLD | NEW |