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

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

Issue 1025503002: Use same base class for popup and plugin blocking UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: msw comments Created 5 years, 9 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 (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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 if (!bubble_content.learn_more_link.empty()) { 205 if (!bubble_content.learn_more_link.empty()) {
206 learn_more_link_ = 206 learn_more_link_ =
207 new views::Link(base::UTF8ToUTF16(bubble_content.learn_more_link)); 207 new views::Link(base::UTF8ToUTF16(bubble_content.learn_more_link));
208 learn_more_link_->set_listener(this); 208 learn_more_link_->set_listener(this);
209 learn_more_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 209 learn_more_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
210 layout->AddView(learn_more_link_); 210 layout->AddView(learn_more_link_);
211 bubble_content_empty = false; 211 bubble_content_empty = false;
212 } 212 }
213 213
214 if (!bubble_content.plugin_names.empty()) { 214 // Layout for the item list (blocked plugins and popups).
215 const int kPluginsColumnSetId = 4; 215 if (!bubble_content.list_items.empty()) {
216 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 216 const int kItemListColumnSetId = 2;
msw 2015/03/21 00:25:19 nit: maybe keep this 4 to avoid conflict with kMed
meacer 2015/03/23 18:19:40 Made kMediaMenuColumnSetId 4 so that they are in i
217 views::ColumnSet* plugins_column_set = 217 views::ColumnSet* item_list_column_set =
218 layout->AddColumnSet(kPluginsColumnSetId); 218 layout->AddColumnSet(kItemListColumnSetId);
219 plugins_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 219 item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
220 GridLayout::USE_PREF, 0, 0); 220 GridLayout::USE_PREF, 0, 0);
221 plugins_column_set->AddPaddingColumn( 221 item_list_column_set->AddPaddingColumn(
222 0, views::kRelatedControlHorizontalSpacing); 222 0, views::kRelatedControlHorizontalSpacing);
223 plugins_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 223 item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
224 GridLayout::USE_PREF, 0, 0); 224 GridLayout::USE_PREF, 0, 0);
225 225
226 views::Label* plugin_names_label = 226 for (auto i(bubble_content.list_items.begin());
Bernhard Bauer 2015/03/23 22:30:46 Can you use a C++11-style loop here as well?
meacer 2015/03/23 23:44:46 Done.
227 new views::Label(bubble_content.plugin_names); 227 i != bubble_content.list_items.end(); ++i) {
228 plugin_names_label->SetMultiLine(true);
229 plugin_names_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
230 layout->StartRow(0, kPluginsColumnSetId);
231 layout->AddView(plugin_names_label);
232 bubble_content_empty = false;
233 }
234
235 if (content_setting_bubble_model_->content_type() ==
236 CONTENT_SETTINGS_TYPE_POPUPS) {
237 const int kPopupColumnSetId = 2;
238 views::ColumnSet* popup_column_set =
239 layout->AddColumnSet(kPopupColumnSetId);
240 popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
241 GridLayout::USE_PREF, 0, 0);
242 popup_column_set->AddPaddingColumn(
243 0, views::kRelatedControlHorizontalSpacing);
244 popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
245 GridLayout::USE_PREF, 0, 0);
246
247 for (std::vector<ContentSettingBubbleModel::PopupItem>::const_iterator
248 i(bubble_content.popup_items.begin());
249 i != bubble_content.popup_items.end(); ++i) {
250 if (!bubble_content_empty) 228 if (!bubble_content_empty)
251 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 229 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
252 layout->StartRow(0, kPopupColumnSetId); 230 layout->StartRow(0, kItemListColumnSetId);
253 231 if (i->has_link) {
254 views::Link* link = new views::Link(base::UTF8ToUTF16(i->title)); 232 views::Link* link = new views::Link(base::UTF8ToUTF16(i->title));
255 link->set_listener(this); 233 link->set_listener(this);
256 link->SetElideBehavior(gfx::ELIDE_MIDDLE); 234 link->SetElideBehavior(gfx::ELIDE_MIDDLE);
257 popup_links_[link] = i - bubble_content.popup_items.begin(); 235 list_item_links_[link] = i - bubble_content.list_items.begin();
258 layout->AddView(new Favicon(i->image, this, link)); 236 layout->AddView(new Favicon(i->image, this, link));
259 layout->AddView(link); 237 layout->AddView(link);
238 } else {
239 views::Label* label = new views::Label(base::UTF8ToUTF16(i->title));
240 layout->AddView(new Favicon(i->image, this, NULL));
241 layout->AddView(label);
242 }
260 bubble_content_empty = false; 243 bubble_content_empty = false;
261 } 244 }
262 } 245 }
263 246
264 const int indented_kSingleColumnSetId = 3; 247 const int indented_kSingleColumnSetId = 3;
265 // Insert a column set with greater indent. 248 // Insert a column set with greater indent.
266 views::ColumnSet* indented_single_column_set = 249 views::ColumnSet* indented_single_column_set =
267 layout->AddColumnSet(indented_kSingleColumnSetId); 250 layout->AddColumnSet(indented_kSingleColumnSetId);
268 indented_single_column_set->AddPaddingColumn(0, views::kCheckboxIndent); 251 indented_single_column_set->AddPaddingColumn(0, views::kCheckboxIndent);
269 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 252 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return; 439 return;
457 } 440 }
458 if (source == manage_link_) { 441 if (source == manage_link_) {
459 GetWidget()->Close(); 442 GetWidget()->Close();
460 content_setting_bubble_model_->OnManageLinkClicked(); 443 content_setting_bubble_model_->OnManageLinkClicked();
461 // CAREFUL: Showing the settings window activates it, which deactivates the 444 // CAREFUL: Showing the settings window activates it, which deactivates the
462 // info bubble, which causes it to close, which deletes us. 445 // info bubble, which causes it to close, which deletes us.
463 return; 446 return;
464 } 447 }
465 448
466 PopupLinks::const_iterator i(popup_links_.find(source)); 449 ListItemLinks::const_iterator i(list_item_links_.find(source));
467 DCHECK(i != popup_links_.end()); 450 DCHECK(i != list_item_links_.end());
468 content_setting_bubble_model_->OnPopupClicked(i->second); 451 content_setting_bubble_model_->OnListItemClicked(i->second);
469 } 452 }
470 453
471 void ContentSettingBubbleContents::OnMenuButtonClicked( 454 void ContentSettingBubbleContents::OnMenuButtonClicked(
472 views::View* source, 455 views::View* source,
473 const gfx::Point& point) { 456 const gfx::Point& point) {
474 MediaMenuPartsMap::iterator j(media_menus_.find( 457 MediaMenuPartsMap::iterator j(media_menus_.find(
475 static_cast<views::MenuButton*>(source))); 458 static_cast<views::MenuButton*>(source)));
476 DCHECK(j != media_menus_.end()); 459 DCHECK(j != media_menus_.end());
477 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get(), 460 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get(),
478 views::MenuRunner::HAS_MNEMONICS)); 461 views::MenuRunner::HAS_MNEMONICS));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 // Make sure the width is at least kMinMediaMenuButtonWidth. The 496 // Make sure the width is at least kMinMediaMenuButtonWidth. The
514 // maximum width will be clamped by kMaxContentsWidth of the view. 497 // maximum width will be clamped by kMaxContentsWidth of the view.
515 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); 498 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins);
516 499
517 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); 500 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin();
518 i != media_menus_.end(); ++i) { 501 i != media_menus_.end(); ++i) {
519 i->first->SetMinSize(gfx::Size(menu_width, 0)); 502 i->first->SetMinSize(gfx::Size(menu_width, 0));
520 i->first->SetMaxSize(gfx::Size(menu_width, 0)); 503 i->first->SetMaxSize(gfx::Size(menu_width, 0));
521 } 504 }
522 } 505 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698