Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1539)

Side by Side Diff: chrome/browser/ui/views/device_chooser_content_view.cc

Issue 2654323002: harmony: convert device chooser (Closed)
Patch Set: fix dialog width Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 29 matching lines...) Expand all
40 40
41 DeviceChooserContentView::DeviceChooserContentView( 41 DeviceChooserContentView::DeviceChooserContentView(
42 views::TableViewObserver* table_view_observer, 42 views::TableViewObserver* table_view_observer,
43 std::unique_ptr<ChooserController> chooser_controller) 43 std::unique_ptr<ChooserController> chooser_controller)
44 : chooser_controller_(std::move(chooser_controller)), 44 : chooser_controller_(std::move(chooser_controller)),
45 help_text_(l10n_util::GetStringFUTF16( 45 help_text_(l10n_util::GetStringFUTF16(
46 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_SCANNING_STATUS, 46 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_SCANNING_STATUS,
47 base::string16())), 47 base::string16())),
48 help_and_scanning_text_(l10n_util::GetStringFUTF16( 48 help_and_scanning_text_(l10n_util::GetStringFUTF16(
49 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_SCANNING_STATUS, 49 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_SCANNING_STATUS,
50 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING))) { 50 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING))),
51 preferred_size_(kChooserWidth, kChooserHeight) {
51 base::string16 re_scan_text = 52 base::string16 re_scan_text =
52 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN); 53 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN);
53 std::vector<size_t> offsets; 54 std::vector<size_t> offsets;
54 help_and_re_scan_text_ = l10n_util::GetStringFUTF16( 55 help_and_re_scan_text_ = l10n_util::GetStringFUTF16(
55 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_RE_SCAN_LINK, help_text_, 56 IDS_DEVICE_CHOOSER_GET_HELP_LINK_WITH_RE_SCAN_LINK, help_text_,
56 re_scan_text, &offsets); 57 re_scan_text, &offsets);
57 help_text_range_ = gfx::Range(offsets[0], offsets[0] + help_text_.size()); 58 help_text_range_ = gfx::Range(offsets[0], offsets[0] + help_text_.size());
58 re_scan_text_range_ = 59 re_scan_text_range_ =
59 gfx::Range(offsets[1], offsets[1] + re_scan_text.size()); 60 gfx::Range(offsets[1], offsets[1] + re_scan_text.size());
60 chooser_controller_->set_view(this); 61 chooser_controller_->set_view(this);
(...skipping 27 matching lines...) Expand all
88 turn_adapter_off_help_->SetVisible(false); 89 turn_adapter_off_help_->SetVisible(false);
89 AddChildView(turn_adapter_off_help_); 90 AddChildView(turn_adapter_off_help_);
90 } 91 }
91 92
92 DeviceChooserContentView::~DeviceChooserContentView() { 93 DeviceChooserContentView::~DeviceChooserContentView() {
93 chooser_controller_->set_view(nullptr); 94 chooser_controller_->set_view(nullptr);
94 table_view_->set_observer(nullptr); 95 table_view_->set_observer(nullptr);
95 table_view_->SetModel(nullptr); 96 table_view_->SetModel(nullptr);
96 } 97 }
97 98
99 void DeviceChooserContentView::SetPreferredSize(gfx::Size size) {
100 preferred_size_ = size;
101 }
102
98 gfx::Size DeviceChooserContentView::GetPreferredSize() const { 103 gfx::Size DeviceChooserContentView::GetPreferredSize() const {
99 return gfx::Size(kChooserWidth, kChooserHeight); 104 return preferred_size_;
100 } 105 }
101 106
102 void DeviceChooserContentView::Layout() { 107 void DeviceChooserContentView::Layout() {
103 gfx::Rect rect(GetContentsBounds()); 108 gfx::Rect rect(GetContentsBounds());
104 table_parent_->SetBoundsRect(rect); 109 table_parent_->SetBoundsRect(rect);
105 // Set the throbber in the center of the chooser. 110 // Set the throbber in the center of the chooser.
106 throbber_->SetBounds((rect.width() - kThrobberDiameter) / 2, 111 throbber_->SetBounds((rect.width() - kThrobberDiameter) / 2,
107 (rect.height() - kThrobberDiameter) / 2, 112 (rect.height() - kThrobberDiameter) / 2,
108 kThrobberDiameter, kThrobberDiameter); 113 kThrobberDiameter, kThrobberDiameter);
109 // Set the adapter off message in the center of the chooser. 114 // Set the adapter off message in the center of the chooser.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 327 }
323 328
324 void DeviceChooserContentView::SetGetHelpAndReScanLink() { 329 void DeviceChooserContentView::SetGetHelpAndReScanLink() {
325 DCHECK(footnote_link_); 330 DCHECK(footnote_link_);
326 footnote_link_->SetText(help_and_re_scan_text_); 331 footnote_link_->SetText(help_and_re_scan_text_);
327 footnote_link_->AddStyleRange( 332 footnote_link_->AddStyleRange(
328 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 333 help_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
329 footnote_link_->AddStyleRange( 334 footnote_link_->AddStyleRange(
330 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink()); 335 re_scan_text_range_, views::StyledLabel::RangeStyleInfo::CreateForLink());
331 } 336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698