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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 286 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
287 layout->StartRow(0, kMediaMenuColumnSetId); | 287 layout->StartRow(0, kMediaMenuColumnSetId); |
288 | 288 |
289 views::Label* label = | 289 views::Label* label = |
290 new views::Label(base::UTF8ToUTF16(i->second.label)); | 290 new views::Label(base::UTF8ToUTF16(i->second.label)); |
291 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 291 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
292 | 292 |
293 views::MenuButton* menu_button = new views::MenuButton( | 293 views::MenuButton* menu_button = new views::MenuButton( |
294 NULL, base::UTF8ToUTF16((i->second.selected_device.name)), | 294 NULL, base::UTF8ToUTF16((i->second.selected_device.name)), |
295 this, true); | 295 this, true); |
296 menu_button->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 296 menu_button->set_alignment(views::TextButton::ALIGN_LEFT); |
| 297 menu_button->SetBorder(scoped_ptr<views::Border>( |
| 298 new views::TextButtonNativeThemeBorder(menu_button))); |
297 menu_button->set_animate_on_state_change(false); | 299 menu_button->set_animate_on_state_change(false); |
298 | 300 |
299 MediaMenuParts* menu_view = new MediaMenuParts(i->first); | 301 MediaMenuParts* menu_view = new MediaMenuParts(i->first); |
300 menu_view->menu_model.reset(new ContentSettingMediaMenuModel( | 302 menu_view->menu_model.reset(new ContentSettingMediaMenuModel( |
301 i->first, | 303 i->first, |
302 content_setting_bubble_model_.get(), | 304 content_setting_bubble_model_.get(), |
303 base::Bind(&ContentSettingBubbleContents::UpdateMenuLabel, | 305 base::Bind(&ContentSettingBubbleContents::UpdateMenuLabel, |
304 base::Unretained(this)))); | 306 base::Unretained(this)))); |
305 media_menus_[menu_button] = menu_view; | 307 media_menus_[menu_button] = menu_view; |
306 | 308 |
(...skipping 21 matching lines...) Expand all Loading... |
328 bubble_content_empty = false; | 330 bubble_content_empty = false; |
329 } | 331 } |
330 | 332 |
331 // Make sure the width is at least kMinMediaMenuButtonWidth. The | 333 // Make sure the width is at least kMinMediaMenuButtonWidth. The |
332 // maximum width will be clamped by kMaxContentsWidth of the view. | 334 // maximum width will be clamped by kMaxContentsWidth of the view. |
333 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width); | 335 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width); |
334 | 336 |
335 // Set all the menu buttons to the width we calculated above. | 337 // Set all the menu buttons to the width we calculated above. |
336 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); | 338 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); |
337 i != media_menus_.end(); ++i) { | 339 i != media_menus_.end(); ++i) { |
338 i->first->set_min_size(gfx::Size(menu_width, 0)); | 340 i->first->set_min_width(menu_width); |
339 i->first->set_max_size(gfx::Size(menu_width, 0)); | 341 i->first->set_max_width(menu_width); |
340 } | 342 } |
341 } | 343 } |
342 | 344 |
343 const gfx::FontList& domain_font = | 345 const gfx::FontList& domain_font = |
344 ui::ResourceBundle::GetSharedInstance().GetFontList( | 346 ui::ResourceBundle::GetSharedInstance().GetFontList( |
345 ui::ResourceBundle::BoldFont); | 347 ui::ResourceBundle::BoldFont); |
346 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( | 348 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( |
347 bubble_content.domain_lists.begin()); | 349 bubble_content.domain_lists.begin()); |
348 i != bubble_content.domain_lists.end(); ++i) { | 350 i != bubble_content.domain_lists.end(); ++i) { |
349 layout->StartRow(0, kSingleColumnSetId); | 351 layout->StartRow(0, kSingleColumnSetId); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 j->first, | 460 j->first, |
459 gfx::Rect(screen_location, j->first->size()), | 461 gfx::Rect(screen_location, j->first->size()), |
460 views::MENU_ANCHOR_TOPLEFT, | 462 views::MENU_ANCHOR_TOPLEFT, |
461 ui::MENU_SOURCE_NONE, | 463 ui::MENU_SOURCE_NONE, |
462 views::MenuRunner::HAS_MNEMONICS)); | 464 views::MenuRunner::HAS_MNEMONICS)); |
463 } | 465 } |
464 | 466 |
465 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth( | 467 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth( |
466 views::MenuButton* button, | 468 views::MenuButton* button, |
467 ui::SimpleMenuModel* menu_model) { | 469 ui::SimpleMenuModel* menu_model) { |
468 base::string16 title = button->GetText(); | 470 base::string16 title = button->text(); |
469 | 471 |
470 int width = button->GetPreferredSize().width(); | 472 int width = button->GetPreferredSize().width(); |
471 for (int i = 0; i < menu_model->GetItemCount(); ++i) { | 473 for (int i = 0; i < menu_model->GetItemCount(); ++i) { |
472 button->SetText(menu_model->GetLabelAt(i)); | 474 button->SetText(menu_model->GetLabelAt(i)); |
473 width = std::max(width, button->GetPreferredSize().width()); | 475 width = std::max(width, button->GetPreferredSize().width()); |
474 } | 476 } |
475 | 477 |
476 // Recover the title for the menu button. | 478 // Recover the title for the menu button. |
477 button->SetText(title); | 479 button->SetText(title); |
478 return width; | 480 return width; |
479 } | 481 } |
OLD | NEW |