| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser_dialogs.h" |
| 8 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 9 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 9 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| 10 #include "components/constrained_window/constrained_window_views.h" | 11 #include "components/constrained_window/constrained_window_views.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/base/models/table_model.h" | 13 #include "ui/base/models/table_model.h" |
| 13 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 14 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
| 15 #include "ui/views/controls/table/table_view.h" | 16 #include "ui/views/controls/table/table_view.h" |
| 16 #include "ui/views/layout/box_layout.h" | 17 #include "ui/views/layout/box_layout.h" |
| 17 #include "ui/views/layout/layout_constants.h" | 18 #include "ui/views/layout/layout_constants.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 table_->Select(0); | 100 table_->Select(0); |
| 100 | 101 |
| 101 table_->set_observer(this); | 102 table_->set_observer(this); |
| 102 | 103 |
| 103 // Create the table parent (a ScrollView which includes the scroll bars and | 104 // Create the table parent (a ScrollView which includes the scroll bars and |
| 104 // border). We add this parent (not the table itself) to the dialog. | 105 // border). We add this parent (not the table itself) to the dialog. |
| 105 views::View* table_parent = table_->CreateParentIfNecessary(); | 106 views::View* table_parent = table_->CreateParentIfNecessary(); |
| 106 AddChildView(table_parent); | 107 AddChildView(table_parent); |
| 107 // Make the table expand to fill the space. | 108 // Make the table expand to fill the space. |
| 108 layout->SetFlexForView(table_parent, 1); | 109 layout->SetFlexForView(table_parent, 1); |
| 110 chrome::RecordDialogCreation( |
| 111 chrome::DialogIdentifier::WEB_SHARE_TARGET_PICKER); |
| 109 } | 112 } |
| 110 | 113 |
| 111 WebShareTargetPickerView::~WebShareTargetPickerView() { | 114 WebShareTargetPickerView::~WebShareTargetPickerView() { |
| 112 // Clear the pointer from |table_| which currently points at |table_model_|. | 115 // Clear the pointer from |table_| which currently points at |table_model_|. |
| 113 // Otherwise, |table_model_| will be deleted before |table_|, and |table_|'s | 116 // Otherwise, |table_model_| will be deleted before |table_|, and |table_|'s |
| 114 // destructor will try to call a method on the model. | 117 // destructor will try to call a method on the model. |
| 115 table_->SetModel(nullptr); | 118 table_->SetModel(nullptr); |
| 116 } | 119 } |
| 117 | 120 |
| 118 gfx::Size WebShareTargetPickerView::GetPreferredSize() const { | 121 gfx::Size WebShareTargetPickerView::GetPreferredSize() const { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 return true; | 164 return true; |
| 162 } | 165 } |
| 163 | 166 |
| 164 void WebShareTargetPickerView::OnSelectionChanged() { | 167 void WebShareTargetPickerView::OnSelectionChanged() { |
| 165 GetDialogClientView()->UpdateDialogButtons(); | 168 GetDialogClientView()->UpdateDialogButtons(); |
| 166 } | 169 } |
| 167 | 170 |
| 168 void WebShareTargetPickerView::OnDoubleClick() { | 171 void WebShareTargetPickerView::OnDoubleClick() { |
| 169 GetDialogClientView()->AcceptWindow(); | 172 GetDialogClientView()->AcceptWindow(); |
| 170 } | 173 } |
| OLD | NEW |