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 29 matching lines...) Expand all Loading... | |
40 #include "ui/views/controls/menu/menu_runner.h" | 40 #include "ui/views/controls/menu/menu_runner.h" |
41 #include "ui/views/controls/separator.h" | 41 #include "ui/views/controls/separator.h" |
42 #include "ui/views/layout/grid_layout.h" | 42 #include "ui/views/layout/grid_layout.h" |
43 #include "ui/views/layout/layout_constants.h" | 43 #include "ui/views/layout/layout_constants.h" |
44 #include "ui/views/native_cursor.h" | 44 #include "ui/views/native_cursor.h" |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // If we don't clamp the maximum width, then very long URLs and titles can make | 48 // If we don't clamp the maximum width, then very long URLs and titles can make |
49 // the bubble arbitrarily wide. | 49 // the bubble arbitrarily wide. |
50 const int kMaxContentsWidth = 500; | 50 const int kMaxContentsWidth = 500; |
msw
2016/09/15 18:29:03
Should we just change the existing maximum width?
| |
51 | 51 |
52 // When we have multiline labels, we should set a minimum width lest we get very | 52 // When we have multiline labels, we should set a minimum width lest we get very |
53 // narrow bubbles with lots of line-wrapping. | 53 // narrow bubbles with lots of line-wrapping. |
54 const int kMinMultiLineContentsWidth = 250; | 54 const int kMinMultiLineContentsWidth = 250; |
55 | 55 |
56 // Subresource filter bubble has ling explanation string, so the width should be | |
msw
2016/09/15 18:29:03
nit: 'a long' consider: 'Maximum width of the subr
melandory
2016/09/15 19:47:43
Done.
| |
57 // bounded. | |
58 const int kMaxSubresourceFilterPromptWidth = 320; | |
59 | |
56 } // namespace | 60 } // namespace |
57 | 61 |
58 using content::PluginService; | 62 using content::PluginService; |
59 using content::WebContents; | 63 using content::WebContents; |
60 | 64 |
61 // ContentSettingBubbleContents::MediaComboboxModel ---------------------------- | 65 // ContentSettingBubbleContents::MediaComboboxModel ---------------------------- |
62 | 66 |
63 ContentSettingBubbleContents::MediaComboboxModel::MediaComboboxModel( | 67 ContentSettingBubbleContents::MediaComboboxModel::MediaComboboxModel( |
64 content::MediaStreamType type) | 68 content::MediaStreamType type) |
65 : type_(type) { | 69 : type_(type) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 RemoveAllChildViews(true); | 179 RemoveAllChildViews(true); |
176 } | 180 } |
177 | 181 |
178 gfx::Size ContentSettingBubbleContents::GetPreferredSize() const { | 182 gfx::Size ContentSettingBubbleContents::GetPreferredSize() const { |
179 gfx::Size preferred_size(views::View::GetPreferredSize()); | 183 gfx::Size preferred_size(views::View::GetPreferredSize()); |
180 int preferred_width = | 184 int preferred_width = |
181 (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && | 185 (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && |
182 (kMinMultiLineContentsWidth > preferred_size.width())) | 186 (kMinMultiLineContentsWidth > preferred_size.width())) |
183 ? kMinMultiLineContentsWidth | 187 ? kMinMultiLineContentsWidth |
184 : preferred_size.width(); | 188 : preferred_size.width(); |
185 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); | 189 preferred_size.set_width( |
msw
2016/09/15 18:29:03
nit: consider:
preferred_size.set_width(std::min
melandory
2016/09/15 19:47:43
Done.
| |
190 std::min(preferred_width, | |
191 content_setting_bubble_model_->AsSubresourceFilterBubbleModel() | |
192 ? kMaxSubresourceFilterPromptWidth | |
193 : kMaxContentsWidth)); | |
186 return preferred_size; | 194 return preferred_size; |
187 } | 195 } |
188 | 196 |
189 void ContentSettingBubbleContents::Init() { | 197 void ContentSettingBubbleContents::Init() { |
190 using views::GridLayout; | 198 using views::GridLayout; |
191 | 199 |
192 GridLayout* layout = new views::GridLayout(this); | 200 GridLayout* layout = new views::GridLayout(this); |
193 SetLayoutManager(layout); | 201 SetLayoutManager(layout); |
194 | 202 |
195 const int kSingleColumnSetId = 0; | 203 const int kSingleColumnSetId = 0; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 DCHECK(i != list_item_links_.end()); | 468 DCHECK(i != list_item_links_.end()); |
461 content_setting_bubble_model_->OnListItemClicked(i->second); | 469 content_setting_bubble_model_->OnListItemClicked(i->second); |
462 } | 470 } |
463 | 471 |
464 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { | 472 void ContentSettingBubbleContents::OnPerformAction(views::Combobox* combobox) { |
465 MediaComboboxModel* model = | 473 MediaComboboxModel* model = |
466 static_cast<MediaComboboxModel*>(combobox->model()); | 474 static_cast<MediaComboboxModel*>(combobox->model()); |
467 content_setting_bubble_model_->OnMediaMenuClicked( | 475 content_setting_bubble_model_->OnMediaMenuClicked( |
468 model->type(), model->GetDevices()[combobox->selected_index()].id); | 476 model->type(), model->GetDevices()[combobox->selected_index()].id); |
469 } | 477 } |
OLD | NEW |