OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/webshare/webshare_target_picker_view.h" | 5 #include "chrome/browser/ui/views/webshare/webshare_target_picker_view.h" |
6 | 6 |
7 #include "chrome/grit/generated_resources.h" | 7 #include "chrome/grit/generated_resources.h" |
8 #include "components/constrained_window/constrained_window_views.h" | 8 #include "components/constrained_window/constrained_window_views.h" |
9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 views::BoxLayout* layout = new views::BoxLayout( | 40 views::BoxLayout* layout = new views::BoxLayout( |
41 views::BoxLayout::kVertical, views::kPanelHorizMargin, | 41 views::BoxLayout::kVertical, views::kPanelHorizMargin, |
42 views::kPanelVertMargin, views::kRelatedControlVerticalSpacing); | 42 views::kPanelVertMargin, views::kRelatedControlVerticalSpacing); |
43 SetLayoutManager(layout); | 43 SetLayoutManager(layout); |
44 | 44 |
45 views::Label* overview_label = new views::Label( | 45 views::Label* overview_label = new views::Label( |
46 l10n_util::GetStringUTF16(IDS_WEBSHARE_TARGET_PICKER_LABEL)); | 46 l10n_util::GetStringUTF16(IDS_WEBSHARE_TARGET_PICKER_LABEL)); |
47 AddChildView(overview_label); | 47 AddChildView(overview_label); |
48 | 48 |
49 std::vector<ui::TableColumn> table_columns{ui::TableColumn()}; | 49 std::vector<ui::TableColumn> table_columns{ui::TableColumn()}; |
50 views::TableView* table = | 50 table_ = new views::TableView(this, table_columns, views::TEXT_ONLY, true); |
sky
2017/02/06 17:11:24
To avoid errors please initialize table_ to null i
Matt Giuca
2017/02/06 23:17:21
Done (in the .h file).
| |
51 new views::TableView(this, table_columns, views::TEXT_ONLY, true); | |
52 // Select the first row. | 51 // Select the first row. |
53 if (RowCount() > 0) | 52 if (RowCount() > 0) |
54 table->Select(0); | 53 table_->Select(0); |
55 | 54 |
56 // Create the table parent (a ScrollView which includes the scroll bars and | 55 // Create the table parent (a ScrollView which includes the scroll bars and |
57 // border). We add this parent (not the table itself) to the dialog. | 56 // border). We add this parent (not the table itself) to the dialog. |
58 views::View* table_parent = table->CreateParentIfNecessary(); | 57 views::View* table_parent = table_->CreateParentIfNecessary(); |
59 AddChildView(table_parent); | 58 AddChildView(table_parent); |
60 // Make the table expand to fill the space. | 59 // Make the table expand to fill the space. |
61 layout->SetFlexForView(table_parent, 1); | 60 layout->SetFlexForView(table_parent, 1); |
62 } | 61 } |
63 | 62 |
64 WebShareTargetPickerView::~WebShareTargetPickerView() {} | 63 WebShareTargetPickerView::~WebShareTargetPickerView() {} |
65 | 64 |
66 gfx::Size WebShareTargetPickerView::GetPreferredSize() const { | 65 gfx::Size WebShareTargetPickerView::GetPreferredSize() const { |
67 return gfx::Size(kDialogWidth, kDialogHeight); | 66 return gfx::Size(kDialogWidth, kDialogHeight); |
68 } | 67 } |
(...skipping 30 matching lines...) Expand all Loading... | |
99 | 98 |
100 int WebShareTargetPickerView::RowCount() { | 99 int WebShareTargetPickerView::RowCount() { |
101 return targets_.size(); | 100 return targets_.size(); |
102 } | 101 } |
103 | 102 |
104 base::string16 WebShareTargetPickerView::GetText(int row, int /*column_id*/) { | 103 base::string16 WebShareTargetPickerView::GetText(int row, int /*column_id*/) { |
105 return targets_[row]; | 104 return targets_[row]; |
106 } | 105 } |
107 | 106 |
108 void WebShareTargetPickerView::SetObserver(ui::TableModelObserver* observer) {} | 107 void WebShareTargetPickerView::SetObserver(ui::TableModelObserver* observer) {} |
OLD | NEW |