| 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 "ui/base/keycodes/keyboard_codes.h" | 9 #include "ui/base/keycodes/keyboard_codes.h" |
| 10 #include "ui/views/controls/button/label_button.h" | 10 #include "ui/views/controls/button/label_button.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 DialogClientView* DialogClientView::AsDialogClientView() { | 139 DialogClientView* DialogClientView::AsDialogClientView() { |
| 140 return this; | 140 return this; |
| 141 } | 141 } |
| 142 | 142 |
| 143 const DialogClientView* DialogClientView::AsDialogClientView() const { | 143 const DialogClientView* DialogClientView::AsDialogClientView() const { |
| 144 return this; | 144 return this; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void DialogClientView::OnWillChangeFocus(View* focused_before, | 147 void DialogClientView::OnWillChangeFocus(View* focused_before, |
| 148 View* focused_now) { | 148 View* focused_now) { |
| 149 // New style dialogs do not move the default button with the focus. | |
| 150 // TODO(msw|wittman): Remove this functionality once the new style has landed. | |
| 151 if (DialogDelegate::UseNewStyle()) | |
| 152 return; | |
| 153 | |
| 154 // Make the newly focused button default or restore the dialog's default. | 149 // Make the newly focused button default or restore the dialog's default. |
| 155 const int default_button = GetDialogDelegate()->GetDefaultDialogButton(); | 150 const int default_button = GetDialogDelegate()->GetDefaultDialogButton(); |
| 156 LabelButton* new_default_button = NULL; | 151 LabelButton* new_default_button = NULL; |
| 157 if (focused_now && | 152 if (focused_now && |
| 158 !strcmp(focused_now->GetClassName(), LabelButton::kViewClassName)) { | 153 !strcmp(focused_now->GetClassName(), LabelButton::kViewClassName)) { |
| 159 new_default_button = static_cast<LabelButton*>(focused_now); | 154 new_default_button = static_cast<LabelButton*>(focused_now); |
| 160 } else if (default_button == ui::DIALOG_BUTTON_OK && ok_button_) { | 155 } else if (default_button == ui::DIALOG_BUTTON_OK && ok_button_) { |
| 161 new_default_button = ok_button_; | 156 new_default_button = ok_button_; |
| 162 } else if (default_button == ui::DIALOG_BUTTON_CANCEL && cancel_button_) { | 157 } else if (default_button == ui::DIALOG_BUTTON_CANCEL && cancel_button_) { |
| 163 new_default_button = cancel_button_; | 158 new_default_button = cancel_button_; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 gfx::Insets(0, kButtonHEdgeMargin, | 381 gfx::Insets(0, kButtonHEdgeMargin, |
| 387 kButtonVEdgeMargin, kButtonHEdgeMargin); | 382 kButtonVEdgeMargin, kButtonHEdgeMargin); |
| 388 } | 383 } |
| 389 | 384 |
| 390 void DialogClientView::Close() { | 385 void DialogClientView::Close() { |
| 391 GetWidget()->Close(); | 386 GetWidget()->Close(); |
| 392 GetDialogDelegate()->OnClose(); | 387 GetDialogDelegate()->OnClose(); |
| 393 } | 388 } |
| 394 | 389 |
| 395 } // namespace views | 390 } // namespace views |
| OLD | NEW |