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

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

Issue 298813002: views: Move MenuButton from TextButton to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable DragDirectlyToSecondWindow. Created 6 years, 6 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 | Annotate | Revision Log
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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->set_alignment(views::TextButton::ALIGN_LEFT); 296 menu_button->SetHorizontalAlignment(gfx::ALIGN_LEFT);
297 menu_button->SetBorder(scoped_ptr<views::Border>(
298 new views::TextButtonNativeThemeBorder(menu_button)));
299 menu_button->set_animate_on_state_change(false); 297 menu_button->set_animate_on_state_change(false);
300 298
301 MediaMenuParts* menu_view = new MediaMenuParts(i->first); 299 MediaMenuParts* menu_view = new MediaMenuParts(i->first);
302 menu_view->menu_model.reset(new ContentSettingMediaMenuModel( 300 menu_view->menu_model.reset(new ContentSettingMediaMenuModel(
303 i->first, 301 i->first,
304 content_setting_bubble_model_.get(), 302 content_setting_bubble_model_.get(),
305 base::Bind(&ContentSettingBubbleContents::UpdateMenuLabel, 303 base::Bind(&ContentSettingBubbleContents::UpdateMenuLabel,
306 base::Unretained(this)))); 304 base::Unretained(this))));
307 media_menus_[menu_button] = menu_view; 305 media_menus_[menu_button] = menu_view;
308 306
(...skipping 21 matching lines...) Expand all
330 bubble_content_empty = false; 328 bubble_content_empty = false;
331 } 329 }
332 330
333 // Make sure the width is at least kMinMediaMenuButtonWidth. The 331 // Make sure the width is at least kMinMediaMenuButtonWidth. The
334 // maximum width will be clamped by kMaxContentsWidth of the view. 332 // maximum width will be clamped by kMaxContentsWidth of the view.
335 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width); 333 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width);
336 334
337 // Set all the menu buttons to the width we calculated above. 335 // Set all the menu buttons to the width we calculated above.
338 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); 336 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin();
339 i != media_menus_.end(); ++i) { 337 i != media_menus_.end(); ++i) {
340 i->first->set_min_width(menu_width); 338 i->first->set_min_size(gfx::Size(menu_width, 0));
341 i->first->set_max_width(menu_width); 339 i->first->set_max_size(gfx::Size(menu_width, 0));
342 } 340 }
343 } 341 }
344 342
345 const gfx::FontList& domain_font = 343 const gfx::FontList& domain_font =
346 ui::ResourceBundle::GetSharedInstance().GetFontList( 344 ui::ResourceBundle::GetSharedInstance().GetFontList(
347 ui::ResourceBundle::BoldFont); 345 ui::ResourceBundle::BoldFont);
348 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i( 346 for (std::vector<ContentSettingBubbleModel::DomainList>::const_iterator i(
349 bubble_content.domain_lists.begin()); 347 bubble_content.domain_lists.begin());
350 i != bubble_content.domain_lists.end(); ++i) { 348 i != bubble_content.domain_lists.end(); ++i) {
351 layout->StartRow(0, kSingleColumnSetId); 349 layout->StartRow(0, kSingleColumnSetId);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 j->first, 458 j->first,
461 gfx::Rect(screen_location, j->first->size()), 459 gfx::Rect(screen_location, j->first->size()),
462 views::MENU_ANCHOR_TOPLEFT, 460 views::MENU_ANCHOR_TOPLEFT,
463 ui::MENU_SOURCE_NONE, 461 ui::MENU_SOURCE_NONE,
464 views::MenuRunner::HAS_MNEMONICS)); 462 views::MenuRunner::HAS_MNEMONICS));
465 } 463 }
466 464
467 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth( 465 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth(
468 views::MenuButton* button, 466 views::MenuButton* button,
469 ui::SimpleMenuModel* menu_model) { 467 ui::SimpleMenuModel* menu_model) {
470 base::string16 title = button->text(); 468 base::string16 title = button->GetText();
471 469
472 int width = button->GetPreferredSize().width(); 470 int width = button->GetPreferredSize().width();
473 for (int i = 0; i < menu_model->GetItemCount(); ++i) { 471 for (int i = 0; i < menu_model->GetItemCount(); ++i) {
474 button->SetText(menu_model->GetLabelAt(i)); 472 button->SetText(menu_model->GetLabelAt(i));
475 width = std::max(width, button->GetPreferredSize().width()); 473 width = std::max(width, button->GetPreferredSize().width());
476 } 474 }
477 475
478 // Recover the title for the menu button. 476 // Recover the title for the menu button.
479 button->SetText(title); 477 button->SetText(title);
480 return width; 478 return width;
481 } 479 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698