| 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" |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 #if defined(OS_WIN) | 948 #if defined(OS_WIN) |
| 949 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), | 949 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), |
| 950 ui::ResourceBundle::GetSharedInstance(). | 950 ui::ResourceBundle::GetSharedInstance(). |
| 951 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); | 951 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); |
| 952 #endif | 952 #endif |
| 953 | 953 |
| 954 AddGlobalErrorMenuItems(); | 954 AddGlobalErrorMenuItems(); |
| 955 | 955 |
| 956 AddSeparator(ui::NORMAL_SEPARATOR); | 956 AddSeparator(ui::NORMAL_SEPARATOR); |
| 957 AddSubMenuWithStringId( | 957 AddSubMenuWithStringId( |
| 958 IDC_ZOOM_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); | 958 IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); |
| 959 | 959 |
| 960 bool show_exit_menu = browser_defaults::kShowExitMenuItem; | 960 bool show_exit_menu = browser_defaults::kShowExitMenuItem; |
| 961 #if defined(OS_WIN) | 961 #if defined(OS_WIN) |
| 962 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 962 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
| 963 show_exit_menu = false; | 963 show_exit_menu = false; |
| 964 #endif | 964 #endif |
| 965 | 965 |
| 966 if (show_exit_menu) { | 966 if (show_exit_menu) { |
| 967 AddSeparator(ui::NORMAL_SEPARATOR); | 967 AddSeparator(ui::NORMAL_SEPARATOR); |
| 968 AddItemWithStringId(IDC_EXIT, IDS_EXIT); | 968 AddItemWithStringId(IDC_EXIT, IDS_EXIT); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 if (!extensions::ExtensionToolbarModel::Get(browser_->profile())-> | 1020 if (!extensions::ExtensionToolbarModel::Get(browser_->profile())-> |
| 1021 all_icons_visible()) { | 1021 all_icons_visible()) { |
| 1022 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); | 1022 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); |
| 1023 AddSeparator(ui::UPPER_SEPARATOR); | 1023 AddSeparator(ui::UPPER_SEPARATOR); |
| 1024 } | 1024 } |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 void WrenchMenuModel::CreateCutCopyPasteMenu() { | 1027 void WrenchMenuModel::CreateCutCopyPasteMenu() { |
| 1028 AddSeparator(ui::LOWER_SEPARATOR); | 1028 AddSeparator(ui::LOWER_SEPARATOR); |
| 1029 | 1029 |
| 1030 #if defined(OS_MACOSX) | |
| 1031 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the | 1030 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the |
| 1032 // layout for this menu item in Toolbar.xib. It does, however, use the | 1031 // layout for this menu item in WrenchMenu.xib. It does, however, use the |
| 1033 // command_id value from AddButtonItem() to identify this special item. | 1032 // command_id value from AddButtonItem() to identify this special item. |
| 1034 edit_menu_item_model_.reset(new ui::ButtonMenuItemModel(IDS_EDIT, this)); | 1033 edit_menu_item_model_.reset(new ui::ButtonMenuItemModel(IDS_EDIT, this)); |
| 1035 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT); | 1034 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT); |
| 1036 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY); | 1035 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY); |
| 1037 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE); | 1036 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE); |
| 1038 AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get()); | 1037 AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get()); |
| 1039 #else | |
| 1040 // WARNING: views/wrench_menu assumes these items are added in this order. If | |
| 1041 // you change the order you'll need to update wrench_menu as well. | |
| 1042 AddItemWithStringId(IDC_CUT, IDS_CUT); | |
| 1043 AddItemWithStringId(IDC_COPY, IDS_COPY); | |
| 1044 AddItemWithStringId(IDC_PASTE, IDS_PASTE); | |
| 1045 #endif | |
| 1046 | 1038 |
| 1047 AddSeparator(ui::UPPER_SEPARATOR); | 1039 AddSeparator(ui::UPPER_SEPARATOR); |
| 1048 } | 1040 } |
| 1049 | 1041 |
| 1050 void WrenchMenuModel::CreateZoomMenu() { | 1042 void WrenchMenuModel::CreateZoomMenu() { |
| 1051 // This menu needs to be enclosed by separators. | 1043 // This menu needs to be enclosed by separators. |
| 1052 AddSeparator(ui::LOWER_SEPARATOR); | 1044 AddSeparator(ui::LOWER_SEPARATOR); |
| 1053 | 1045 |
| 1054 #if defined(OS_MACOSX) | |
| 1055 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the | 1046 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the |
| 1056 // layout for this menu item in Toolbar.xib. It does, however, use the | 1047 // layout for this menu item in WrenchMenu.xib. It does, however, use the |
| 1057 // command_id value from AddButtonItem() to identify this special item. | 1048 // command_id value from AddButtonItem() to identify this special item. |
| 1058 zoom_menu_item_model_.reset( | 1049 zoom_menu_item_model_.reset( |
| 1059 new ui::ButtonMenuItemModel(IDS_ZOOM_MENU, this)); | 1050 new ui::ButtonMenuItemModel(IDS_ZOOM_MENU, this)); |
| 1060 zoom_menu_item_model_->AddGroupItemWithStringId( | 1051 zoom_menu_item_model_->AddGroupItemWithStringId(IDC_ZOOM_MINUS, |
| 1061 IDC_ZOOM_MINUS, IDS_ZOOM_MINUS2); | 1052 IDS_ZOOM_MINUS2); |
| 1062 zoom_menu_item_model_->AddButtonLabel(IDC_ZOOM_PERCENT_DISPLAY, | 1053 zoom_menu_item_model_->AddGroupItemWithStringId(IDC_ZOOM_PLUS, |
| 1063 IDS_ZOOM_PLUS2); | 1054 IDS_ZOOM_PLUS2); |
| 1064 zoom_menu_item_model_->AddGroupItemWithStringId( | 1055 zoom_menu_item_model_->AddItemWithImage(IDC_FULLSCREEN, |
| 1065 IDC_ZOOM_PLUS, IDS_ZOOM_PLUS2); | 1056 IDR_FULLSCREEN_MENU_BUTTON); |
| 1066 zoom_menu_item_model_->AddSpace(); | |
| 1067 zoom_menu_item_model_->AddItemWithImage( | |
| 1068 IDC_FULLSCREEN, IDR_FULLSCREEN_MENU_BUTTON); | |
| 1069 AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get()); | 1057 AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get()); |
| 1070 #else | |
| 1071 // WARNING: views/wrench_menu assumes these items are added in this order. If | |
| 1072 // you change the order you'll need to update wrench_menu as well. | |
| 1073 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); | |
| 1074 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); | |
| 1075 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); | |
| 1076 #endif | |
| 1077 | 1058 |
| 1078 AddSeparator(ui::UPPER_SEPARATOR); | 1059 AddSeparator(ui::UPPER_SEPARATOR); |
| 1079 } | 1060 } |
| 1080 | 1061 |
| 1081 void WrenchMenuModel::UpdateZoomControls() { | 1062 void WrenchMenuModel::UpdateZoomControls() { |
| 1082 int zoom_percent = 100; | 1063 int zoom_percent = 100; |
| 1083 if (browser_->tab_strip_model()->GetActiveWebContents()) { | 1064 if (browser_->tab_strip_model()->GetActiveWebContents()) { |
| 1084 zoom_percent = ui_zoom::ZoomController::FromWebContents( | 1065 zoom_percent = ui_zoom::ZoomController::FromWebContents( |
| 1085 browser_->tab_strip_model()->GetActiveWebContents()) | 1066 browser_->tab_strip_model()->GetActiveWebContents()) |
| 1086 ->GetZoomPercent(); | 1067 ->GetZoomPercent(); |
| 1087 } | 1068 } |
| 1088 zoom_label_ = l10n_util::GetStringFUTF16( | 1069 zoom_label_ = l10n_util::GetStringFUTF16( |
| 1089 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 1070 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 1090 } | 1071 } |
| 1091 | 1072 |
| 1092 void WrenchMenuModel::OnZoomLevelChanged( | 1073 void WrenchMenuModel::OnZoomLevelChanged( |
| 1093 const content::HostZoomMap::ZoomLevelChange& change) { | 1074 const content::HostZoomMap::ZoomLevelChange& change) { |
| 1094 UpdateZoomControls(); | 1075 UpdateZoomControls(); |
| 1095 } | 1076 } |
| OLD | NEW |