OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/device_chooser_content_view.h" | 5 #include "chrome/browser/ui/views/device_chooser_content_view.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
9 #include "chrome/app/vector_icons/vector_icons.h" | 9 #include "chrome/app/vector_icons/vector_icons.h" |
| 10 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
10 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
11 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
12 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/gfx/color_palette.h" | 14 #include "ui/gfx/color_palette.h" |
14 #include "ui/gfx/geometry/point.h" | 15 #include "ui/gfx/geometry/point.h" |
15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
17 #include "ui/gfx/paint_vector_icon.h" | 18 #include "ui/gfx/paint_vector_icon.h" |
18 #include "ui/resources/grit/ui_resources.h" | 19 #include "ui/resources/grit/ui_resources.h" |
19 #include "ui/views/controls/styled_label.h" | 20 #include "ui/views/controls/styled_label.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // and in that case, the system won't be able to scan for devices, so | 104 // and in that case, the system won't be able to scan for devices, so |
104 // the throbber won't be shown at the same time. | 105 // the throbber won't be shown at the same time. |
105 turn_adapter_off_help_->SetPosition( | 106 turn_adapter_off_help_->SetPosition( |
106 gfx::Point((rect.width() - turn_adapter_off_help_->width()) / 2, | 107 gfx::Point((rect.width() - turn_adapter_off_help_->width()) / 2, |
107 (rect.height() - turn_adapter_off_help_->height()) / 2)); | 108 (rect.height() - turn_adapter_off_help_->height()) / 2)); |
108 turn_adapter_off_help_->SizeToFit(rect.width() - | 109 turn_adapter_off_help_->SizeToFit(rect.width() - |
109 2 * kAdapterOffHelpLinkPadding); | 110 2 * kAdapterOffHelpLinkPadding); |
110 views::View::Layout(); | 111 views::View::Layout(); |
111 } | 112 } |
112 | 113 |
| 114 gfx::Size DeviceChooserContentView::GetPreferredSize() const { |
| 115 constexpr int kHeight = 320; |
| 116 constexpr int kDefaultWidth = 402; |
| 117 int width = LayoutDelegate::Get()->GetDialogPreferredWidth( |
| 118 LayoutDelegate::DialogWidth::MEDIUM); |
| 119 if (!width) |
| 120 width = kDefaultWidth; |
| 121 return gfx::Size(width, kHeight); |
| 122 } |
| 123 |
113 int DeviceChooserContentView::RowCount() { | 124 int DeviceChooserContentView::RowCount() { |
114 // When there are no devices, the table contains a message saying there | 125 // When there are no devices, the table contains a message saying there |
115 // are no devices, so the number of rows is always at least 1. | 126 // are no devices, so the number of rows is always at least 1. |
116 return std::max(base::checked_cast<int>(chooser_controller_->NumOptions()), | 127 return std::max(base::checked_cast<int>(chooser_controller_->NumOptions()), |
117 1); | 128 1); |
118 } | 129 } |
119 | 130 |
120 base::string16 DeviceChooserContentView::GetText(int row, int column_id) { | 131 base::string16 DeviceChooserContentView::GetText(int row, int column_id) { |
121 int num_options = base::checked_cast<int>(chooser_controller_->NumOptions()); | 132 int num_options = base::checked_cast<int>(chooser_controller_->NumOptions()); |
122 if (num_options == 0) { | 133 if (num_options == 0) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 325 } |
315 | 326 |
316 void DeviceChooserContentView::SetGetHelpAndReScanLink() { | 327 void DeviceChooserContentView::SetGetHelpAndReScanLink() { |
317 DCHECK(footnote_link_); | 328 DCHECK(footnote_link_); |
318 footnote_link_->SetText(help_and_re_scan_text_); | 329 footnote_link_->SetText(help_and_re_scan_text_); |
319 footnote_link_->AddStyleRange( | 330 footnote_link_->AddStyleRange( |
320 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); | 331 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); |
321 footnote_link_->AddStyleRange( | 332 footnote_link_->AddStyleRange( |
322 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); | 333 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); |
323 } | 334 } |
OLD | NEW |