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 "chrome/browser/ui/views/importer/import_lock_dialog_view.h" | 5 #include "chrome/browser/ui/views/importer/import_lock_dialog_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/metrics/user_metrics.h" | 9 #include "base/metrics/user_metrics.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "chrome/browser/importer/importer_lock_dialog.h" | 13 #include "chrome/browser/importer/importer_lock_dialog.h" |
14 #include "chrome/browser/ui/browser_dialogs.h" | 14 #include "chrome/browser/ui/browser_dialogs.h" |
15 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 15 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
16 #include "chrome/grit/chromium_strings.h" | 16 #include "chrome/grit/chromium_strings.h" |
17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
18 #include "chrome/grit/locale_settings.h" | 18 #include "chrome/grit/locale_settings.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
21 #include "ui/views/layout/layout_constants.h" | |
22 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
23 | 22 |
24 using base::UserMetricsAction; | 23 using base::UserMetricsAction; |
25 | 24 |
26 namespace importer { | 25 namespace importer { |
27 | 26 |
28 void ShowImportLockDialog(gfx::NativeWindow parent, | 27 void ShowImportLockDialog(gfx::NativeWindow parent, |
29 const base::Callback<void(bool)>& callback) { | 28 const base::Callback<void(bool)>& callback) { |
30 ImportLockDialogView::Show(parent, callback); | 29 ImportLockDialogView::Show(parent, callback); |
31 base::RecordAction(UserMetricsAction("ImportLockDialogView_Shown")); | 30 base::RecordAction(UserMetricsAction("ImportLockDialogView_Shown")); |
(...skipping 24 matching lines...) Expand all Loading... |
56 } | 55 } |
57 | 56 |
58 gfx::Size ImportLockDialogView::GetPreferredSize() const { | 57 gfx::Size ImportLockDialogView::GetPreferredSize() const { |
59 return gfx::Size(views::Widget::GetLocalizedContentsSize( | 58 return gfx::Size(views::Widget::GetLocalizedContentsSize( |
60 IDS_IMPORTLOCK_DIALOG_WIDTH_CHARS, | 59 IDS_IMPORTLOCK_DIALOG_WIDTH_CHARS, |
61 IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES)); | 60 IDS_IMPORTLOCK_DIALOG_HEIGHT_LINES)); |
62 } | 61 } |
63 | 62 |
64 void ImportLockDialogView::Layout() { | 63 void ImportLockDialogView::Layout() { |
65 gfx::Rect bounds(GetLocalBounds()); | 64 gfx::Rect bounds(GetLocalBounds()); |
66 bounds.Inset(views::kButtonHEdgeMarginNew, | 65 const ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
67 ChromeLayoutProvider::Get()->GetDistanceMetric( | 66 bounds.Inset(provider->GetDistanceMetric( |
68 DISTANCE_PANEL_CONTENT_MARGIN)); | 67 views::DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN), |
| 68 provider->GetDistanceMetric( |
| 69 views::DISTANCE_DIALOG_CONTENTS_VERTICAL_MARGIN)); |
69 description_label_->SetBoundsRect(bounds); | 70 description_label_->SetBoundsRect(bounds); |
70 } | 71 } |
71 | 72 |
72 base::string16 ImportLockDialogView::GetDialogButtonLabel( | 73 base::string16 ImportLockDialogView::GetDialogButtonLabel( |
73 ui::DialogButton button) const { | 74 ui::DialogButton button) const { |
74 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? | 75 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? |
75 IDS_IMPORTER_LOCK_OK : IDS_IMPORTER_LOCK_CANCEL); | 76 IDS_IMPORTER_LOCK_OK : IDS_IMPORTER_LOCK_CANCEL); |
76 } | 77 } |
77 | 78 |
78 base::string16 ImportLockDialogView::GetWindowTitle() const { | 79 base::string16 ImportLockDialogView::GetWindowTitle() const { |
79 return l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_TITLE); | 80 return l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_TITLE); |
80 } | 81 } |
81 | 82 |
82 bool ImportLockDialogView::Accept() { | 83 bool ImportLockDialogView::Accept() { |
83 base::ThreadTaskRunnerHandle::Get()->PostTask( | 84 base::ThreadTaskRunnerHandle::Get()->PostTask( |
84 FROM_HERE, base::BindOnce(callback_, true)); | 85 FROM_HERE, base::BindOnce(callback_, true)); |
85 return true; | 86 return true; |
86 } | 87 } |
87 | 88 |
88 bool ImportLockDialogView::Cancel() { | 89 bool ImportLockDialogView::Cancel() { |
89 base::ThreadTaskRunnerHandle::Get()->PostTask( | 90 base::ThreadTaskRunnerHandle::Get()->PostTask( |
90 FROM_HERE, base::BindOnce(callback_, false)); | 91 FROM_HERE, base::BindOnce(callback_, false)); |
91 return true; | 92 return true; |
92 } | 93 } |
OLD | NEW |