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

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

Issue 10446010: wip: Add ui::EventType parameter. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wip - views_unittests Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/focus/focus_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 bool is_default_button = 124 bool is_default_button =
125 (dd->GetDefaultDialogButton() & ui::DIALOG_BUTTON_OK) != 0; 125 (dd->GetDefaultDialogButton() & ui::DIALOG_BUTTON_OK) != 0;
126 ok_button_ = new DialogButton(this, 126 ok_button_ = new DialogButton(this,
127 GetWidget(), 127 GetWidget(),
128 ui::DIALOG_BUTTON_OK, 128 ui::DIALOG_BUTTON_OK,
129 label, 129 label,
130 is_default_button); 130 is_default_button);
131 ok_button_->SetGroup(kButtonGroup); 131 ok_button_->SetGroup(kButtonGroup);
132 if (is_default_button) 132 if (is_default_button)
133 default_button_ = ok_button_; 133 default_button_ = ok_button_;
134 if (!(buttons & ui::DIALOG_BUTTON_CANCEL)) 134 if (!(buttons & ui::DIALOG_BUTTON_CANCEL)) {
135 ok_button_->AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); 135 ok_button_->AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE,
136 ui::EF_NONE,
137 ui::ET_KEY_PRESSED));
138 }
136 AddChildView(ok_button_); 139 AddChildView(ok_button_);
137 } 140 }
138 if (buttons & ui::DIALOG_BUTTON_CANCEL && !cancel_button_) { 141 if (buttons & ui::DIALOG_BUTTON_CANCEL && !cancel_button_) {
139 string16 label = 142 string16 label =
140 dd->GetDialogButtonLabel(ui::DIALOG_BUTTON_CANCEL); 143 dd->GetDialogButtonLabel(ui::DIALOG_BUTTON_CANCEL);
141 if (label.empty()) { 144 if (label.empty()) {
142 if (buttons & ui::DIALOG_BUTTON_OK) { 145 if (buttons & ui::DIALOG_BUTTON_OK) {
143 label = l10n_util::GetStringUTF16(IDS_APP_CANCEL); 146 label = l10n_util::GetStringUTF16(IDS_APP_CANCEL);
144 } else { 147 } else {
145 label = l10n_util::GetStringUTF16(IDS_APP_CLOSE); 148 label = l10n_util::GetStringUTF16(IDS_APP_CLOSE);
146 } 149 }
147 } 150 }
148 bool is_default_button = 151 bool is_default_button =
149 (dd->GetDefaultDialogButton() & ui::DIALOG_BUTTON_CANCEL) 152 (dd->GetDefaultDialogButton() & ui::DIALOG_BUTTON_CANCEL)
150 != 0; 153 != 0;
151 cancel_button_ = new DialogButton(this, 154 cancel_button_ = new DialogButton(this,
152 GetWidget(), 155 GetWidget(),
153 ui::DIALOG_BUTTON_CANCEL, 156 ui::DIALOG_BUTTON_CANCEL,
154 label, 157 label,
155 is_default_button); 158 is_default_button);
156 cancel_button_->SetGroup(kButtonGroup); 159 cancel_button_->SetGroup(kButtonGroup);
157 cancel_button_->AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 160 cancel_button_->AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE,
158 ui::EF_NONE)); 161 ui::EF_NONE,
162 ui::ET_KEY_PRESSED));
159 if (is_default_button) 163 if (is_default_button)
160 default_button_ = ok_button_; 164 default_button_ = ok_button_;
161 AddChildView(cancel_button_); 165 AddChildView(cancel_button_);
162 } 166 }
163 if (!buttons) { 167 if (!buttons) {
164 // Register the escape key as an accelerator which will close the window 168 // Register the escape key as an accelerator which will close the window
165 // if there are no dialog buttons. 169 // if there are no dialog buttons.
166 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); 170 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE,
171 ui::EF_NONE,
172 ui::ET_KEY_PRESSED));
167 } 173 }
168 } 174 }
169 175
170 void DialogClientView::SetDefaultButton(NativeTextButton* new_default_button) { 176 void DialogClientView::SetDefaultButton(NativeTextButton* new_default_button) {
171 if (default_button_ && default_button_ != new_default_button) { 177 if (default_button_ && default_button_ != new_default_button) {
172 default_button_->SetIsDefault(false); 178 default_button_->SetIsDefault(false);
173 default_button_ = NULL; 179 default_button_ = NULL;
174 } 180 }
175 181
176 if (new_default_button) { 182 if (new_default_button) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 529 }
524 saved_focus_manager_ = focus_manager; 530 saved_focus_manager_ = focus_manager;
525 // Listen for focus change events so we can update the default button. 531 // Listen for focus change events so we can update the default button.
526 if (focus_manager) { 532 if (focus_manager) {
527 focus_manager->AddFocusChangeListener(this); 533 focus_manager->AddFocusChangeListener(this);
528 listening_to_focus_ = true; 534 listening_to_focus_ = true;
529 } 535 }
530 } 536 }
531 537
532 } // namespace views 538 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/focus/focus_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698