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/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/gfx/color_palette.h" | 13 #include "ui/gfx/color_palette.h" |
14 #include "ui/gfx/geometry/point.h" | 14 #include "ui/gfx/geometry/point.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
17 #include "ui/gfx/paint_vector_icon.h" | 17 #include "ui/gfx/paint_vector_icon.h" |
18 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
19 #include "ui/views/controls/styled_label.h" | 19 #include "ui/views/controls/styled_label.h" |
20 #include "ui/views/controls/table/table_view.h" | 20 #include "ui/views/controls/table/table_view.h" |
21 #include "ui/views/controls/throbber.h" | 21 #include "ui/views/controls/throbber.h" |
22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 const int kChooserWidth = 370; | |
27 | |
28 const int kChooserHeight = 260; | |
29 | |
30 const int kThrobberDiameter = 24; | 26 const int kThrobberDiameter = 24; |
31 | 27 |
32 const int kAdapterOffHelpLinkPadding = 5; | 28 const int kAdapterOffHelpLinkPadding = 5; |
33 | 29 |
34 // The lookup table for signal strength level image. | 30 // The lookup table for signal strength level image. |
35 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, | 31 const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR, |
36 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, | 32 IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR, |
37 IDR_SIGNAL_4_BAR}; | 33 IDR_SIGNAL_4_BAR}; |
38 | 34 |
39 } // namespace | 35 } // namespace |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 turn_adapter_off_help_->SetVisible(false); | 84 turn_adapter_off_help_->SetVisible(false); |
89 AddChildView(turn_adapter_off_help_); | 85 AddChildView(turn_adapter_off_help_); |
90 } | 86 } |
91 | 87 |
92 DeviceChooserContentView::~DeviceChooserContentView() { | 88 DeviceChooserContentView::~DeviceChooserContentView() { |
93 chooser_controller_->set_view(nullptr); | 89 chooser_controller_->set_view(nullptr); |
94 table_view_->set_observer(nullptr); | 90 table_view_->set_observer(nullptr); |
95 table_view_->SetModel(nullptr); | 91 table_view_->SetModel(nullptr); |
96 } | 92 } |
97 | 93 |
98 gfx::Size DeviceChooserContentView::GetPreferredSize() const { | |
99 return gfx::Size(kChooserWidth, kChooserHeight); | |
100 } | |
101 | |
102 void DeviceChooserContentView::Layout() { | 94 void DeviceChooserContentView::Layout() { |
103 gfx::Rect rect(GetContentsBounds()); | 95 gfx::Rect rect(GetContentsBounds()); |
104 table_parent_->SetBoundsRect(rect); | 96 table_parent_->SetBoundsRect(rect); |
105 // Set the throbber in the center of the chooser. | 97 // Set the throbber in the center of the chooser. |
106 throbber_->SetBounds((rect.width() - kThrobberDiameter) / 2, | 98 throbber_->SetBounds((rect.width() - kThrobberDiameter) / 2, |
107 (rect.height() - kThrobberDiameter) / 2, | 99 (rect.height() - kThrobberDiameter) / 2, |
108 kThrobberDiameter, kThrobberDiameter); | 100 kThrobberDiameter, kThrobberDiameter); |
109 // Set the adapter off message in the center of the chooser. | 101 // Set the adapter off message in the center of the chooser. |
110 // The adapter off message will only be shown when the adapter is off, | 102 // The adapter off message will only be shown when the adapter is off, |
111 // and in that case, the system won't be able to scan for devices, so | 103 // and in that case, the system won't be able to scan for devices, so |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 314 } |
323 | 315 |
324 void DeviceChooserContentView::SetGetHelpAndReScanLink() { | 316 void DeviceChooserContentView::SetGetHelpAndReScanLink() { |
325 DCHECK(footnote_link_); | 317 DCHECK(footnote_link_); |
326 footnote_link_->SetText(help_and_re_scan_text_); | 318 footnote_link_->SetText(help_and_re_scan_text_); |
327 footnote_link_->AddStyleRange( | 319 footnote_link_->AddStyleRange( |
328 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); | 320 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); |
329 footnote_link_->AddStyleRange( | 321 footnote_link_->AddStyleRange( |
330 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); | 322 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); |
331 } | 323 } |
OLD | NEW |