OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/wrench_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 command_id <= WrenchMenuModel::kMaxRecentTabsCommandId; | 99 command_id <= WrenchMenuModel::kMaxRecentTabsCommandId; |
100 } | 100 } |
101 | 101 |
102 // Subclass of ImageButton whose preferred size includes the size of the border. | 102 // Subclass of ImageButton whose preferred size includes the size of the border. |
103 class FullscreenButton : public ImageButton { | 103 class FullscreenButton : public ImageButton { |
104 public: | 104 public: |
105 explicit FullscreenButton(views::ButtonListener* listener) | 105 explicit FullscreenButton(views::ButtonListener* listener) |
106 : ImageButton(listener) { } | 106 : ImageButton(listener) { } |
107 | 107 |
108 // Overridden from ImageButton. | 108 // Overridden from ImageButton. |
109 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 109 virtual gfx::Size GetPreferredSize() const override { |
110 gfx::Size pref = ImageButton::GetPreferredSize(); | 110 gfx::Size pref = ImageButton::GetPreferredSize(); |
111 if (border()) { | 111 if (border()) { |
112 gfx::Insets insets = border()->GetInsets(); | 112 gfx::Insets insets = border()->GetInsets(); |
113 pref.Enlarge(insets.width(), insets.height()); | 113 pref.Enlarge(insets.width(), insets.height()); |
114 } | 114 } |
115 return pref; | 115 return pref; |
116 } | 116 } |
117 | 117 |
118 private: | 118 private: |
119 DISALLOW_COPY_AND_ASSIGN(FullscreenButton); | 119 DISALLOW_COPY_AND_ASSIGN(FullscreenButton); |
(...skipping 21 matching lines...) Expand all Loading... |
141 if (base::i18n::IsRTL()) { | 141 if (base::i18n::IsRTL()) { |
142 left_button_ = right_button; | 142 left_button_ = right_button; |
143 right_button_ = left_button; | 143 right_button_ = left_button; |
144 } else { | 144 } else { |
145 left_button_ = left_button; | 145 left_button_ = left_button; |
146 right_button_ = right_button; | 146 right_button_ = right_button; |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 // Overridden from views::Background. | 150 // Overridden from views::Background. |
151 virtual void Paint(gfx::Canvas* canvas, View* view) const OVERRIDE { | 151 virtual void Paint(gfx::Canvas* canvas, View* view) const override { |
152 CustomButton* button = CustomButton::AsCustomButton(view); | 152 CustomButton* button = CustomButton::AsCustomButton(view); |
153 views::Button::ButtonState state = | 153 views::Button::ButtonState state = |
154 button ? button->state() : views::Button::STATE_NORMAL; | 154 button ? button->state() : views::Button::STATE_NORMAL; |
155 int h = view->height(); | 155 int h = view->height(); |
156 | 156 |
157 // Normal buttons get a border drawn on the right side and the rest gets | 157 // Normal buttons get a border drawn on the right side and the rest gets |
158 // filled in. The left button however does not get a line to combine | 158 // filled in. The left button however does not get a line to combine |
159 // buttons. | 159 // buttons. |
160 if (type_ != RIGHT_BUTTON) { | 160 if (type_ != RIGHT_BUTTON) { |
161 canvas->FillRect(gfx::Rect(0, 0, 1, h), | 161 canvas->FillRect(gfx::Rect(0, 0, 1, h), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 set_background(in_menu_background_); | 269 set_background(in_menu_background_); |
270 | 270 |
271 OnNativeThemeChanged(NULL); | 271 OnNativeThemeChanged(NULL); |
272 } | 272 } |
273 | 273 |
274 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { | 274 void SetOtherButtons(const InMenuButton* left, const InMenuButton* right) { |
275 in_menu_background_->SetOtherButtons(left, right); | 275 in_menu_background_->SetOtherButtons(left, right); |
276 } | 276 } |
277 | 277 |
278 // views::LabelButton | 278 // views::LabelButton |
279 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE { | 279 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
280 const MenuConfig& menu_config = MenuConfig::instance(theme); | 280 const MenuConfig& menu_config = MenuConfig::instance(theme); |
281 SetBorder(views::Border::CreateEmptyBorder( | 281 SetBorder(views::Border::CreateEmptyBorder( |
282 0, kHorizontalPadding, 0, kHorizontalPadding)); | 282 0, kHorizontalPadding, 0, kHorizontalPadding)); |
283 SetFontList(menu_config.font_list); | 283 SetFontList(menu_config.font_list); |
284 | 284 |
285 if (theme) { | 285 if (theme) { |
286 SetTextColor( | 286 SetTextColor( |
287 views::Button::STATE_DISABLED, | 287 views::Button::STATE_DISABLED, |
288 theme->GetSystemColor( | 288 theme->GetSystemColor( |
289 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); | 289 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor)); |
(...skipping 28 matching lines...) Expand all Loading... |
318 menu_model_(menu_model) { | 318 menu_model_(menu_model) { |
319 menu_->AddObserver(this); | 319 menu_->AddObserver(this); |
320 } | 320 } |
321 | 321 |
322 virtual ~WrenchMenuView() { | 322 virtual ~WrenchMenuView() { |
323 if (menu_) | 323 if (menu_) |
324 menu_->RemoveObserver(this); | 324 menu_->RemoveObserver(this); |
325 } | 325 } |
326 | 326 |
327 // Overridden from views::View. | 327 // Overridden from views::View. |
328 virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE { | 328 virtual void SchedulePaintInRect(const gfx::Rect& r) override { |
329 // Normally when the mouse enters/exits a button the buttons invokes | 329 // Normally when the mouse enters/exits a button the buttons invokes |
330 // SchedulePaint. As part of the button border (InMenuButtonBackground) is | 330 // SchedulePaint. As part of the button border (InMenuButtonBackground) is |
331 // rendered by the button to the left/right of it SchedulePaint on the the | 331 // rendered by the button to the left/right of it SchedulePaint on the the |
332 // button may not be enough, so this forces a paint all. | 332 // button may not be enough, so this forces a paint all. |
333 View::SchedulePaintInRect(gfx::Rect(size())); | 333 View::SchedulePaintInRect(gfx::Rect(size())); |
334 } | 334 } |
335 | 335 |
336 InMenuButton* CreateAndConfigureButton( | 336 InMenuButton* CreateAndConfigureButton( |
337 int string_id, | 337 int string_id, |
338 InMenuButtonBackground::ButtonType type, | 338 InMenuButtonBackground::ButtonType type, |
(...skipping 18 matching lines...) Expand all Loading... |
357 button->SetEnabled(menu_model_->IsEnabledAt(index)); | 357 button->SetEnabled(menu_model_->IsEnabledAt(index)); |
358 | 358 |
359 AddChildView(button); | 359 AddChildView(button); |
360 // all buttons on menu should must be a custom button in order for | 360 // all buttons on menu should must be a custom button in order for |
361 // the keyboard nativigation work. | 361 // the keyboard nativigation work. |
362 DCHECK(CustomButton::AsCustomButton(button)); | 362 DCHECK(CustomButton::AsCustomButton(button)); |
363 return button; | 363 return button; |
364 } | 364 } |
365 | 365 |
366 // Overridden from WrenchMenuObserver: | 366 // Overridden from WrenchMenuObserver: |
367 virtual void WrenchMenuDestroyed() OVERRIDE { | 367 virtual void WrenchMenuDestroyed() override { |
368 menu_->RemoveObserver(this); | 368 menu_->RemoveObserver(this); |
369 menu_ = NULL; | 369 menu_ = NULL; |
370 menu_model_ = NULL; | 370 menu_model_ = NULL; |
371 } | 371 } |
372 | 372 |
373 protected: | 373 protected: |
374 WrenchMenu* menu() { return menu_; } | 374 WrenchMenu* menu() { return menu_; } |
375 MenuModel* menu_model() { return menu_model_; } | 375 MenuModel* menu_model() { return menu_model_; } |
376 | 376 |
377 private: | 377 private: |
(...skipping 10 matching lines...) Expand all Loading... |
388 | 388 |
389 // Generate the button image for hover state. | 389 // Generate the button image for hover state. |
390 class HoveredImageSource : public gfx::ImageSkiaSource { | 390 class HoveredImageSource : public gfx::ImageSkiaSource { |
391 public: | 391 public: |
392 HoveredImageSource(const gfx::ImageSkia& image, SkColor color) | 392 HoveredImageSource(const gfx::ImageSkia& image, SkColor color) |
393 : image_(image), | 393 : image_(image), |
394 color_(color) { | 394 color_(color) { |
395 } | 395 } |
396 virtual ~HoveredImageSource() {} | 396 virtual ~HoveredImageSource() {} |
397 | 397 |
398 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { | 398 virtual gfx::ImageSkiaRep GetImageForScale(float scale) override { |
399 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale); | 399 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale); |
400 SkBitmap bitmap = rep.sk_bitmap(); | 400 SkBitmap bitmap = rep.sk_bitmap(); |
401 SkBitmap white; | 401 SkBitmap white; |
402 white.allocN32Pixels(bitmap.width(), bitmap.height()); | 402 white.allocN32Pixels(bitmap.width(), bitmap.height()); |
403 white.eraseARGB(0, 0, 0, 0); | 403 white.eraseARGB(0, 0, 0, 0); |
404 bitmap.lockPixels(); | 404 bitmap.lockPixels(); |
405 for (int y = 0; y < bitmap.height(); ++y) { | 405 for (int y = 0; y < bitmap.height(); ++y) { |
406 uint32* image_row = bitmap.getAddr32(0, y); | 406 uint32* image_row = bitmap.getAddr32(0, y); |
407 uint32* dst_row = white.getAddr32(0, y); | 407 uint32* dst_row = white.getAddr32(0, y); |
408 for (int x = 0; x < bitmap.width(); ++x) { | 408 for (int x = 0; x < bitmap.width(); ++x) { |
(...skipping 28 matching lines...) Expand all Loading... |
437 InMenuButton* cut = CreateAndConfigureButton( | 437 InMenuButton* cut = CreateAndConfigureButton( |
438 IDS_CUT, InMenuButtonBackground::LEFT_BUTTON, cut_index); | 438 IDS_CUT, InMenuButtonBackground::LEFT_BUTTON, cut_index); |
439 InMenuButton* copy = CreateAndConfigureButton( | 439 InMenuButton* copy = CreateAndConfigureButton( |
440 IDS_COPY, InMenuButtonBackground::CENTER_BUTTON, copy_index); | 440 IDS_COPY, InMenuButtonBackground::CENTER_BUTTON, copy_index); |
441 InMenuButton* paste = CreateAndConfigureButton( | 441 InMenuButton* paste = CreateAndConfigureButton( |
442 IDS_PASTE, InMenuButtonBackground::CENTER_BUTTON, paste_index); | 442 IDS_PASTE, InMenuButtonBackground::CENTER_BUTTON, paste_index); |
443 copy->SetOtherButtons(cut, paste); | 443 copy->SetOtherButtons(cut, paste); |
444 } | 444 } |
445 | 445 |
446 // Overridden from View. | 446 // Overridden from View. |
447 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 447 virtual gfx::Size GetPreferredSize() const override { |
448 // Returned height doesn't matter as MenuItemView forces everything to the | 448 // Returned height doesn't matter as MenuItemView forces everything to the |
449 // height of the menuitemview. | 449 // height of the menuitemview. |
450 return gfx::Size(GetMaxChildViewPreferredWidth() * child_count(), 0); | 450 return gfx::Size(GetMaxChildViewPreferredWidth() * child_count(), 0); |
451 } | 451 } |
452 | 452 |
453 virtual void Layout() OVERRIDE { | 453 virtual void Layout() override { |
454 // All buttons are given the same width. | 454 // All buttons are given the same width. |
455 int width = GetMaxChildViewPreferredWidth(); | 455 int width = GetMaxChildViewPreferredWidth(); |
456 for (int i = 0; i < child_count(); ++i) | 456 for (int i = 0; i < child_count(); ++i) |
457 child_at(i)->SetBounds(i * width, 0, width, height()); | 457 child_at(i)->SetBounds(i * width, 0, width, height()); |
458 } | 458 } |
459 | 459 |
460 // Overridden from ButtonListener. | 460 // Overridden from ButtonListener. |
461 virtual void ButtonPressed(views::Button* sender, | 461 virtual void ButtonPressed(views::Button* sender, |
462 const ui::Event& event) OVERRIDE { | 462 const ui::Event& event) override { |
463 menu()->CancelAndEvaluate(menu_model(), sender->tag()); | 463 menu()->CancelAndEvaluate(menu_model(), sender->tag()); |
464 } | 464 } |
465 | 465 |
466 private: | 466 private: |
467 // Returns the max preferred width of all the children. | 467 // Returns the max preferred width of all the children. |
468 int GetMaxChildViewPreferredWidth() const { | 468 int GetMaxChildViewPreferredWidth() const { |
469 int width = 0; | 469 int width = 0; |
470 for (int i = 0; i < child_count(); ++i) | 470 for (int i = 0; i < child_count(); ++i) |
471 width = std::max(width, child_at(i)->GetPreferredSize().width()); | 471 width = std::max(width, child_at(i)->GetPreferredSize().width()); |
472 return width; | 472 return width; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 AddChildView(fullscreen_button_); | 549 AddChildView(fullscreen_button_); |
550 | 550 |
551 // Need to set a font list for the zoom label width calculations. | 551 // Need to set a font list for the zoom label width calculations. |
552 OnNativeThemeChanged(NULL); | 552 OnNativeThemeChanged(NULL); |
553 UpdateZoomControls(); | 553 UpdateZoomControls(); |
554 } | 554 } |
555 | 555 |
556 virtual ~ZoomView() {} | 556 virtual ~ZoomView() {} |
557 | 557 |
558 // Overridden from View. | 558 // Overridden from View. |
559 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 559 virtual gfx::Size GetPreferredSize() const override { |
560 // The increment/decrement button are forced to the same width. | 560 // The increment/decrement button are forced to the same width. |
561 int button_width = std::max(increment_button_->GetPreferredSize().width(), | 561 int button_width = std::max(increment_button_->GetPreferredSize().width(), |
562 decrement_button_->GetPreferredSize().width()); | 562 decrement_button_->GetPreferredSize().width()); |
563 int fullscreen_width = | 563 int fullscreen_width = |
564 fullscreen_button_->GetPreferredSize().width() + kFullscreenPadding; | 564 fullscreen_button_->GetPreferredSize().width() + kFullscreenPadding; |
565 // Returned height doesn't matter as MenuItemView forces everything to the | 565 // Returned height doesn't matter as MenuItemView forces everything to the |
566 // height of the menuitemview. Note that we have overridden the height when | 566 // height of the menuitemview. Note that we have overridden the height when |
567 // constructing the menu. | 567 // constructing the menu. |
568 return gfx::Size(button_width + zoom_label_width_ + button_width + | 568 return gfx::Size(button_width + zoom_label_width_ + button_width + |
569 fullscreen_width, 0); | 569 fullscreen_width, 0); |
570 } | 570 } |
571 | 571 |
572 virtual void Layout() OVERRIDE { | 572 virtual void Layout() override { |
573 int x = 0; | 573 int x = 0; |
574 int button_width = std::max(increment_button_->GetPreferredSize().width(), | 574 int button_width = std::max(increment_button_->GetPreferredSize().width(), |
575 decrement_button_->GetPreferredSize().width()); | 575 decrement_button_->GetPreferredSize().width()); |
576 gfx::Rect bounds(0, 0, button_width, height()); | 576 gfx::Rect bounds(0, 0, button_width, height()); |
577 | 577 |
578 decrement_button_->SetBoundsRect(bounds); | 578 decrement_button_->SetBoundsRect(bounds); |
579 | 579 |
580 x += bounds.width(); | 580 x += bounds.width(); |
581 bounds.set_x(x); | 581 bounds.set_x(x); |
582 bounds.set_width(zoom_label_width_); | 582 bounds.set_width(zoom_label_width_); |
583 zoom_label_->SetBoundsRect(bounds); | 583 zoom_label_->SetBoundsRect(bounds); |
584 | 584 |
585 x += bounds.width(); | 585 x += bounds.width(); |
586 bounds.set_x(x); | 586 bounds.set_x(x); |
587 bounds.set_width(button_width); | 587 bounds.set_width(button_width); |
588 increment_button_->SetBoundsRect(bounds); | 588 increment_button_->SetBoundsRect(bounds); |
589 | 589 |
590 x += bounds.width(); | 590 x += bounds.width(); |
591 bounds.set_x(x); | 591 bounds.set_x(x); |
592 bounds.set_width(fullscreen_button_->GetPreferredSize().width() + | 592 bounds.set_width(fullscreen_button_->GetPreferredSize().width() + |
593 kFullscreenPadding); | 593 kFullscreenPadding); |
594 fullscreen_button_->SetBoundsRect(bounds); | 594 fullscreen_button_->SetBoundsRect(bounds); |
595 } | 595 } |
596 | 596 |
597 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE { | 597 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override { |
598 WrenchMenuView::OnNativeThemeChanged(theme); | 598 WrenchMenuView::OnNativeThemeChanged(theme); |
599 | 599 |
600 const MenuConfig& menu_config = MenuConfig::instance(theme); | 600 const MenuConfig& menu_config = MenuConfig::instance(theme); |
601 zoom_label_->SetBorder(views::Border::CreateEmptyBorder( | 601 zoom_label_->SetBorder(views::Border::CreateEmptyBorder( |
602 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding)); | 602 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding)); |
603 zoom_label_->SetFontList(menu_config.font_list); | 603 zoom_label_->SetFontList(menu_config.font_list); |
604 zoom_label_width_ = MaxWidthForZoomLabel(); | 604 zoom_label_width_ = MaxWidthForZoomLabel(); |
605 | 605 |
606 if (theme) { | 606 if (theme) { |
607 zoom_label_->SetEnabledColor(theme->GetSystemColor( | 607 zoom_label_->SetEnabledColor(theme->GetSystemColor( |
608 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); | 608 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); |
609 gfx::ImageSkia* full_screen_image = | 609 gfx::ImageSkia* full_screen_image = |
610 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 610 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
611 IDR_FULLSCREEN_MENU_BUTTON); | 611 IDR_FULLSCREEN_MENU_BUTTON); |
612 SkColor fg_color = theme->GetSystemColor( | 612 SkColor fg_color = theme->GetSystemColor( |
613 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor); | 613 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor); |
614 gfx::ImageSkia hovered_fullscreen_image( | 614 gfx::ImageSkia hovered_fullscreen_image( |
615 new HoveredImageSource(*full_screen_image, fg_color), | 615 new HoveredImageSource(*full_screen_image, fg_color), |
616 full_screen_image->size()); | 616 full_screen_image->size()); |
617 fullscreen_button_->SetImage( | 617 fullscreen_button_->SetImage( |
618 ImageButton::STATE_HOVERED, &hovered_fullscreen_image); | 618 ImageButton::STATE_HOVERED, &hovered_fullscreen_image); |
619 fullscreen_button_->SetImage( | 619 fullscreen_button_->SetImage( |
620 ImageButton::STATE_PRESSED, &hovered_fullscreen_image); | 620 ImageButton::STATE_PRESSED, &hovered_fullscreen_image); |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
624 // Overridden from ButtonListener. | 624 // Overridden from ButtonListener. |
625 virtual void ButtonPressed(views::Button* sender, | 625 virtual void ButtonPressed(views::Button* sender, |
626 const ui::Event& event) OVERRIDE { | 626 const ui::Event& event) override { |
627 if (sender->tag() == fullscreen_index_) { | 627 if (sender->tag() == fullscreen_index_) { |
628 menu()->CancelAndEvaluate(menu_model(), sender->tag()); | 628 menu()->CancelAndEvaluate(menu_model(), sender->tag()); |
629 } else { | 629 } else { |
630 // Zoom buttons don't close the menu. | 630 // Zoom buttons don't close the menu. |
631 menu_model()->ActivatedAt(sender->tag()); | 631 menu_model()->ActivatedAt(sender->tag()); |
632 } | 632 } |
633 } | 633 } |
634 | 634 |
635 // Overridden from WrenchMenuObserver. | 635 // Overridden from WrenchMenuObserver. |
636 virtual void WrenchMenuDestroyed() OVERRIDE { | 636 virtual void WrenchMenuDestroyed() override { |
637 WrenchMenuView::WrenchMenuDestroyed(); | 637 WrenchMenuView::WrenchMenuDestroyed(); |
638 } | 638 } |
639 | 639 |
640 private: | 640 private: |
641 void OnZoomLevelChanged(const HostZoomMap::ZoomLevelChange& change) { | 641 void OnZoomLevelChanged(const HostZoomMap::ZoomLevelChange& change) { |
642 UpdateZoomControls(); | 642 UpdateZoomControls(); |
643 } | 643 } |
644 | 644 |
645 void UpdateZoomControls() { | 645 void UpdateZoomControls() { |
646 WebContents* selected_tab = | 646 WebContents* selected_tab = |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 } | 742 } |
743 | 743 |
744 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const { | 744 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const { |
745 // The items for which we get a font list, should be shown in the bolded | 745 // The items for which we get a font list, should be shown in the bolded |
746 // color. | 746 // color. |
747 return GetLabelFontListAt(index) ? true : false; | 747 return GetLabelFontListAt(index) ? true : false; |
748 } | 748 } |
749 | 749 |
750 // ui::MenuModelDelegate implementation: | 750 // ui::MenuModelDelegate implementation: |
751 | 751 |
752 virtual void OnIconChanged(int index) OVERRIDE { | 752 virtual void OnIconChanged(int index) override { |
753 int command_id = model_->GetCommandIdAt(index); | 753 int command_id = model_->GetCommandIdAt(index); |
754 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); | 754 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); |
755 DCHECK(item); | 755 DCHECK(item); |
756 gfx::Image icon; | 756 gfx::Image icon; |
757 model_->GetIconAt(index, &icon); | 757 model_->GetIconAt(index, &icon); |
758 item->SetIcon(*icon.ToImageSkia()); | 758 item->SetIcon(*icon.ToImageSkia()); |
759 } | 759 } |
760 | 760 |
761 virtual void OnMenuStructureChanged() OVERRIDE { | 761 virtual void OnMenuStructureChanged() override { |
762 if (menu_item_->HasSubmenu()) { | 762 if (menu_item_->HasSubmenu()) { |
763 // Remove all menu items from submenu. | 763 // Remove all menu items from submenu. |
764 views::SubmenuView* submenu = menu_item_->GetSubmenu(); | 764 views::SubmenuView* submenu = menu_item_->GetSubmenu(); |
765 while (submenu->child_count() > 0) | 765 while (submenu->child_count() > 0) |
766 menu_item_->RemoveMenuItemAt(submenu->child_count() - 1); | 766 menu_item_->RemoveMenuItemAt(submenu->child_count() - 1); |
767 | 767 |
768 // Remove all elements in |WrenchMenu::command_id_to_entry_| that map to | 768 // Remove all elements in |WrenchMenu::command_id_to_entry_| that map to |
769 // |model_|. | 769 // |model_|. |
770 WrenchMenu::CommandIDToEntry::iterator iter = | 770 WrenchMenu::CommandIDToEntry::iterator iter = |
771 wrench_menu_->command_id_to_entry_.begin(); | 771 wrench_menu_->command_id_to_entry_.begin(); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 0, | 1261 0, |
1262 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1262 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
1263 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); | 1263 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); |
1264 } | 1264 } |
1265 | 1265 |
1266 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { | 1266 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { |
1267 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1267 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
1268 DCHECK(ix != command_id_to_entry_.end()); | 1268 DCHECK(ix != command_id_to_entry_.end()); |
1269 return ix->second.second; | 1269 return ix->second.second; |
1270 } | 1270 } |
OLD | NEW |