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

Side by Side Diff: chrome/browser/ui/toolbar/app_menu_model.cc

Issue 2254273003: Remove text encoding UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 months 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 (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/app_menu_model.h" 5 #include "chrome/browser/ui/toolbar/app_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 19 matching lines...) Expand all
30 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 30 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
31 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_commands.h" 32 #include "chrome/browser/ui/browser_commands.h"
33 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
34 #include "chrome/browser/ui/browser_window.h" 34 #include "chrome/browser/ui/browser_window.h"
35 #include "chrome/browser/ui/global_error/global_error.h" 35 #include "chrome/browser/ui/global_error/global_error.h"
36 #include "chrome/browser/ui/global_error/global_error_service.h" 36 #include "chrome/browser/ui/global_error/global_error_service.h"
37 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 37 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" 38 #include "chrome/browser/ui/tabs/tab_strip_model.h"
39 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" 39 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h"
40 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
41 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" 40 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h"
42 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 41 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
43 #include "chrome/browser/upgrade_detector.h" 42 #include "chrome/browser/upgrade_detector.h"
44 #include "chrome/common/chrome_paths.h" 43 #include "chrome/common/chrome_paths.h"
45 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
46 #include "chrome/common/profiling.h" 45 #include "chrome/common/profiling.h"
47 #include "chrome/grit/chromium_strings.h" 46 #include "chrome/grit/chromium_strings.h"
48 #include "chrome/grit/generated_resources.h" 47 #include "chrome/grit/generated_resources.h"
49 #include "chrome/grit/theme_resources.h" 48 #include "chrome/grit/theme_resources.h"
50 #include "components/bookmarks/common/bookmark_pref_names.h" 49 #include "components/bookmarks/common/bookmark_pref_names.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 UpgradeDetector::GetInstance()->is_outdated_install_no_au()) { 102 UpgradeDetector::GetInstance()->is_outdated_install_no_au()) {
104 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_MENU_ITEM); 103 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_MENU_ITEM);
105 } else { 104 } else {
106 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); 105 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW);
107 } 106 }
108 } 107 }
109 108
110 } // namespace 109 } // namespace
111 110
112 //////////////////////////////////////////////////////////////////////////////// 111 ////////////////////////////////////////////////////////////////////////////////
113 // EncodingMenuModel
114
115 EncodingMenuModel::EncodingMenuModel(Browser* browser)
116 : ui::SimpleMenuModel(this),
117 browser_(browser) {
118 Build();
119 }
120
121 EncodingMenuModel::~EncodingMenuModel() {
122 }
123
124 void EncodingMenuModel::Build() {
125 EncodingMenuController::EncodingMenuItemList encoding_menu_items;
126 EncodingMenuController encoding_menu_controller;
127 encoding_menu_controller.GetEncodingMenuItems(browser_->profile(),
128 &encoding_menu_items);
129
130 int group_id = 0;
131 EncodingMenuController::EncodingMenuItemList::iterator it =
132 encoding_menu_items.begin();
133 for (; it != encoding_menu_items.end(); ++it) {
134 int id = it->first;
135 base::string16& label = it->second;
136 if (id == 0) {
137 AddSeparator(ui::NORMAL_SEPARATOR);
138 } else {
139 if (id == IDC_ENCODING_AUTO_DETECT) {
140 AddCheckItem(id, label);
141 } else {
142 // Use the id of the first radio command as the id of the group.
143 if (group_id <= 0)
144 group_id = id;
145 AddRadioItem(id, label, group_id);
146 }
147 }
148 }
149 }
150
151 bool EncodingMenuModel::IsCommandIdChecked(int command_id) const {
152 WebContents* current_tab =
153 browser_->tab_strip_model()->GetActiveWebContents();
154 if (!current_tab)
155 return false;
156 EncodingMenuController controller;
157 return controller.IsItemChecked(browser_->profile(),
158 current_tab->GetEncoding(), command_id);
159 }
160
161 bool EncodingMenuModel::IsCommandIdEnabled(int command_id) const {
162 bool enabled = chrome::IsCommandEnabled(browser_, command_id);
163 // Special handling for the contents of the Encoding submenu. On Mac OS,
164 // instead of enabling/disabling the top-level menu item, the submenu's
165 // contents get disabled, per Apple's HIG.
166 #if defined(OS_MACOSX)
167 enabled &= chrome::IsCommandEnabled(browser_, IDC_ENCODING_MENU);
168 #endif
169 return enabled;
170 }
171
172 void EncodingMenuModel::ExecuteCommand(int command_id, int event_flags) {
173 chrome::ExecuteCommand(browser_, command_id);
174 }
175
176 ////////////////////////////////////////////////////////////////////////////////
177 // ZoomMenuModel 112 // ZoomMenuModel
178 113
179 ZoomMenuModel::ZoomMenuModel(ui::SimpleMenuModel::Delegate* delegate) 114 ZoomMenuModel::ZoomMenuModel(ui::SimpleMenuModel::Delegate* delegate)
180 : SimpleMenuModel(delegate) { 115 : SimpleMenuModel(delegate) {
181 Build(); 116 Build();
182 } 117 }
183 118
184 ZoomMenuModel::~ZoomMenuModel() { 119 ZoomMenuModel::~ZoomMenuModel() {
185 } 120 }
186 121
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 196 }
262 197
263 AddSeparator(ui::NORMAL_SEPARATOR); 198 AddSeparator(ui::NORMAL_SEPARATOR);
264 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); 199 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA);
265 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); 200 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS);
266 if (chrome::CanOpenTaskManager()) 201 if (chrome::CanOpenTaskManager())
267 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); 202 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
268 #if defined(OS_CHROMEOS) 203 #if defined(OS_CHROMEOS)
269 AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT); 204 AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT);
270 #endif 205 #endif
271 encoding_menu_model_.reset(new EncodingMenuModel(browser));
272 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU,
273 encoding_menu_model_.get());
274
275 AddSeparator(ui::NORMAL_SEPARATOR); 206 AddSeparator(ui::NORMAL_SEPARATOR);
276 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); 207 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS);
277 208
278 if (base::debug::IsProfilingSupported()) { 209 if (base::debug::IsProfilingSupported()) {
279 AddSeparator(ui::NORMAL_SEPARATOR); 210 AddSeparator(ui::NORMAL_SEPARATOR);
280 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); 211 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED);
281 } 212 }
282 } 213 }
283 214
284 //////////////////////////////////////////////////////////////////////////////// 215 ////////////////////////////////////////////////////////////////////////////////
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 browser_->tab_strip_model()->GetActiveWebContents()) 865 browser_->tab_strip_model()->GetActiveWebContents())
935 ->GetZoomPercent(); 866 ->GetZoomPercent();
936 } 867 }
937 zoom_label_ = base::FormatPercent(zoom_percent); 868 zoom_label_ = base::FormatPercent(zoom_percent);
938 } 869 }
939 870
940 void AppMenuModel::OnZoomLevelChanged( 871 void AppMenuModel::OnZoomLevelChanged(
941 const content::HostZoomMap::ZoomLevelChange& change) { 872 const content::HostZoomMap::ZoomLevelChange& change) {
942 UpdateZoomControls(); 873 UpdateZoomControls();
943 } 874 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/app_menu_model.h ('k') | chrome/browser/ui/toolbar/app_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698