OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/confirm_message_box_dialog.h" | 5 #include "chrome/browser/views/confirm_message_box_dialog.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
| 9 #include "base/utf_string_conversions.h" |
9 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
10 #include "grit/locale_settings.h" | 11 #include "grit/locale_settings.h" |
11 #include "views/standard_layout.h" | 12 #include "views/standard_layout.h" |
12 #include "views/widget/widget.h" | 13 #include "views/widget/widget.h" |
13 #include "views/window/window.h" | 14 #include "views/window/window.h" |
14 | 15 |
15 // static | 16 // static |
16 void ConfirmMessageBoxDialog::Run(gfx::NativeWindow parent, | 17 void ConfirmMessageBoxDialog::Run(gfx::NativeWindow parent, |
17 ConfirmMessageBoxObserver* observer, | 18 ConfirmMessageBoxObserver* observer, |
18 const std::wstring& message_text, | 19 const std::wstring& message_text, |
(...skipping 27 matching lines...) Expand all Loading... |
46 } | 47 } |
47 | 48 |
48 ConfirmMessageBoxDialog::ConfirmMessageBoxDialog( | 49 ConfirmMessageBoxDialog::ConfirmMessageBoxDialog( |
49 ConfirmMessageBoxObserver* observer, const std::wstring& message_text, | 50 ConfirmMessageBoxObserver* observer, const std::wstring& message_text, |
50 const std::wstring& window_title) | 51 const std::wstring& window_title) |
51 : observer_(observer), | 52 : observer_(observer), |
52 window_title_(window_title), | 53 window_title_(window_title), |
53 preferred_size_(gfx::Size(views::Window::GetLocalizedContentsSize( | 54 preferred_size_(gfx::Size(views::Window::GetLocalizedContentsSize( |
54 IDS_CONFIRM_MESSAGE_BOX_DEFAULT_WIDTH_CHARS, | 55 IDS_CONFIRM_MESSAGE_BOX_DEFAULT_WIDTH_CHARS, |
55 IDS_CONFIRM_MESSAGE_BOX_DEFAULT_HEIGHT_LINES))), | 56 IDS_CONFIRM_MESSAGE_BOX_DEFAULT_HEIGHT_LINES))), |
56 confirm_label_(l10n_util::GetString( | 57 confirm_label_(UTF16ToWide(l10n_util::GetStringUTF16( |
57 IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)), | 58 IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL))), |
58 reject_label_(l10n_util::GetString( | 59 reject_label_(UTF16ToWide(l10n_util::GetStringUTF16( |
59 IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)) { | 60 IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL))) { |
60 message_label_ = new views::Label(message_text); | 61 message_label_ = new views::Label(message_text); |
61 message_label_->SetMultiLine(true); | 62 message_label_->SetMultiLine(true); |
62 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 63 message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
63 AddChildView(message_label_); | 64 AddChildView(message_label_); |
64 } | 65 } |
65 | 66 |
66 int ConfirmMessageBoxDialog::GetDialogButtons() const { | 67 int ConfirmMessageBoxDialog::GetDialogButtons() const { |
67 return MessageBoxFlags::DIALOGBUTTON_OK | | 68 return MessageBoxFlags::DIALOGBUTTON_OK | |
68 MessageBoxFlags::DIALOGBUTTON_CANCEL; | 69 MessageBoxFlags::DIALOGBUTTON_CANCEL; |
69 } | 70 } |
(...skipping 25 matching lines...) Expand all Loading... |
95 void ConfirmMessageBoxDialog::Layout() { | 96 void ConfirmMessageBoxDialog::Layout() { |
96 gfx::Size sz = message_label_->GetPreferredSize(); | 97 gfx::Size sz = message_label_->GetPreferredSize(); |
97 message_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, | 98 message_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, |
98 width() - 2 * kPanelHorizMargin, | 99 width() - 2 * kPanelHorizMargin, |
99 sz.height()); | 100 sz.height()); |
100 } | 101 } |
101 | 102 |
102 gfx::Size ConfirmMessageBoxDialog::GetPreferredSize() { | 103 gfx::Size ConfirmMessageBoxDialog::GetPreferredSize() { |
103 return preferred_size_; | 104 return preferred_size_; |
104 } | 105 } |
OLD | NEW |