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

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: Use actual types in for loops instead of auto 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
« no previous file with comments | « chrome/browser/ui/views/content_setting_bubble_contents.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
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 int row = 0;
227 new views::Label(bubble_content.plugin_names); 227 for (const ContentSettingBubbleModel::ListItem& list_item :
228 plugin_names_label->SetMultiLine(true); 228 bubble_content.list_items) {
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) 229 if (!bubble_content_empty)
251 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 230 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
252 layout->StartRow(0, kPopupColumnSetId); 231 layout->StartRow(0, kItemListColumnSetId);
253 232 if (list_item.has_link) {
254 views::Link* link = new views::Link(base::UTF8ToUTF16(i->title)); 233 views::Link* link = new views::Link(base::UTF8ToUTF16(list_item.title));
255 link->set_listener(this); 234 link->set_listener(this);
256 link->SetElideBehavior(gfx::ELIDE_MIDDLE); 235 link->SetElideBehavior(gfx::ELIDE_MIDDLE);
257 popup_links_[link] = i - bubble_content.popup_items.begin(); 236 list_item_links_[link] = row;
258 layout->AddView(new Favicon(i->image, this, link)); 237 layout->AddView(new Favicon(list_item.image, this, link));
259 layout->AddView(link); 238 layout->AddView(link);
239 } else {
240 views::Label* label =
241 new views::Label(base::UTF8ToUTF16(list_item.title));
242 layout->AddView(new Favicon(list_item.image, this, NULL));
243 layout->AddView(label);
244 }
245 row++;
260 bubble_content_empty = false; 246 bubble_content_empty = false;
261 } 247 }
262 } 248 }
263 249
264 const int indented_kSingleColumnSetId = 3; 250 const int indented_kSingleColumnSetId = 3;
265 // Insert a column set with greater indent. 251 // Insert a column set with greater indent.
266 views::ColumnSet* indented_single_column_set = 252 views::ColumnSet* indented_single_column_set =
267 layout->AddColumnSet(indented_kSingleColumnSetId); 253 layout->AddColumnSet(indented_kSingleColumnSetId);
268 indented_single_column_set->AddPaddingColumn(0, views::kCheckboxIndent); 254 indented_single_column_set->AddPaddingColumn(0, views::kCheckboxIndent);
269 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 255 indented_single_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL,
(...skipping 18 matching lines...) Expand all
288 } 274 }
289 DCHECK(!radio_group_.empty()); 275 DCHECK(!radio_group_.empty());
290 // Now that the buttons have been added to the view hierarchy, it's safe 276 // Now that the buttons have been added to the view hierarchy, it's safe
291 // to call SetChecked() on them. 277 // to call SetChecked() on them.
292 radio_group_[radio_group.default_item]->SetChecked(true); 278 radio_group_[radio_group.default_item]->SetChecked(true);
293 } 279 }
294 280
295 // Layout code for the media device menus. 281 // Layout code for the media device menus.
296 if (content_setting_bubble_model_->content_type() == 282 if (content_setting_bubble_model_->content_type() ==
297 CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 283 CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
298 const int kMediaMenuColumnSetId = 2; 284 const int kMediaMenuColumnSetId = 4;
299 views::ColumnSet* menu_column_set = 285 views::ColumnSet* menu_column_set =
300 layout->AddColumnSet(kMediaMenuColumnSetId); 286 layout->AddColumnSet(kMediaMenuColumnSetId);
301 menu_column_set->AddPaddingColumn(0, views::kCheckboxIndent); 287 menu_column_set->AddPaddingColumn(0, views::kCheckboxIndent);
302 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0, 288 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
303 GridLayout::USE_PREF, 0, 0); 289 GridLayout::USE_PREF, 0, 0);
304 menu_column_set->AddPaddingColumn( 290 menu_column_set->AddPaddingColumn(
305 0, views::kRelatedControlHorizontalSpacing); 291 0, views::kRelatedControlHorizontalSpacing);
306 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 292 menu_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
307 GridLayout::USE_PREF, 0, 0); 293 GridLayout::USE_PREF, 0, 0);
308 294
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return; 442 return;
457 } 443 }
458 if (source == manage_link_) { 444 if (source == manage_link_) {
459 GetWidget()->Close(); 445 GetWidget()->Close();
460 content_setting_bubble_model_->OnManageLinkClicked(); 446 content_setting_bubble_model_->OnManageLinkClicked();
461 // CAREFUL: Showing the settings window activates it, which deactivates the 447 // CAREFUL: Showing the settings window activates it, which deactivates the
462 // info bubble, which causes it to close, which deletes us. 448 // info bubble, which causes it to close, which deletes us.
463 return; 449 return;
464 } 450 }
465 451
466 PopupLinks::const_iterator i(popup_links_.find(source)); 452 ListItemLinks::const_iterator i(list_item_links_.find(source));
467 DCHECK(i != popup_links_.end()); 453 DCHECK(i != list_item_links_.end());
468 content_setting_bubble_model_->OnPopupClicked(i->second); 454 content_setting_bubble_model_->OnListItemClicked(i->second);
469 } 455 }
470 456
471 void ContentSettingBubbleContents::OnMenuButtonClicked( 457 void ContentSettingBubbleContents::OnMenuButtonClicked(
472 views::View* source, 458 views::View* source,
473 const gfx::Point& point) { 459 const gfx::Point& point) {
474 MediaMenuPartsMap::iterator j(media_menus_.find( 460 MediaMenuPartsMap::iterator j(media_menus_.find(
475 static_cast<views::MenuButton*>(source))); 461 static_cast<views::MenuButton*>(source)));
476 DCHECK(j != media_menus_.end()); 462 DCHECK(j != media_menus_.end());
477 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get(), 463 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get(),
478 views::MenuRunner::HAS_MNEMONICS)); 464 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 499 // Make sure the width is at least kMinMediaMenuButtonWidth. The
514 // maximum width will be clamped by kMaxContentsWidth of the view. 500 // maximum width will be clamped by kMaxContentsWidth of the view.
515 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); 501 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins);
516 502
517 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); 503 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin();
518 i != media_menus_.end(); ++i) { 504 i != media_menus_.end(); ++i) {
519 i->first->SetMinSize(gfx::Size(menu_width, 0)); 505 i->first->SetMinSize(gfx::Size(menu_width, 0));
520 i->first->SetMaxSize(gfx::Size(menu_width, 0)); 506 i->first->SetMaxSize(gfx::Size(menu_width, 0));
521 } 507 }
522 } 508 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/content_setting_bubble_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698