OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/content_setting_bubble_contents.h" | 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 set_anchor_view_insets(gfx::Insets( | 177 set_anchor_view_insets(gfx::Insets( |
178 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 178 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
179 } | 179 } |
180 | 180 |
181 ContentSettingBubbleContents::~ContentSettingBubbleContents() { | 181 ContentSettingBubbleContents::~ContentSettingBubbleContents() { |
182 // Must remove the children here so the comboboxes get destroyed before | 182 // Must remove the children here so the comboboxes get destroyed before |
183 // their associated models. | 183 // their associated models. |
184 RemoveAllChildViews(true); | 184 RemoveAllChildViews(true); |
185 } | 185 } |
186 | 186 |
187 gfx::Size ContentSettingBubbleContents::GetPreferredSize() const { | 187 gfx::Size ContentSettingBubbleContents::GetUnsnappedPreferredSize() const { |
188 gfx::Size preferred_size(views::View::GetPreferredSize()); | 188 gfx::Size preferred_size(views::View::GetPreferredSize()); |
189 int preferred_width = LayoutDelegate::Get()->GetDialogPreferredWidth( | 189 int preferred_width = |
190 LayoutDelegate::DialogWidth::SMALL); | 190 (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && |
191 if (!preferred_width) | 191 (kMinMultiLineContentsWidth > preferred_size.width())) |
192 preferred_width = (!content_setting_bubble_model_->bubble_content() | 192 ? kMinMultiLineContentsWidth |
193 .domain_lists.empty() && | 193 : preferred_size.width(); |
194 (kMinMultiLineContentsWidth > preferred_size.width())) | |
195 ? kMinMultiLineContentsWidth | |
196 : preferred_size.width(); | |
197 else | |
198 preferred_width -= margins().width(); | |
199 if (content_setting_bubble_model_->AsSubresourceFilterBubbleModel()) { | 194 if (content_setting_bubble_model_->AsSubresourceFilterBubbleModel()) { |
200 preferred_size.set_width(std::min(preferred_width, | 195 preferred_size.set_width(std::min(preferred_width, |
201 kMaxDefaultContentsWidth)); | 196 kMaxDefaultContentsWidth)); |
202 } else { | 197 } else { |
203 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); | 198 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); |
204 } | 199 } |
Peter Kasting
2017/03/30 00:35:34
Ugh. This is all a mess. Can you add a TODO here
| |
205 return preferred_size; | 200 return preferred_size; |
206 } | 201 } |
207 | 202 |
208 void ContentSettingBubbleContents::Init() { | 203 void ContentSettingBubbleContents::Init() { |
209 using views::GridLayout; | 204 using views::GridLayout; |
210 | 205 |
211 GridLayout* layout = new views::GridLayout(this); | 206 GridLayout* layout = new views::GridLayout(this); |
212 SetLayoutManager(layout); | 207 SetLayoutManager(layout); |
213 const LayoutDelegate* layout_delegate = LayoutDelegate::Get(); | 208 const LayoutDelegate* layout_delegate = LayoutDelegate::Get(); |
214 const int related_control_horizontal_spacing = layout_delegate->GetMetric( | 209 const int related_control_horizontal_spacing = layout_delegate->GetMetric( |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 DCHECK(i != list_item_links_.end()); | 502 DCHECK(i != list_item_links_.end()); |
508 content_setting_bubble_model_->OnListItemClicked(i->second); | 503 content_setting_bubble_model_->OnListItemClicked(i->second); |
509 } | 504 } |
510 | 505 |
511 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { | 506 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { |
512 MediaComboboxModel* model = | 507 MediaComboboxModel* model = |
513 static_cast<MediaComboboxModel*>(combobox->model()); | 508 static_cast<MediaComboboxModel*>(combobox->model()); |
514 content_setting_bubble_model_->OnMediaMenuClicked( | 509 content_setting_bubble_model_->OnMediaMenuClicked( |
515 model->type(), model->GetDevices()[combobox->selected_index()].id); | 510 model->type(), model->GetDevices()[combobox->selected_index()].id); |
516 } | 511 } |
OLD | NEW |