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

Side by Side Diff: chrome/browser/ui/views/toolbar/wrench_menu.cc

Issue 680053003: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
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
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 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
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 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 return MenuItemView::GetAccessibleNameForMenuItem( 252 return MenuItemView::GetAccessibleNameForMenuItem(
253 accessible_name, accelerator_text); 253 accessible_name, accelerator_text);
254 } 254 }
255 255
256 // A button that lives inside a menu item. 256 // A button that lives inside a menu item.
257 class InMenuButton : public LabelButton { 257 class InMenuButton : public LabelButton {
258 public: 258 public:
259 InMenuButton(views::ButtonListener* listener, const base::string16& text) 259 InMenuButton(views::ButtonListener* listener, const base::string16& text)
260 : LabelButton(listener, text), in_menu_background_(NULL) {} 260 : LabelButton(listener, text), in_menu_background_(NULL) {}
261 virtual ~InMenuButton() {} 261 ~InMenuButton() override {}
262 262
263 void Init(InMenuButtonBackground::ButtonType type) { 263 void Init(InMenuButtonBackground::ButtonType type) {
264 SetFocusable(true); 264 SetFocusable(true);
265 set_request_focus_on_press(false); 265 set_request_focus_on_press(false);
266 SetHorizontalAlignment(gfx::ALIGN_CENTER); 266 SetHorizontalAlignment(gfx::ALIGN_CENTER);
267 267
268 in_menu_background_ = new InMenuButtonBackground(type); 268 in_menu_background_ = new InMenuButtonBackground(type);
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 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 22 matching lines...) Expand all
312 class WrenchMenuView : public views::View, 312 class WrenchMenuView : public views::View,
313 public views::ButtonListener, 313 public views::ButtonListener,
314 public WrenchMenuObserver { 314 public WrenchMenuObserver {
315 public: 315 public:
316 WrenchMenuView(WrenchMenu* menu, MenuModel* menu_model) 316 WrenchMenuView(WrenchMenu* menu, MenuModel* menu_model)
317 : menu_(menu), 317 : menu_(menu),
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 ~WrenchMenuView() override {
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 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
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 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:
378 // Hosting WrenchMenu. 378 // Hosting WrenchMenu.
379 // WARNING: this may be NULL during shutdown. 379 // WARNING: this may be NULL during shutdown.
380 WrenchMenu* menu_; 380 WrenchMenu* menu_;
381 381
382 // The menu model containing the increment/decrement/reset items. 382 // The menu model containing the increment/decrement/reset items.
383 // WARNING: this may be NULL during shutdown. 383 // WARNING: this may be NULL during shutdown.
384 MenuModel* menu_model_; 384 MenuModel* menu_model_;
385 385
386 DISALLOW_COPY_AND_ASSIGN(WrenchMenuView); 386 DISALLOW_COPY_AND_ASSIGN(WrenchMenuView);
387 }; 387 };
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 ~HoveredImageSource() override {}
397 397
398 virtual gfx::ImageSkiaRep GetImageForScale(float scale) override { 398 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
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 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 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 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
462 const ui::Event& event) override {
463 menu()->CancelAndEvaluate(menu_model(), sender->tag()); 462 menu()->CancelAndEvaluate(menu_model(), sender->tag());
464 } 463 }
465 464
466 private: 465 private:
467 // Returns the max preferred width of all the children. 466 // Returns the max preferred width of all the children.
468 int GetMaxChildViewPreferredWidth() const { 467 int GetMaxChildViewPreferredWidth() const {
469 int width = 0; 468 int width = 0;
470 for (int i = 0; i < child_count(); ++i) 469 for (int i = 0; i < child_count(); ++i)
471 width = std::max(width, child_at(i)->GetPreferredSize().width()); 470 width = std::max(width, child_at(i)->GetPreferredSize().width());
472 return width; 471 return width;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 fullscreen_button_->SetAccessibleName( 545 fullscreen_button_->SetAccessibleName(
547 GetAccessibleNameForWrenchMenuItem( 546 GetAccessibleNameForWrenchMenuItem(
548 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); 547 menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN));
549 AddChildView(fullscreen_button_); 548 AddChildView(fullscreen_button_);
550 549
551 // Need to set a font list for the zoom label width calculations. 550 // Need to set a font list for the zoom label width calculations.
552 OnNativeThemeChanged(NULL); 551 OnNativeThemeChanged(NULL);
553 UpdateZoomControls(); 552 UpdateZoomControls();
554 } 553 }
555 554
556 virtual ~ZoomView() {} 555 ~ZoomView() override {}
557 556
558 // Overridden from View. 557 // Overridden from View.
559 virtual gfx::Size GetPreferredSize() const override { 558 gfx::Size GetPreferredSize() const override {
560 // The increment/decrement button are forced to the same width. 559 // The increment/decrement button are forced to the same width.
561 int button_width = std::max(increment_button_->GetPreferredSize().width(), 560 int button_width = std::max(increment_button_->GetPreferredSize().width(),
562 decrement_button_->GetPreferredSize().width()); 561 decrement_button_->GetPreferredSize().width());
563 int fullscreen_width = 562 int fullscreen_width =
564 fullscreen_button_->GetPreferredSize().width() + kFullscreenPadding; 563 fullscreen_button_->GetPreferredSize().width() + kFullscreenPadding;
565 // Returned height doesn't matter as MenuItemView forces everything to the 564 // Returned height doesn't matter as MenuItemView forces everything to the
566 // height of the menuitemview. Note that we have overridden the height when 565 // height of the menuitemview. Note that we have overridden the height when
567 // constructing the menu. 566 // constructing the menu.
568 return gfx::Size(button_width + zoom_label_width_ + button_width + 567 return gfx::Size(button_width + zoom_label_width_ + button_width +
569 fullscreen_width, 0); 568 fullscreen_width, 0);
570 } 569 }
571 570
572 virtual void Layout() override { 571 void Layout() override {
573 int x = 0; 572 int x = 0;
574 int button_width = std::max(increment_button_->GetPreferredSize().width(), 573 int button_width = std::max(increment_button_->GetPreferredSize().width(),
575 decrement_button_->GetPreferredSize().width()); 574 decrement_button_->GetPreferredSize().width());
576 gfx::Rect bounds(0, 0, button_width, height()); 575 gfx::Rect bounds(0, 0, button_width, height());
577 576
578 decrement_button_->SetBoundsRect(bounds); 577 decrement_button_->SetBoundsRect(bounds);
579 578
580 x += bounds.width(); 579 x += bounds.width();
581 bounds.set_x(x); 580 bounds.set_x(x);
582 bounds.set_width(zoom_label_width_); 581 bounds.set_width(zoom_label_width_);
583 zoom_label_->SetBoundsRect(bounds); 582 zoom_label_->SetBoundsRect(bounds);
584 583
585 x += bounds.width(); 584 x += bounds.width();
586 bounds.set_x(x); 585 bounds.set_x(x);
587 bounds.set_width(button_width); 586 bounds.set_width(button_width);
588 increment_button_->SetBoundsRect(bounds); 587 increment_button_->SetBoundsRect(bounds);
589 588
590 x += bounds.width(); 589 x += bounds.width();
591 bounds.set_x(x); 590 bounds.set_x(x);
592 bounds.set_width(fullscreen_button_->GetPreferredSize().width() + 591 bounds.set_width(fullscreen_button_->GetPreferredSize().width() +
593 kFullscreenPadding); 592 kFullscreenPadding);
594 fullscreen_button_->SetBoundsRect(bounds); 593 fullscreen_button_->SetBoundsRect(bounds);
595 } 594 }
596 595
597 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override { 596 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
598 WrenchMenuView::OnNativeThemeChanged(theme); 597 WrenchMenuView::OnNativeThemeChanged(theme);
599 598
600 const MenuConfig& menu_config = MenuConfig::instance(theme); 599 const MenuConfig& menu_config = MenuConfig::instance(theme);
601 zoom_label_->SetBorder(views::Border::CreateEmptyBorder( 600 zoom_label_->SetBorder(views::Border::CreateEmptyBorder(
602 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding)); 601 0, kZoomLabelHorizontalPadding, 0, kZoomLabelHorizontalPadding));
603 zoom_label_->SetFontList(menu_config.font_list); 602 zoom_label_->SetFontList(menu_config.font_list);
604 zoom_label_width_ = MaxWidthForZoomLabel(); 603 zoom_label_width_ = MaxWidthForZoomLabel();
605 604
606 if (theme) { 605 if (theme) {
607 zoom_label_->SetEnabledColor(theme->GetSystemColor( 606 zoom_label_->SetEnabledColor(theme->GetSystemColor(
608 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor)); 607 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor));
609 gfx::ImageSkia* full_screen_image = 608 gfx::ImageSkia* full_screen_image =
610 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 609 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
611 IDR_FULLSCREEN_MENU_BUTTON); 610 IDR_FULLSCREEN_MENU_BUTTON);
612 SkColor fg_color = theme->GetSystemColor( 611 SkColor fg_color = theme->GetSystemColor(
613 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor); 612 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor);
614 gfx::ImageSkia hovered_fullscreen_image( 613 gfx::ImageSkia hovered_fullscreen_image(
615 new HoveredImageSource(*full_screen_image, fg_color), 614 new HoveredImageSource(*full_screen_image, fg_color),
616 full_screen_image->size()); 615 full_screen_image->size());
617 fullscreen_button_->SetImage( 616 fullscreen_button_->SetImage(
618 ImageButton::STATE_HOVERED, &hovered_fullscreen_image); 617 ImageButton::STATE_HOVERED, &hovered_fullscreen_image);
619 fullscreen_button_->SetImage( 618 fullscreen_button_->SetImage(
620 ImageButton::STATE_PRESSED, &hovered_fullscreen_image); 619 ImageButton::STATE_PRESSED, &hovered_fullscreen_image);
621 } 620 }
622 } 621 }
623 622
624 // Overridden from ButtonListener. 623 // Overridden from ButtonListener.
625 virtual void ButtonPressed(views::Button* sender, 624 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
626 const ui::Event& event) override {
627 if (sender->tag() == fullscreen_index_) { 625 if (sender->tag() == fullscreen_index_) {
628 menu()->CancelAndEvaluate(menu_model(), sender->tag()); 626 menu()->CancelAndEvaluate(menu_model(), sender->tag());
629 } else { 627 } else {
630 // Zoom buttons don't close the menu. 628 // Zoom buttons don't close the menu.
631 menu_model()->ActivatedAt(sender->tag()); 629 menu_model()->ActivatedAt(sender->tag());
632 } 630 }
633 } 631 }
634 632
635 // Overridden from WrenchMenuObserver. 633 // Overridden from WrenchMenuObserver.
636 virtual void WrenchMenuDestroyed() override { 634 void WrenchMenuDestroyed() override { WrenchMenuView::WrenchMenuDestroyed(); }
637 WrenchMenuView::WrenchMenuDestroyed();
638 }
639 635
640 private: 636 private:
641 void OnZoomLevelChanged(const HostZoomMap::ZoomLevelChange& change) { 637 void OnZoomLevelChanged(const HostZoomMap::ZoomLevelChange& change) {
642 UpdateZoomControls(); 638 UpdateZoomControls();
643 } 639 }
644 640
645 void UpdateZoomControls() { 641 void UpdateZoomControls() {
646 WebContents* selected_tab = 642 WebContents* selected_tab =
647 menu()->browser_->tab_strip_model()->GetActiveWebContents(); 643 menu()->browser_->tab_strip_model()->GetActiveWebContents();
648 int zoom = 100; 644 int zoom = 100;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 public: 712 public:
717 RecentTabsMenuModelDelegate(WrenchMenu* wrench_menu, 713 RecentTabsMenuModelDelegate(WrenchMenu* wrench_menu,
718 ui::MenuModel* model, 714 ui::MenuModel* model,
719 views::MenuItemView* menu_item) 715 views::MenuItemView* menu_item)
720 : wrench_menu_(wrench_menu), 716 : wrench_menu_(wrench_menu),
721 model_(model), 717 model_(model),
722 menu_item_(menu_item) { 718 menu_item_(menu_item) {
723 model_->SetMenuModelDelegate(this); 719 model_->SetMenuModelDelegate(this);
724 } 720 }
725 721
726 virtual ~RecentTabsMenuModelDelegate() { 722 ~RecentTabsMenuModelDelegate() override {
727 model_->SetMenuModelDelegate(NULL); 723 model_->SetMenuModelDelegate(NULL);
728 } 724 }
729 725
730 const gfx::FontList* GetLabelFontListAt(int index) const { 726 const gfx::FontList* GetLabelFontListAt(int index) const {
731 return model_->GetLabelFontListAt(index); 727 return model_->GetLabelFontListAt(index);
732 } 728 }
733 729
734 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const { 730 bool GetShouldUseDisabledEmphasizedForegroundColor(int index) const {
735 // The items for which we get a font list, should be shown in the bolded 731 // The items for which we get a font list, should be shown in the bolded
736 // color. 732 // color.
737 return GetLabelFontListAt(index) ? true : false; 733 return GetLabelFontListAt(index) ? true : false;
738 } 734 }
739 735
740 // ui::MenuModelDelegate implementation: 736 // ui::MenuModelDelegate implementation:
741 737
742 virtual void OnIconChanged(int index) override { 738 void OnIconChanged(int index) override {
743 int command_id = model_->GetCommandIdAt(index); 739 int command_id = model_->GetCommandIdAt(index);
744 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id); 740 views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id);
745 DCHECK(item); 741 DCHECK(item);
746 gfx::Image icon; 742 gfx::Image icon;
747 model_->GetIconAt(index, &icon); 743 model_->GetIconAt(index, &icon);
748 item->SetIcon(*icon.ToImageSkia()); 744 item->SetIcon(*icon.ToImageSkia());
749 } 745 }
750 746
751 virtual void OnMenuStructureChanged() override { 747 void OnMenuStructureChanged() override {
752 if (menu_item_->HasSubmenu()) { 748 if (menu_item_->HasSubmenu()) {
753 // Remove all menu items from submenu. 749 // Remove all menu items from submenu.
754 views::SubmenuView* submenu = menu_item_->GetSubmenu(); 750 views::SubmenuView* submenu = menu_item_->GetSubmenu();
755 while (submenu->child_count() > 0) 751 while (submenu->child_count() > 0)
756 menu_item_->RemoveMenuItemAt(submenu->child_count() - 1); 752 menu_item_->RemoveMenuItemAt(submenu->child_count() - 1);
757 753
758 // Remove all elements in |WrenchMenu::command_id_to_entry_| that map to 754 // Remove all elements in |WrenchMenu::command_id_to_entry_| that map to
759 // |model_|. 755 // |model_|.
760 WrenchMenu::CommandIDToEntry::iterator iter = 756 WrenchMenu::CommandIDToEntry::iterator iter =
761 wrench_menu_->command_id_to_entry_.begin(); 757 wrench_menu_->command_id_to_entry_.begin();
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 0, 1239 0,
1244 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1240 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1245 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); 1241 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU);
1246 } 1242 }
1247 1243
1248 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { 1244 int WrenchMenu::ModelIndexFromCommandId(int command_id) const {
1249 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1245 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1250 DCHECK(ix != command_id_to_entry_.end()); 1246 DCHECK(ix != command_id_to_entry_.end());
1251 return ix->second.second; 1247 return ix->second.second;
1252 } 1248 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/wrench_menu.h ('k') | chrome/browser/ui/views/toolbar/wrench_toolbar_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698