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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 void ContentSettingBubbleContents::OnMenuButtonClicked( | 437 void ContentSettingBubbleContents::OnMenuButtonClicked( |
438 views::View* source, | 438 views::View* source, |
439 const gfx::Point& point) { | 439 const gfx::Point& point) { |
440 MediaMenuPartsMap::iterator j(media_menus_.find( | 440 MediaMenuPartsMap::iterator j(media_menus_.find( |
441 static_cast<views::MenuButton*>(source))); | 441 static_cast<views::MenuButton*>(source))); |
442 DCHECK(j != media_menus_.end()); | 442 DCHECK(j != media_menus_.end()); |
443 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get())); | 443 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get())); |
444 | 444 |
445 gfx::Point screen_location; | 445 gfx::Point screen_location; |
446 views::View::ConvertPointToScreen(j->first, &screen_location); | 446 views::View::ConvertPointToScreen(j->first, &screen_location); |
447 ignore_result(menu_runner_->RunMenuAt( | 447 ignore_result( |
448 source->GetWidget(), | 448 menu_runner_->RunMenuAt(source->GetWidget(), |
449 j->first, | 449 j->first, |
450 gfx::Rect(screen_location, j->first->size()), | 450 gfx::Rect(screen_location, j->first->size()), |
451 views::MenuItemView::TOPLEFT, | 451 views::MENU_ANCHOR_TOPLEFT, |
452 ui::MENU_SOURCE_NONE, | 452 ui::MENU_SOURCE_NONE, |
453 views::MenuRunner::HAS_MNEMONICS)); | 453 views::MenuRunner::HAS_MNEMONICS)); |
454 } | 454 } |
455 | 455 |
456 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth( | 456 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth( |
457 views::MenuButton* button, | 457 views::MenuButton* button, |
458 ui::SimpleMenuModel* menu_model) { | 458 ui::SimpleMenuModel* menu_model) { |
459 base::string16 title = button->text(); | 459 base::string16 title = button->text(); |
460 | 460 |
461 int width = button->GetPreferredSize().width(); | 461 int width = button->GetPreferredSize().width(); |
462 for (int i = 0; i < menu_model->GetItemCount(); ++i) { | 462 for (int i = 0; i < menu_model->GetItemCount(); ++i) { |
463 button->SetText(menu_model->GetLabelAt(i)); | 463 button->SetText(menu_model->GetLabelAt(i)); |
464 width = std::max(width, button->GetPreferredSize().width()); | 464 width = std::max(width, button->GetPreferredSize().width()); |
465 } | 465 } |
466 | 466 |
467 // Recover the title for the menu button. | 467 // Recover the title for the menu button. |
468 button->SetText(title); | 468 button->SetText(title); |
469 return width; | 469 return width; |
470 } | 470 } |
OLD | NEW |