| 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 "chrome/app/locales/locale_settings.h" |
| 7 #include "chrome/browser/importer.h" | 8 #include "chrome/browser/importer.h" |
| 8 #include "chrome/browser/standard_layout.h" | 9 #include "chrome/browser/standard_layout.h" |
| 9 #include "chrome/common/l10n_util.h" | 10 #include "chrome/common/l10n_util.h" |
| 10 #include "chrome/views/label.h" | 11 #include "chrome/views/label.h" |
| 12 #include "chrome/views/window.h" |
| 11 | 13 |
| 12 #include "chromium_strings.h" | 14 #include "chromium_strings.h" |
| 13 #include "generated_resources.h" | 15 #include "generated_resources.h" |
| 14 | 16 |
| 15 using ChromeViews::ColumnSet; | 17 using ChromeViews::ColumnSet; |
| 16 using ChromeViews::GridLayout; | 18 using ChromeViews::GridLayout; |
| 17 | 19 |
| 18 // Default size of the dialog window. | 20 // Default size of the dialog window. |
| 19 static const int kDefaultWindowWidth = 320; | 21 static const int kDefaultWindowWidth = 320; |
| 20 static const int kDefaultWindowHeight = 100; | 22 static const int kDefaultWindowHeight = 100; |
| 21 | 23 |
| 22 ImporterLockView::ImporterLockView(ImporterHost* host) | 24 ImporterLockView::ImporterLockView(ImporterHost* host) |
| 23 : description_label_(NULL), | 25 : description_label_(NULL), |
| 24 importer_host_(host) { | 26 importer_host_(host) { |
| 25 description_label_ = new ChromeViews::Label( | 27 description_label_ = new ChromeViews::Label( |
| 26 l10n_util::GetString(IDS_IMPORTER_LOCK_TEXT)); | 28 l10n_util::GetString(IDS_IMPORTER_LOCK_TEXT)); |
| 27 description_label_->SetMultiLine(true); | 29 description_label_->SetMultiLine(true); |
| 28 description_label_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); | 30 description_label_->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); |
| 29 AddChildView(description_label_); | 31 AddChildView(description_label_); |
| 30 } | 32 } |
| 31 | 33 |
| 32 ImporterLockView::~ImporterLockView() { | 34 ImporterLockView::~ImporterLockView() { |
| 33 } | 35 } |
| 34 | 36 |
| 35 void ImporterLockView::GetPreferredSize(CSize *out) { | 37 void ImporterLockView::GetPreferredSize(CSize *out) { |
| 36 out->cx = kDefaultWindowWidth; | 38 DCHECK(out); |
| 37 out->cy = kDefaultWindowHeight; | 39 *out = ChromeViews::Window::GetLocalizedContentsSize( |
| 40 IDS_IMPORTLOCK_DIALOG_WIDTH_CHARS, |
| 41 IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES).ToSIZE(); |
| 38 } | 42 } |
| 39 | 43 |
| 40 void ImporterLockView::Layout() { | 44 void ImporterLockView::Layout() { |
| 41 description_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, | 45 description_label_->SetBounds(kPanelHorizMargin, kPanelVertMargin, |
| 42 kDefaultWindowWidth - 2 * kPanelHorizMargin, | 46 GetWidth() - 2 * kPanelHorizMargin, |
| 43 kDefaultWindowHeight - 2 * kPanelVertMargin); | 47 GetHeight() - 2 * kPanelVertMargin); |
| 44 } | 48 } |
| 45 | 49 |
| 46 std::wstring ImporterLockView::GetDialogButtonLabel( | 50 std::wstring ImporterLockView::GetDialogButtonLabel( |
| 47 DialogButton button) const { | 51 DialogButton button) const { |
| 48 if (button == DIALOGBUTTON_OK) { | 52 if (button == DIALOGBUTTON_OK) { |
| 49 return l10n_util::GetString(IDS_IMPORTER_LOCK_OK); | 53 return l10n_util::GetString(IDS_IMPORTER_LOCK_OK); |
| 50 } else if (button == DIALOGBUTTON_CANCEL) { | 54 } else if (button == DIALOGBUTTON_CANCEL) { |
| 51 return l10n_util::GetString(IDS_IMPORTER_LOCK_CANCEL); | 55 return l10n_util::GetString(IDS_IMPORTER_LOCK_CANCEL); |
| 52 } | 56 } |
| 53 return std::wstring(); | 57 return std::wstring(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 bool ImporterLockView::Cancel() { | 74 bool ImporterLockView::Cancel() { |
| 71 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 75 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
| 72 importer_host_, &ImporterHost::OnLockViewEnd, false)); | 76 importer_host_, &ImporterHost::OnLockViewEnd, false)); |
| 73 return true; | 77 return true; |
| 74 } | 78 } |
| 75 | 79 |
| 76 ChromeViews::View* ImporterLockView::GetContentsView() { | 80 ChromeViews::View* ImporterLockView::GetContentsView() { |
| 77 return this; | 81 return this; |
| 78 } | 82 } |
| 79 | 83 |
| OLD | NEW |