OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/importer_lock_view.h" | 5 #include "chrome/browser/views/importer_lock_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/importer/importer.h" | 10 #include "chrome/browser/importer/importer.h" |
10 #include "grit/chromium_strings.h" | 11 #include "grit/chromium_strings.h" |
11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
12 #include "grit/locale_settings.h" | 13 #include "grit/locale_settings.h" |
13 #include "views/controls/label.h" | 14 #include "views/controls/label.h" |
14 #include "views/standard_layout.h" | 15 #include "views/standard_layout.h" |
15 #include "views/window/window.h" | 16 #include "views/window/window.h" |
16 | 17 |
17 // Default size of the dialog window. | 18 // Default size of the dialog window. |
18 static const int kDefaultWindowWidth = 320; | 19 static const int kDefaultWindowWidth = 320; |
19 static const int kDefaultWindowHeight = 100; | 20 static const int kDefaultWindowHeight = 100; |
20 | 21 |
21 ImporterLockView::ImporterLockView(ImporterHost* host) | 22 ImporterLockView::ImporterLockView(ImporterHost* host) |
22 : description_label_(NULL), | 23 : description_label_(NULL), |
23 importer_host_(host) { | 24 importer_host_(host) { |
24 description_label_ = new views::Label( | 25 description_label_ = new views::Label( |
25 l10n_util::GetString(IDS_IMPORTER_LOCK_TEXT)); | 26 UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_TEXT))); |
26 description_label_->SetMultiLine(true); | 27 description_label_->SetMultiLine(true); |
27 description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 28 description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
28 AddChildView(description_label_); | 29 AddChildView(description_label_); |
29 } | 30 } |
30 | 31 |
31 ImporterLockView::~ImporterLockView() { | 32 ImporterLockView::~ImporterLockView() { |
32 } | 33 } |
33 | 34 |
34 gfx::Size ImporterLockView::GetPreferredSize() { | 35 gfx::Size ImporterLockView::GetPreferredSize() { |
35 return gfx::Size(views::Window::GetLocalizedContentsSize( | 36 return gfx::Size(views::Window::GetLocalizedContentsSize( |
36 IDS_IMPORTLOCK_DIALOG_WIDTH_CHARS, | 37 IDS_IMPORTLOCK_DIALOG_WIDTH_CHARS, |
37 IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES)); | 38 IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES)); |
38 } | 39 } |
39 | 40 |
40 void ImporterLockView::Layout() { | 41 void ImporterLockView::Layout() { |
41 description_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, | 42 description_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, |
42 width() - 2 * kPanelHorizMargin, | 43 width() - 2 * kPanelHorizMargin, |
43 height() - 2 * kPanelVertMargin); | 44 height() - 2 * kPanelVertMargin); |
44 } | 45 } |
45 | 46 |
46 std::wstring ImporterLockView::GetDialogButtonLabel( | 47 std::wstring ImporterLockView::GetDialogButtonLabel( |
47 MessageBoxFlags::DialogButton button) const { | 48 MessageBoxFlags::DialogButton button) const { |
48 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 49 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { |
49 return l10n_util::GetString(IDS_IMPORTER_LOCK_OK); | 50 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_OK)); |
50 } else if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) { | 51 } else if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) { |
51 return l10n_util::GetString(IDS_IMPORTER_LOCK_CANCEL); | 52 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_CANCEL)); |
52 } | 53 } |
53 return std::wstring(); | 54 return std::wstring(); |
54 } | 55 } |
55 | 56 |
56 bool ImporterLockView::IsModal() const { | 57 bool ImporterLockView::IsModal() const { |
57 return false; | 58 return false; |
58 } | 59 } |
59 | 60 |
60 std::wstring ImporterLockView::GetWindowTitle() const { | 61 std::wstring ImporterLockView::GetWindowTitle() const { |
61 return l10n_util::GetString(IDS_IMPORTER_LOCK_TITLE); | 62 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_TITLE)); |
62 } | 63 } |
63 | 64 |
64 bool ImporterLockView::Accept() { | 65 bool ImporterLockView::Accept() { |
65 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 66 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
66 importer_host_, &ImporterHost::OnLockViewEnd, true)); | 67 importer_host_, &ImporterHost::OnLockViewEnd, true)); |
67 return true; | 68 return true; |
68 } | 69 } |
69 | 70 |
70 bool ImporterLockView::Cancel() { | 71 bool ImporterLockView::Cancel() { |
71 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 72 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
72 importer_host_, &ImporterHost::OnLockViewEnd, false)); | 73 importer_host_, &ImporterHost::OnLockViewEnd, false)); |
73 return true; | 74 return true; |
74 } | 75 } |
75 | 76 |
76 views::View* ImporterLockView::GetContentsView() { | 77 views::View* ImporterLockView::GetContentsView() { |
77 return this; | 78 return this; |
78 } | 79 } |
OLD | NEW |