OLD | NEW |
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/toolbar/wrench_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
| 18 #include "chrome/browser/extensions/extension_toolbar_model.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/search/search.h" | 21 #include "chrome/browser/search/search.h" |
21 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
22 #include "chrome/browser/signin/signin_ui_util.h" | 23 #include "chrome/browser/signin/signin_ui_util.h" |
23 #include "chrome/browser/task_manager/task_manager.h" | 24 #include "chrome/browser/task_manager/task_manager.h" |
24 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 25 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
27 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), | 734 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), |
734 image); | 735 image); |
735 } | 736 } |
736 } | 737 } |
737 } | 738 } |
738 } | 739 } |
739 | 740 |
740 void WrenchMenuModel::CreateExtensionToolbarOverflowMenu() { | 741 void WrenchMenuModel::CreateExtensionToolbarOverflowMenu() { |
741 #if defined(TOOLKIT_VIEWS) | 742 #if defined(TOOLKIT_VIEWS) |
742 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); | 743 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); |
743 // TODO(devlin): Add the separator only if there are > 0 icons to show. | 744 // We only add the separator if there are > 0 items to show in the overflow. |
744 AddSeparator(ui::UPPER_SEPARATOR); | 745 extensions::ExtensionToolbarModel* toolbar_model = |
| 746 extensions::ExtensionToolbarModel::Get(browser_->profile()); |
| 747 // A count of -1 means all actions are visible. |
| 748 if (toolbar_model->GetVisibleIconCount() != -1) |
| 749 AddSeparator(ui::UPPER_SEPARATOR); |
745 #endif // defined(TOOLKIT_VIEWS) | 750 #endif // defined(TOOLKIT_VIEWS) |
746 } | 751 } |
747 | 752 |
748 void WrenchMenuModel::CreateCutCopyPasteMenu(bool new_menu) { | 753 void WrenchMenuModel::CreateCutCopyPasteMenu(bool new_menu) { |
749 AddSeparator(new_menu ? ui::LOWER_SEPARATOR : ui::NORMAL_SEPARATOR); | 754 AddSeparator(new_menu ? ui::LOWER_SEPARATOR : ui::NORMAL_SEPARATOR); |
750 | 755 |
751 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) | 756 #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) |
752 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the | 757 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the |
753 // layout for this menu item in Toolbar.xib. It does, however, use the | 758 // layout for this menu item in Toolbar.xib. It does, however, use the |
754 // command_id value from AddButtonItem() to identify this special item. | 759 // command_id value from AddButtonItem() to identify this special item. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 ->GetZoomPercent(); | 813 ->GetZoomPercent(); |
809 } | 814 } |
810 zoom_label_ = l10n_util::GetStringFUTF16( | 815 zoom_label_ = l10n_util::GetStringFUTF16( |
811 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 816 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
812 } | 817 } |
813 | 818 |
814 void WrenchMenuModel::OnZoomLevelChanged( | 819 void WrenchMenuModel::OnZoomLevelChanged( |
815 const content::HostZoomMap::ZoomLevelChange& change) { | 820 const content::HostZoomMap::ZoomLevelChange& change) { |
816 UpdateZoomControls(); | 821 UpdateZoomControls(); |
817 } | 822 } |
OLD | NEW |