OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/toolbar_view.h" | 5 #include "chrome/browser/views/toolbar_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/drag_drop_types.h" | 9 #include "app/drag_drop_types.h" |
10 #include "app/gfx/chrome_canvas.h" | 10 #include "app/gfx/chrome_canvas.h" |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 return gfx::Size(min_width, normal_background.height()); | 575 return gfx::Size(min_width, normal_background.height()); |
576 } | 576 } |
577 | 577 |
578 int vertical_spacing = PopupTopSpacing() + | 578 int vertical_spacing = PopupTopSpacing() + |
579 (GetWindow()->GetNonClientView()->UseNativeFrame() ? | 579 (GetWindow()->GetNonClientView()->UseNativeFrame() ? |
580 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); | 580 kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass); |
581 return gfx::Size(0, location_bar_->GetPreferredSize().height() + | 581 return gfx::Size(0, location_bar_->GetPreferredSize().height() + |
582 vertical_spacing); | 582 vertical_spacing); |
583 } | 583 } |
584 | 584 |
585 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) { | 585 void BrowserToolbarView::RunPageMenu(const gfx::Point& pt, HWND hwnd) { |
586 Menu::AnchorPoint anchor = Menu::TOPRIGHT; | 586 Menu::AnchorPoint anchor = Menu::TOPRIGHT; |
587 if (UILayoutIsRightToLeft()) | 587 if (UILayoutIsRightToLeft()) |
588 anchor = Menu::TOPLEFT; | 588 anchor = Menu::TOPLEFT; |
589 | 589 |
590 Menu menu(this, anchor, hwnd); | 590 Menu menu(this, anchor, hwnd); |
591 menu.AppendMenuItemWithLabel(IDC_CREATE_SHORTCUTS, | 591 menu.AppendMenuItemWithLabel(IDC_CREATE_SHORTCUTS, |
592 l10n_util::GetString(IDS_CREATE_SHORTCUTS)); | 592 l10n_util::GetString(IDS_CREATE_SHORTCUTS)); |
593 menu.AppendSeparator(); | 593 menu.AppendSeparator(); |
594 menu.AppendMenuItemWithLabel(IDC_CUT, l10n_util::GetString(IDS_CUT)); | 594 menu.AppendMenuItemWithLabel(IDC_CUT, l10n_util::GetString(IDS_CUT)); |
595 menu.AppendMenuItemWithLabel(IDC_COPY, l10n_util::GetString(IDS_COPY)); | 595 menu.AppendMenuItemWithLabel(IDC_COPY, l10n_util::GetString(IDS_COPY)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 l10n_util::GetString(developer_menu_materials[i].menu_label_id)); | 639 l10n_util::GetString(developer_menu_materials[i].menu_label_id)); |
640 } else { | 640 } else { |
641 developer_menu->AppendSeparator(); | 641 developer_menu->AppendSeparator(); |
642 } | 642 } |
643 } | 643 } |
644 | 644 |
645 menu.AppendSeparator(); | 645 menu.AppendSeparator(); |
646 | 646 |
647 menu.AppendMenuItemWithLabel(IDC_REPORT_BUG, | 647 menu.AppendMenuItemWithLabel(IDC_REPORT_BUG, |
648 l10n_util::GetString(IDS_REPORT_BUG)); | 648 l10n_util::GetString(IDS_REPORT_BUG)); |
649 menu.RunMenuAt(pt.x, pt.y); | 649 menu.RunMenuAt(pt.x(), pt.y()); |
650 } | 650 } |
651 | 651 |
652 void BrowserToolbarView::RunAppMenu(const CPoint& pt, HWND hwnd) { | 652 void BrowserToolbarView::RunAppMenu(const gfx::Point& pt, HWND hwnd) { |
653 Menu::AnchorPoint anchor = Menu::TOPRIGHT; | 653 Menu::AnchorPoint anchor = Menu::TOPRIGHT; |
654 if (UILayoutIsRightToLeft()) | 654 if (UILayoutIsRightToLeft()) |
655 anchor = Menu::TOPLEFT; | 655 anchor = Menu::TOPLEFT; |
656 | 656 |
657 Menu menu(this, anchor, hwnd); | 657 Menu menu(this, anchor, hwnd); |
658 menu.AppendMenuItemWithLabel(IDC_NEW_TAB, l10n_util::GetString(IDS_NEW_TAB)); | 658 menu.AppendMenuItemWithLabel(IDC_NEW_TAB, l10n_util::GetString(IDS_NEW_TAB)); |
659 menu.AppendMenuItemWithLabel(IDC_NEW_WINDOW, | 659 menu.AppendMenuItemWithLabel(IDC_NEW_WINDOW, |
660 l10n_util::GetString(IDS_NEW_WINDOW)); | 660 l10n_util::GetString(IDS_NEW_WINDOW)); |
661 menu.AppendMenuItemWithLabel(IDC_NEW_INCOGNITO_WINDOW, | 661 menu.AppendMenuItemWithLabel(IDC_NEW_INCOGNITO_WINDOW, |
662 l10n_util::GetString(IDS_NEW_INCOGNITO_WINDOW)); | 662 l10n_util::GetString(IDS_NEW_INCOGNITO_WINDOW)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 menu.AppendSeparator(); | 697 menu.AppendSeparator(); |
698 menu.AppendMenuItemWithLabel(IDC_OPTIONS, l10n_util::GetStringF(IDS_OPTIONS, | 698 menu.AppendMenuItemWithLabel(IDC_OPTIONS, l10n_util::GetStringF(IDS_OPTIONS, |
699 l10n_util::GetString(IDS_PRODUCT_NAME))); | 699 l10n_util::GetString(IDS_PRODUCT_NAME))); |
700 menu.AppendMenuItemWithLabel(IDC_ABOUT, l10n_util::GetStringF(IDS_ABOUT, | 700 menu.AppendMenuItemWithLabel(IDC_ABOUT, l10n_util::GetStringF(IDS_ABOUT, |
701 l10n_util::GetString(IDS_PRODUCT_NAME))); | 701 l10n_util::GetString(IDS_PRODUCT_NAME))); |
702 menu.AppendMenuItemWithLabel(IDC_HELP_PAGE, | 702 menu.AppendMenuItemWithLabel(IDC_HELP_PAGE, |
703 l10n_util::GetString(IDS_HELP_PAGE)); | 703 l10n_util::GetString(IDS_HELP_PAGE)); |
704 menu.AppendSeparator(); | 704 menu.AppendSeparator(); |
705 menu.AppendMenuItemWithLabel(IDC_EXIT, l10n_util::GetString(IDS_EXIT)); | 705 menu.AppendMenuItemWithLabel(IDC_EXIT, l10n_util::GetString(IDS_EXIT)); |
706 | 706 |
707 menu.RunMenuAt(pt.x, pt.y); | 707 menu.RunMenuAt(pt.x(), pt.y()); |
708 | 708 |
709 // Menu is going away, so set the profiles menu pointer to NULL. | 709 // Menu is going away, so set the profiles menu pointer to NULL. |
710 profiles_menu_ = NULL; | 710 profiles_menu_ = NULL; |
711 } | 711 } |
712 | 712 |
713 bool BrowserToolbarView::IsItemChecked(int id) const { | 713 bool BrowserToolbarView::IsItemChecked(int id) const { |
714 if (!profile_) | 714 if (!profile_) |
715 return false; | 715 return false; |
716 if (id == IDC_SHOW_BOOKMARK_BAR) | 716 if (id == IDC_SHOW_BOOKMARK_BAR) |
717 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 717 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
718 return EncodingMenuControllerDelegate::IsItemChecked(id); | 718 return EncodingMenuControllerDelegate::IsItemChecked(id); |
719 } | 719 } |
720 | 720 |
721 void BrowserToolbarView::RunMenu(views::View* source, const CPoint& pt, | 721 void BrowserToolbarView::RunMenu(views::View* source, const gfx::Point& pt, |
722 HWND hwnd) { | 722 HWND hwnd) { |
723 switch (source->GetID()) { | 723 switch (source->GetID()) { |
724 case VIEW_ID_PAGE_MENU: | 724 case VIEW_ID_PAGE_MENU: |
725 RunPageMenu(pt, hwnd); | 725 RunPageMenu(pt, hwnd); |
726 break; | 726 break; |
727 case VIEW_ID_APP_MENU: | 727 case VIEW_ID_APP_MENU: |
728 RunAppMenu(pt, hwnd); | 728 RunAppMenu(pt, hwnd); |
729 break; | 729 break; |
730 default: | 730 default: |
731 NOTREACHED() << "Invalid source menu."; | 731 NOTREACHED() << "Invalid source menu."; |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 case IDC_COPY: | 945 case IDC_COPY: |
946 *accel = views::Accelerator(L'C', false, true, false); | 946 *accel = views::Accelerator(L'C', false, true, false); |
947 return true; | 947 return true; |
948 case IDC_PASTE: | 948 case IDC_PASTE: |
949 *accel = views::Accelerator(L'V', false, true, false); | 949 *accel = views::Accelerator(L'V', false, true, false); |
950 return true; | 950 return true; |
951 } | 951 } |
952 // Else, we retrieve the accelerator information from the frame. | 952 // Else, we retrieve the accelerator information from the frame. |
953 return GetWidget()->GetAccelerator(id, accel); | 953 return GetWidget()->GetAccelerator(id, accel); |
954 } | 954 } |
OLD | NEW |