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

Side by Side Diff: chrome/browser/wrench_menu_model.cc

Issue 3163035: Revert "Clean up the WrenchMenuModel so that it uses SimpleMenu::Delegate." (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
« no previous file with comments | « chrome/browser/wrench_menu_model.h ('k') | chrome/browser/wrench_menu_model_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/wrench_menu_model.h" 5 #include "chrome/browser/wrench_menu_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/menus/button_menu_item_model.h" 11 #include "app/menus/button_menu_item_model.h"
12 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/app/chrome_dll_resource.h" 17 #include "chrome/app/chrome_dll_resource.h"
18 #include "chrome/browser/browser.h" 18 #include "chrome/browser/browser.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/defaults.h" 20 #include "chrome/browser/defaults.h"
21 #include "chrome/browser/encoding_menu_controller.h" 21 #include "chrome/browser/encoding_menu_controller.h"
22 #include "chrome/browser/host_zoom_map.h" 22 #include "chrome/browser/host_zoom_map.h"
23 #include "chrome/browser/pref_service.h"
24 #include "chrome/browser/profile.h" 23 #include "chrome/browser/profile.h"
25 #include "chrome/browser/sync/profile_sync_service.h" 24 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/sync/sync_ui_util.h" 25 #include "chrome/browser/sync/sync_ui_util.h"
27 #include "chrome/browser/tab_contents/tab_contents.h" 26 #include "chrome/browser/tab_contents/tab_contents.h"
28 #include "chrome/browser/upgrade_detector.h" 27 #include "chrome/browser/upgrade_detector.h"
29 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/notification_service.h" 29 #include "chrome/common/notification_service.h"
31 #include "chrome/common/notification_source.h" 30 #include "chrome/common/notification_source.h"
32 #include "chrome/common/notification_type.h" 31 #include "chrome/common/notification_type.h"
33 #include "chrome/common/pref_names.h"
34 #include "grit/chromium_strings.h" 32 #include "grit/chromium_strings.h"
35 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
36 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
37 35
38 #if defined(OS_LINUX) 36 #if defined(OS_LINUX)
39 #include <gtk/gtk.h> 37 #include <gtk/gtk.h>
40 #endif 38 #endif
41 39
42 #if defined(OS_MACOSX)
43 #include "chrome/browser/browser_window.h"
44 #endif
45
46 //////////////////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////////////////
47 // EncodingMenuModel 41 // EncodingMenuModel
48 42
49 EncodingMenuModel::EncodingMenuModel(Browser* browser) 43 EncodingMenuModel::EncodingMenuModel(Browser* browser)
50 : ALLOW_THIS_IN_INITIALIZER_LIST(menus::SimpleMenuModel(this)), 44 : ALLOW_THIS_IN_INITIALIZER_LIST(menus::SimpleMenuModel(this)),
51 browser_(browser) { 45 browser_(browser) {
52 Build(); 46 Build();
53 } 47 }
54 48
55 void EncodingMenuModel::Build() { 49 void EncodingMenuModel::Build() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); 156 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE);
163 if (g_browser_process->have_inspector_files()) { 157 if (g_browser_process->have_inspector_files()) {
164 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); 158 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS);
165 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); 159 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE);
166 } 160 }
167 } 161 }
168 162
169 //////////////////////////////////////////////////////////////////////////////// 163 ////////////////////////////////////////////////////////////////////////////////
170 // WrenchMenuModel 164 // WrenchMenuModel
171 165
172 WrenchMenuModel::WrenchMenuModel(menus::AcceleratorProvider* provider, 166 WrenchMenuModel::WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate,
173 Browser* browser) 167 Browser* browser)
174 : ALLOW_THIS_IN_INITIALIZER_LIST(model_(this)), 168 : menus::SimpleMenuModel(delegate),
175 provider_(provider), 169 delegate_(delegate),
176 browser_(browser), 170 browser_(browser),
177 tabstrip_model_(browser_->tabstrip_model()) { 171 tabstrip_model_(browser_->tabstrip_model()) {
178 Build(); 172 Build();
179 UpdateZoomControls(); 173 UpdateZoomControls();
180 174
181 tabstrip_model_->AddObserver(this); 175 tabstrip_model_->AddObserver(this);
182 176
183 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED, 177 registrar_.Add(this, NotificationType::ZOOM_LEVEL_CHANGED,
184 Source<Profile>(browser_->profile())); 178 Source<Profile>(browser_->profile()));
185 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 179 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
186 NotificationService::AllSources()); 180 NotificationService::AllSources());
187 } 181 }
188 182
189 WrenchMenuModel::~WrenchMenuModel() { 183 WrenchMenuModel::~WrenchMenuModel() {
190 if (tabstrip_model_) 184 if (tabstrip_model_)
191 tabstrip_model_->RemoveObserver(this); 185 tabstrip_model_->RemoveObserver(this);
192 } 186 }
193 187
194 bool WrenchMenuModel::IsLabelForCommandIdDynamic(int command_id) const { 188 bool WrenchMenuModel::IsLabelDynamicAt(int index) const {
195 return command_id == IDC_ZOOM_PERCENT_DISPLAY || 189 return IsDynamicItem(index) || SimpleMenuModel::IsLabelDynamicAt(index);
196 command_id == IDC_SYNC_BOOKMARKS ||
197 #if defined(OS_MACOSX)
198 command_id == IDC_FULLSCREEN ||
199 #endif
200 command_id == IDC_ABOUT;
201 } 190 }
202 191
203 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { 192 string16 WrenchMenuModel::GetLabelAt(int index) const {
193 if (!IsDynamicItem(index))
194 return SimpleMenuModel::GetLabelAt(index);
195
196 int command_id = GetCommandIdAt(index);
197
204 switch (command_id) { 198 switch (command_id) {
205 case IDC_ABOUT: 199 case IDC_ABOUT:
206 return GetAboutEntryMenuLabel(); 200 return GetAboutEntryMenuLabel();
207 case IDC_SYNC_BOOKMARKS: 201 case IDC_SYNC_BOOKMARKS:
208 return GetSyncMenuLabel(); 202 return GetSyncMenuLabel();
209 case IDC_ZOOM_PERCENT_DISPLAY:
210 return zoom_label_;
211 #if defined(OS_MACOSX)
212 case IDC_FULLSCREEN: {
213 int string_id = IDS_ENTER_FULLSCREEN_MAC; // Default to Enter.
214 // Note: On startup, |window()| may be NULL.
215 if (browser_->window() && browser_->window()->IsFullscreen())
216 string_id = IDS_EXIT_FULLSCREEN_MAC;
217 return l10n_util::GetStringUTF16(string_id);
218 }
219 #endif
220 default: 203 default:
221 NOTREACHED(); 204 NOTREACHED();
222 return string16(); 205 return string16();
223 } 206 }
224 } 207 }
225 208
226 void WrenchMenuModel::ExecuteCommand(int command_id) { 209 bool WrenchMenuModel::GetIconAt(int index, SkBitmap* icon) const {
227 browser_->ExecuteCommand(command_id); 210 if (GetCommandIdAt(index) == IDC_ABOUT &&
228 } 211 Singleton<UpgradeDetector>::get()->notify_upgrade()) {
229 212 // Show the exclamation point next to the menu item.
230 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { 213 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
231 #if defined(OS_CHROMEOS) 214 *icon = *rb.GetBitmapNamed(IDR_UPDATE_AVAILABLE);
232 if (command_id == IDC_TOGGLE_VERTICAL_TABS) { 215 return true;
233 return browser_->UseVerticalTabs();
234 } 216 }
235 #endif
236
237 if (command_id == IDC_SHOW_BOOKMARK_BAR) {
238 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
239 }
240
241 return false; 217 return false;
242 } 218 }
243 219
244 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { 220 bool WrenchMenuModel::IsLabelForCommandIdDynamic(int command_id) const {
245 return browser_->command_updater()->IsCommandEnabled(command_id); 221 return command_id == IDC_ZOOM_PERCENT_DISPLAY;
246 } 222 }
247 223
248 bool WrenchMenuModel::GetAcceleratorForCommandId( 224 string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const {
249 int command_id, 225 DCHECK_EQ(IDC_ZOOM_PERCENT_DISPLAY, command_id);
250 menus::Accelerator* accelerator) { 226 return zoom_label_;
251 return provider_->GetAcceleratorForCommandId(command_id, accelerator); 227 }
228
229 void WrenchMenuModel::ExecuteCommand(int command_id) {
230 if (delegate_)
231 delegate_->ExecuteCommand(command_id);
252 } 232 }
253 233
254 void WrenchMenuModel::TabSelectedAt(TabContents* old_contents, 234 void WrenchMenuModel::TabSelectedAt(TabContents* old_contents,
255 TabContents* new_contents, 235 TabContents* new_contents,
256 int index, 236 int index,
257 bool user_gesture) { 237 bool user_gesture) {
258 // The user has switched between tabs and the new tab may have a different 238 // The user has switched between tabs and the new tab may have a different
259 // zoom setting. 239 // zoom setting.
260 UpdateZoomControls(); 240 UpdateZoomControls();
261 } 241 }
262 242
263 void WrenchMenuModel::TabReplacedAt(TabContents* old_contents, 243 void WrenchMenuModel::TabReplacedAt(TabContents* old_contents,
264 TabContents* new_contents, int index) { 244 TabContents* new_contents, int index) {
265 UpdateZoomControls(); 245 UpdateZoomControls();
266 } 246 }
267 247
268 void WrenchMenuModel::TabStripModelDeleted() { 248 void WrenchMenuModel::TabStripModelDeleted() {
269 // During views shutdown, the tabstrip model/browser is deleted first, while 249 // During views shutdown, the tabstrip model/browser is deleted first, while
270 // it is the opposite in gtk land. 250 // it is the opposite in gtk land.
271 tabstrip_model_->RemoveObserver(this); 251 tabstrip_model_->RemoveObserver(this);
272 tabstrip_model_ = NULL; 252 tabstrip_model_ = NULL;
273 } 253 }
274 254
275 void WrenchMenuModel::Observe(NotificationType type, 255 void WrenchMenuModel::Observe(NotificationType type,
276 const NotificationSource& source, 256 const NotificationSource& source,
277 const NotificationDetails& details) { 257 const NotificationDetails& details) {
278 UpdateZoomControls(); 258 UpdateZoomControls();
279 } 259 }
280 260
281 // For testing. 261 void WrenchMenuModel::Build() {
282 WrenchMenuModel::WrenchMenuModel() : model_(NULL) { 262 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
283 } 263 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
264 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
284 265
285 void WrenchMenuModel::Build() { 266 AddSeparator();
286 model_.AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
287 model_.AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
288 model_.AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW,
289 IDS_NEW_INCOGNITO_WINDOW);
290
291 model_.AddSeparator();
292 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) 267 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS))
293 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the 268 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the
294 // layout for this menu item in Toolbar.xib. It does, however, use the 269 // layout for this menu item in Toolbar.xib. It does, however, use the
295 // command_id value from AddButtonItem() to identify this special item. 270 // command_id value from AddButtonItem() to identify this special item.
296 edit_menu_item_model_.reset(new menus::ButtonMenuItemModel(IDS_EDIT, this)); 271 edit_menu_item_model_.reset(new menus::ButtonMenuItemModel(IDS_EDIT, this));
297 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT); 272 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT);
298 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY); 273 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY);
299 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE); 274 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE);
300 model_.AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get()); 275 AddButtonItem(IDC_EDIT_MENU, edit_menu_item_model_.get());
301 #else 276 #else
302 // TODO(port): Move to the above. 277 // TODO(port): Move to the above.
303 CreateCutCopyPaste(); 278 CreateCutCopyPaste();
304 #endif 279 #endif
305 280
306 model_.AddSeparator(); 281 AddSeparator();
307 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) 282 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS))
308 // WARNING: See above comment. 283 // WARNING: See above comment.
309 zoom_menu_item_model_.reset( 284 zoom_menu_item_model_.reset(
310 new menus::ButtonMenuItemModel(IDS_ZOOM_MENU, this)); 285 new menus::ButtonMenuItemModel(IDS_ZOOM_MENU, this));
311 zoom_menu_item_model_->AddGroupItemWithStringId( 286 zoom_menu_item_model_->AddGroupItemWithStringId(
312 IDC_ZOOM_MINUS, IDS_ZOOM_MINUS2); 287 IDC_ZOOM_MINUS, IDS_ZOOM_MINUS2);
313 zoom_menu_item_model_->AddButtonLabel(IDC_ZOOM_PERCENT_DISPLAY, 288 zoom_menu_item_model_->AddButtonLabel(IDC_ZOOM_PERCENT_DISPLAY,
314 IDS_ZOOM_PLUS2); 289 IDS_ZOOM_PLUS2);
315 zoom_menu_item_model_->AddGroupItemWithStringId( 290 zoom_menu_item_model_->AddGroupItemWithStringId(
316 IDC_ZOOM_PLUS, IDS_ZOOM_PLUS2); 291 IDC_ZOOM_PLUS, IDS_ZOOM_PLUS2);
317 zoom_menu_item_model_->AddSpace(); 292 zoom_menu_item_model_->AddSpace();
318 zoom_menu_item_model_->AddItemWithImage( 293 zoom_menu_item_model_->AddItemWithImage(
319 IDC_FULLSCREEN, IDR_FULLSCREEN_MENU_BUTTON); 294 IDC_FULLSCREEN, IDR_FULLSCREEN_MENU_BUTTON);
320 model_.AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get()); 295 AddButtonItem(IDC_ZOOM_MENU, zoom_menu_item_model_.get());
321 #else 296 #else
322 // TODO(port): Move to the above. 297 // TODO(port): Move to the above.
323 CreateZoomFullscreen(); 298 CreateZoomFullscreen();
324 #endif 299 #endif
325 300
326 model_.AddSeparator(); 301 AddSeparator();
327 model_.AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); 302 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE);
328 model_.AddItemWithStringId(IDC_FIND, IDS_FIND); 303 AddItemWithStringId(IDC_FIND, IDS_FIND);
329 model_.AddItemWithStringId(IDC_PRINT, IDS_PRINT); 304 AddItemWithStringId(IDC_PRINT, IDS_PRINT);
330 305
331 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); 306 tools_menu_model_.reset(new ToolsMenuModel(delegate(), browser_));
332 model_.AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU, 307 AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU,
333 tools_menu_model_.get()); 308 tools_menu_model_.get());
334 309
335 model_.AddSeparator(); 310 AddSeparator();
336 #if defined(ENABLE_REMOTING) 311 #if defined(ENABLE_REMOTING)
337 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) { 312 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) {
338 model_.AddItem(IDC_REMOTING_SETUP, 313 AddItem(IDC_REMOTING_SETUP,
339 l10n_util::GetStringUTF16(IDS_REMOTING_SETUP_LABEL)); 314 l10n_util::GetStringUTF16(IDS_REMOTING_SETUP_LABEL));
340 } 315 }
341 #endif 316 #endif
342 model_.AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER); 317 AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER);
343 model_.AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); 318 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
344 model_.AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); 319 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS);
345 model_.AddSeparator(); 320 AddSeparator();
346 321
347 #if defined(OS_MACOSX) 322 #if defined(OS_MACOSX)
348 model_.AddItemWithStringId(IDC_OPTIONS, IDS_PREFERENCES_MAC); 323 AddItemWithStringId(IDC_OPTIONS, IDS_PREFERENCES_MAC);
349 #elif defined(OS_LINUX) 324 #elif defined(OS_LINUX)
350 GtkStockItem stock_item; 325 GtkStockItem stock_item;
351 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) { 326 if (gtk_stock_lookup(GTK_STOCK_PREFERENCES, &stock_item)) {
352 const char16 kUnderscore[] = { '_', 0 }; 327 const char16 kUnderscore[] = { '_', 0 };
353 string16 preferences; 328 string16 preferences;
354 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences); 329 RemoveChars(UTF8ToUTF16(stock_item.label), kUnderscore, &preferences);
355 model_.AddItem(IDC_OPTIONS, preferences); 330 AddItem(IDC_OPTIONS, preferences);
356 } else {
357 model_.AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS);
358 } 331 }
359 #else 332 #else
360 model_.AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS); 333 AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS);
361 #endif 334 #endif
362 335
363 #if defined(OS_CHROMEOS) 336 #if defined(OS_CHROMEOS)
364 model_.AddCheckItemWithStringId(IDC_TOGGLE_VERTICAL_TABS, 337 AddCheckItemWithStringId(IDC_TOGGLE_VERTICAL_TABS,
365 IDS_TAB_CXMENU_USE_VERTICAL_TABS); 338 IDS_TAB_CXMENU_USE_VERTICAL_TABS);
366 #endif 339 #endif
367 340
368 // TODO(erg): This entire section needs to be reworked and is out of scope of
369 // the first cleanup patch I'm doing. Part 1 (crbug.com/47320) is moving most
370 // of the logic from each platform specific UI code into the model here. Part
371 // 2 (crbug.com/46221) is normalizing the about menu item/hidden update menu
372 // item behaviour across the three platforms.
373
374 // On Mac, there is no About item unless it is replaced with the update 341 // On Mac, there is no About item unless it is replaced with the update
375 // available notification. 342 // available notification.
376 if (browser_defaults::kShowAboutMenuItem || 343 if (browser_defaults::kShowAboutMenuItem ||
377 Singleton<UpgradeDetector>::get()->notify_upgrade()) { 344 Singleton<UpgradeDetector>::get()->notify_upgrade()) {
378 model_.AddItem(IDC_ABOUT, 345 AddItem(IDC_ABOUT,
379 l10n_util::GetStringFUTF16( 346 l10n_util::GetStringFUTF16(
380 IDS_ABOUT, 347 IDS_ABOUT,
381 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 348 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
382 // ResourceBundle& rb = ResourceBundle::GetSharedInstance();
383 // model_.SetIcon(model_.GetIndexOfCommandId(IDC_ABOUT),
384 // *rb.GetBitmapNamed(IDR_UPDATE_AVAILABLE));
385 } 349 }
386 model_.AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE); 350 AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
387 if (browser_defaults::kShowExitMenuItem) { 351 if (browser_defaults::kShowExitMenuItem) {
388 model_.AddSeparator(); 352 AddSeparator();
389 #if defined(OS_CHROMEOS) 353 #if defined(OS_CHROMEOS)
390 model_.AddItemWithStringId(IDC_EXIT, IDS_SIGN_OUT); 354 AddItemWithStringId(IDC_EXIT, IDS_SIGN_OUT);
391 #else 355 #else
392 model_.AddItemWithStringId(IDC_EXIT, IDS_EXIT); 356 AddItemWithStringId(IDC_EXIT, IDS_EXIT);
393 #endif 357 #endif
394 } 358 }
395 } 359 }
396 360
397 void WrenchMenuModel::CreateCutCopyPaste() { 361 void WrenchMenuModel::CreateCutCopyPaste() {
398 // WARNING: views/wrench_menu assumes these items are added in this order. If 362 // WARNING: views/wrench_menu assumes these items are added in this order. If
399 // you change the order you'll need to update wrench_menu as well. 363 // you change the order you'll need to update wrench_menu as well.
400 model_.AddItemWithStringId(IDC_CUT, IDS_CUT); 364 AddItemWithStringId(IDC_CUT, IDS_CUT);
401 model_.AddItemWithStringId(IDC_COPY, IDS_COPY); 365 AddItemWithStringId(IDC_COPY, IDS_COPY);
402 model_.AddItemWithStringId(IDC_PASTE, IDS_PASTE); 366 AddItemWithStringId(IDC_PASTE, IDS_PASTE);
403 } 367 }
404 368
405 void WrenchMenuModel::CreateZoomFullscreen() { 369 void WrenchMenuModel::CreateZoomFullscreen() {
406 // WARNING: views/wrench_menu assumes these items are added in this order. If 370 // WARNING: views/wrench_menu assumes these items are added in this order. If
407 // you change the order you'll need to update wrench_menu as well. 371 // you change the order you'll need to update wrench_menu as well.
408 model_.AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS); 372 AddItemWithStringId(IDC_ZOOM_MINUS, IDS_ZOOM_MINUS);
409 model_.AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS); 373 AddItemWithStringId(IDC_ZOOM_PLUS, IDS_ZOOM_PLUS);
410 model_.AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); 374 AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
411 } 375 }
412 376
413 void WrenchMenuModel::UpdateZoomControls() { 377 void WrenchMenuModel::UpdateZoomControls() {
414 bool enable_increment, enable_decrement; 378 bool enable_increment, enable_decrement;
415 int zoom_percent = 379 int zoom_percent =
416 static_cast<int>(GetZoom(&enable_increment, &enable_decrement) * 100); 380 static_cast<int>(GetZoom(&enable_increment, &enable_decrement) * 100);
417 zoom_label_ = l10n_util::GetStringFUTF16( 381 zoom_label_ = l10n_util::GetStringFUTF16(
418 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); 382 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent));
419 } 383 }
420 384
(...skipping 23 matching lines...) Expand all
444 } 408 }
445 409
446 string16 WrenchMenuModel::GetAboutEntryMenuLabel() const { 410 string16 WrenchMenuModel::GetAboutEntryMenuLabel() const {
447 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) { 411 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) {
448 return l10n_util::GetStringFUTF16( 412 return l10n_util::GetStringFUTF16(
449 IDS_UPDATE_NOW, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 413 IDS_UPDATE_NOW, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
450 } 414 }
451 return l10n_util::GetStringFUTF16( 415 return l10n_util::GetStringFUTF16(
452 IDS_ABOUT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 416 IDS_ABOUT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
453 } 417 }
418
419 bool WrenchMenuModel::IsDynamicItem(int index) const {
420 int command_id = GetCommandIdAt(index);
421 return command_id == IDC_SYNC_BOOKMARKS ||
422 command_id == IDC_ABOUT;
423 }
424
425 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const {
426 if (delegate_)
427 return delegate_->IsCommandIdEnabled(command_id);
428 return true;
429 }
OLDNEW
« no previous file with comments | « chrome/browser/wrench_menu_model.h ('k') | chrome/browser/wrench_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698