| 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 "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 455 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 456 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); | 456 normal_background = *rb.GetBitmapNamed(IDR_CONTENT_TOP_CENTER); |
| 457 } | 457 } |
| 458 return gfx::Size(0, normal_background.height()); | 458 return gfx::Size(0, normal_background.height()); |
| 459 } | 459 } |
| 460 | 460 |
| 461 int locbar_height = location_bar_->GetPreferredSize().height(); | 461 int locbar_height = location_bar_->GetPreferredSize().height(); |
| 462 return gfx::Size(0, locbar_height + 2 * kControlVertOffsetLocationOnly); | 462 return gfx::Size(0, locbar_height + 2 * kControlVertOffsetLocationOnly); |
| 463 } | 463 } |
| 464 | 464 |
| 465 void BrowserToolbarView::RunPageMenu(const CPoint& pt, HWND hwnd) { | 465 void BrowserToolbarView::RunPageMenu(const gfx::Point& pt, HWND hwnd) { |
| 466 Menu::AnchorPoint anchor = Menu::TOPRIGHT; | 466 Menu::AnchorPoint anchor = Menu::TOPRIGHT; |
| 467 if (UILayoutIsRightToLeft()) | 467 if (UILayoutIsRightToLeft()) |
| 468 anchor = Menu::TOPLEFT; | 468 anchor = Menu::TOPLEFT; |
| 469 | 469 |
| 470 Menu menu(this, anchor, hwnd); | 470 Menu menu(this, anchor, hwnd); |
| 471 menu.AppendMenuItemWithLabel(IDC_CREATE_SHORTCUTS, | 471 menu.AppendMenuItemWithLabel(IDC_CREATE_SHORTCUTS, |
| 472 l10n_util::GetString(IDS_CREATE_SHORTCUTS)); | 472 l10n_util::GetString(IDS_CREATE_SHORTCUTS)); |
| 473 menu.AppendSeparator(); | 473 menu.AppendSeparator(); |
| 474 menu.AppendMenuItemWithLabel(IDC_CUT, l10n_util::GetString(IDS_CUT)); | 474 menu.AppendMenuItemWithLabel(IDC_CUT, l10n_util::GetString(IDS_CUT)); |
| 475 menu.AppendMenuItemWithLabel(IDC_COPY, l10n_util::GetString(IDS_COPY)); | 475 menu.AppendMenuItemWithLabel(IDC_COPY, l10n_util::GetString(IDS_COPY)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 l10n_util::GetString(developer_menu_materials[i].menu_label_id)); | 519 l10n_util::GetString(developer_menu_materials[i].menu_label_id)); |
| 520 } else { | 520 } else { |
| 521 developer_menu->AppendSeparator(); | 521 developer_menu->AppendSeparator(); |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 menu.AppendSeparator(); | 525 menu.AppendSeparator(); |
| 526 | 526 |
| 527 menu.AppendMenuItemWithLabel(IDC_REPORT_BUG, | 527 menu.AppendMenuItemWithLabel(IDC_REPORT_BUG, |
| 528 l10n_util::GetString(IDS_REPORT_BUG)); | 528 l10n_util::GetString(IDS_REPORT_BUG)); |
| 529 menu.RunMenuAt(pt.x, pt.y); | 529 menu.RunMenuAt(pt.x(), pt.y()); |
| 530 } | 530 } |
| 531 | 531 |
| 532 void BrowserToolbarView::RunAppMenu(const CPoint& pt, HWND hwnd) { | 532 void BrowserToolbarView::RunAppMenu(const gfx::Point& pt, HWND hwnd) { |
| 533 Menu::AnchorPoint anchor = Menu::TOPRIGHT; | 533 Menu::AnchorPoint anchor = Menu::TOPRIGHT; |
| 534 if (UILayoutIsRightToLeft()) | 534 if (UILayoutIsRightToLeft()) |
| 535 anchor = Menu::TOPLEFT; | 535 anchor = Menu::TOPLEFT; |
| 536 | 536 |
| 537 Menu menu(this, anchor, hwnd); | 537 Menu menu(this, anchor, hwnd); |
| 538 menu.AppendMenuItemWithLabel(IDC_NEW_TAB, l10n_util::GetString(IDS_NEW_TAB)); | 538 menu.AppendMenuItemWithLabel(IDC_NEW_TAB, l10n_util::GetString(IDS_NEW_TAB)); |
| 539 menu.AppendMenuItemWithLabel(IDC_NEW_WINDOW, | 539 menu.AppendMenuItemWithLabel(IDC_NEW_WINDOW, |
| 540 l10n_util::GetString(IDS_NEW_WINDOW)); | 540 l10n_util::GetString(IDS_NEW_WINDOW)); |
| 541 menu.AppendMenuItemWithLabel(IDC_NEW_INCOGNITO_WINDOW, | 541 menu.AppendMenuItemWithLabel(IDC_NEW_INCOGNITO_WINDOW, |
| 542 l10n_util::GetString(IDS_NEW_INCOGNITO_WINDOW)); | 542 l10n_util::GetString(IDS_NEW_INCOGNITO_WINDOW)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 566 menu.AppendSeparator(); | 566 menu.AppendSeparator(); |
| 567 menu.AppendMenuItemWithLabel(IDC_OPTIONS, l10n_util::GetStringF(IDS_OPTIONS, | 567 menu.AppendMenuItemWithLabel(IDC_OPTIONS, l10n_util::GetStringF(IDS_OPTIONS, |
| 568 l10n_util::GetString(IDS_PRODUCT_NAME))); | 568 l10n_util::GetString(IDS_PRODUCT_NAME))); |
| 569 menu.AppendMenuItemWithLabel(IDC_ABOUT, l10n_util::GetStringF(IDS_ABOUT, | 569 menu.AppendMenuItemWithLabel(IDC_ABOUT, l10n_util::GetStringF(IDS_ABOUT, |
| 570 l10n_util::GetString(IDS_PRODUCT_NAME))); | 570 l10n_util::GetString(IDS_PRODUCT_NAME))); |
| 571 menu.AppendMenuItemWithLabel(IDC_HELP_PAGE, | 571 menu.AppendMenuItemWithLabel(IDC_HELP_PAGE, |
| 572 l10n_util::GetString(IDS_HELP_PAGE)); | 572 l10n_util::GetString(IDS_HELP_PAGE)); |
| 573 menu.AppendSeparator(); | 573 menu.AppendSeparator(); |
| 574 menu.AppendMenuItemWithLabel(IDC_EXIT, l10n_util::GetString(IDS_EXIT)); | 574 menu.AppendMenuItemWithLabel(IDC_EXIT, l10n_util::GetString(IDS_EXIT)); |
| 575 | 575 |
| 576 menu.RunMenuAt(pt.x, pt.y); | 576 menu.RunMenuAt(pt.x(), pt.y()); |
| 577 | 577 |
| 578 // Menu is going away, so set the profiles menu pointer to NULL. | 578 // Menu is going away, so set the profiles menu pointer to NULL. |
| 579 profiles_menu_ = NULL; | 579 profiles_menu_ = NULL; |
| 580 } | 580 } |
| 581 | 581 |
| 582 bool BrowserToolbarView::IsItemChecked(int id) const { | 582 bool BrowserToolbarView::IsItemChecked(int id) const { |
| 583 if (!profile_) | 583 if (!profile_) |
| 584 return false; | 584 return false; |
| 585 if (id == IDC_SHOW_BOOKMARK_BAR) | 585 if (id == IDC_SHOW_BOOKMARK_BAR) |
| 586 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 586 return profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 587 return EncodingMenuControllerDelegate::IsItemChecked(id); | 587 return EncodingMenuControllerDelegate::IsItemChecked(id); |
| 588 } | 588 } |
| 589 | 589 |
| 590 void BrowserToolbarView::RunMenu(views::View* source, const CPoint& pt, | 590 void BrowserToolbarView::RunMenu(views::View* source, const gfx::Point& pt, |
| 591 HWND hwnd) { | 591 HWND hwnd) { |
| 592 switch (source->GetID()) { | 592 switch (source->GetID()) { |
| 593 case VIEW_ID_PAGE_MENU: | 593 case VIEW_ID_PAGE_MENU: |
| 594 RunPageMenu(pt, hwnd); | 594 RunPageMenu(pt, hwnd); |
| 595 break; | 595 break; |
| 596 case VIEW_ID_APP_MENU: | 596 case VIEW_ID_APP_MENU: |
| 597 RunAppMenu(pt, hwnd); | 597 RunAppMenu(pt, hwnd); |
| 598 break; | 598 break; |
| 599 default: | 599 default: |
| 600 NOTREACHED() << "Invalid source menu."; | 600 NOTREACHED() << "Invalid source menu."; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 *accel = views::Accelerator(L'C', false, true, false); | 752 *accel = views::Accelerator(L'C', false, true, false); |
| 753 return true; | 753 return true; |
| 754 case IDC_PASTE: | 754 case IDC_PASTE: |
| 755 *accel = views::Accelerator(L'V', false, true, false); | 755 *accel = views::Accelerator(L'V', false, true, false); |
| 756 return true; | 756 return true; |
| 757 } | 757 } |
| 758 // Else, we retrieve the accelerator information from the frame. | 758 // Else, we retrieve the accelerator information from the frame. |
| 759 return GetWidget()->GetAccelerator(id, accel); | 759 return GetWidget()->GetAccelerator(id, accel); |
| 760 } | 760 } |
| 761 | 761 |
| OLD | NEW |