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

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

Issue 331993009: MacViews: Run native Cocoa context menus to support Services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add VIEWS_EXPORT for unit test access Created 6 years, 5 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 DCHECK(i != popup_links_.end()); 461 DCHECK(i != popup_links_.end());
462 content_setting_bubble_model_->OnPopupClicked(i->second); 462 content_setting_bubble_model_->OnPopupClicked(i->second);
463 } 463 }
464 464
465 void ContentSettingBubbleContents::OnMenuButtonClicked( 465 void ContentSettingBubbleContents::OnMenuButtonClicked(
466 views::View* source, 466 views::View* source,
467 const gfx::Point& point) { 467 const gfx::Point& point) {
468 MediaMenuPartsMap::iterator j(media_menus_.find( 468 MediaMenuPartsMap::iterator j(media_menus_.find(
469 static_cast<views::MenuButton*>(source))); 469 static_cast<views::MenuButton*>(source)));
470 DCHECK(j != media_menus_.end()); 470 DCHECK(j != media_menus_.end());
471 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get())); 471 menu_runner_.reset(new views::MenuRunner(j->second->menu_model.get(),
472 views::MenuRunner::HAS_MNEMONICS));
472 473
473 gfx::Point screen_location; 474 gfx::Point screen_location;
474 views::View::ConvertPointToScreen(j->first, &screen_location); 475 views::View::ConvertPointToScreen(j->first, &screen_location);
475 ignore_result( 476 ignore_result(
476 menu_runner_->RunMenuAt(source->GetWidget(), 477 menu_runner_->RunMenuAt(source->GetWidget(),
477 j->first, 478 j->first,
478 gfx::Rect(screen_location, j->first->size()), 479 gfx::Rect(screen_location, j->first->size()),
479 views::MENU_ANCHOR_TOPLEFT, 480 views::MENU_ANCHOR_TOPLEFT,
480 ui::MENU_SOURCE_NONE, 481 ui::MENU_SOURCE_NONE));
481 views::MenuRunner::HAS_MNEMONICS));
482 } 482 }
483 483
484 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth( 484 int ContentSettingBubbleContents::GetPreferredMediaMenuWidth(
485 views::MenuButton* button, 485 views::MenuButton* button,
486 ui::SimpleMenuModel* menu_model) { 486 ui::SimpleMenuModel* menu_model) {
487 base::string16 title = button->GetText(); 487 base::string16 title = button->GetText();
488 488
489 int width = button->GetPreferredSize().width(); 489 int width = button->GetPreferredSize().width();
490 for (int i = 0; i < menu_model->GetItemCount(); ++i) { 490 for (int i = 0; i < menu_model->GetItemCount(); ++i) {
491 button->SetText(menu_model->GetLabelAt(i)); 491 button->SetText(menu_model->GetLabelAt(i));
492 width = std::max(width, button->GetPreferredSize().width()); 492 width = std::max(width, button->GetPreferredSize().width());
493 } 493 }
494 494
495 // Recover the title for the menu button. 495 // Recover the title for the menu button.
496 button->SetText(title); 496 button->SetText(title);
497 return width; 497 return width;
498 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698