| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 279 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
| 280 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 280 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
| 281 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 281 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 282 } | 282 } |
| 283 | 283 |
| 284 return false; | 284 return false; |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 287 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
| 288 #if defined(OS_CHROMEOS) | |
| 289 // Special case because IDC_NEW_WINDOW item should be disabled in BWSI mode, | |
| 290 // but accelerator should work. | |
| 291 if (command_id == IDC_NEW_WINDOW && | |
| 292 CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) | |
| 293 return false; | |
| 294 #endif | |
| 295 | |
| 296 return browser_->command_updater()->IsCommandEnabled(command_id); | 288 return browser_->command_updater()->IsCommandEnabled(command_id); |
| 297 } | 289 } |
| 298 | 290 |
| 299 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { | 291 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { |
| 300 if (command_id == IDC_UPGRADE_DIALOG) { | 292 if (command_id == IDC_UPGRADE_DIALOG) { |
| 301 #if defined(OS_CHROMEOS) | 293 #if defined(OS_CHROMEOS) |
| 302 return (chromeos::CrosLibrary::Get()->GetUpdateLibrary()->status().status | 294 return (chromeos::CrosLibrary::Get()->GetUpdateLibrary()->status().status |
| 303 == chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT); | 295 == chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT); |
| 304 #else | 296 #else |
| 305 return UpgradeDetector::GetInstance()->notify_upgrade(); | 297 return UpgradeDetector::GetInstance()->notify_upgrade(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 WrenchMenuModel::WrenchMenuModel() | 357 WrenchMenuModel::WrenchMenuModel() |
| 366 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 358 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
| 367 provider_(NULL), | 359 provider_(NULL), |
| 368 browser_(NULL), | 360 browser_(NULL), |
| 369 tabstrip_model_(NULL) { | 361 tabstrip_model_(NULL) { |
| 370 } | 362 } |
| 371 | 363 |
| 372 void WrenchMenuModel::Build() { | 364 void WrenchMenuModel::Build() { |
| 373 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 365 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
| 374 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); | 366 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); |
| 375 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, | 367 #if defined(OS_CHROMEOS) |
| 376 IDS_NEW_INCOGNITO_WINDOW); | 368 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) |
| 369 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); |
| 370 #else |
| 371 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); |
| 372 #endif |
| 377 | 373 |
| 378 AddSeparator(); | 374 AddSeparator(); |
| 379 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) | 375 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) |
| 380 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the | 376 // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the |
| 381 // layout for this menu item in Toolbar.xib. It does, however, use the | 377 // layout for this menu item in Toolbar.xib. It does, however, use the |
| 382 // command_id value from AddButtonItem() to identify this special item. | 378 // command_id value from AddButtonItem() to identify this special item. |
| 383 edit_menu_item_model_.reset(new ui::ButtonMenuItemModel(IDS_EDIT, this)); | 379 edit_menu_item_model_.reset(new ui::ButtonMenuItemModel(IDS_EDIT, this)); |
| 384 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT); | 380 edit_menu_item_model_->AddGroupItemWithStringId(IDC_CUT, IDS_CUT); |
| 385 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY); | 381 edit_menu_item_model_->AddGroupItemWithStringId(IDC_COPY, IDS_COPY); |
| 386 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE); | 382 edit_menu_item_model_->AddGroupItemWithStringId(IDC_PASTE, IDS_PASTE); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 &enable_increment, &enable_decrement); | 502 &enable_increment, &enable_decrement); |
| 507 } | 503 } |
| 508 zoom_label_ = l10n_util::GetStringFUTF16( | 504 zoom_label_ = l10n_util::GetStringFUTF16( |
| 509 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 505 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 510 } | 506 } |
| 511 | 507 |
| 512 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 508 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
| 513 return sync_ui_util::GetSyncMenuLabel( | 509 return sync_ui_util::GetSyncMenuLabel( |
| 514 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); | 510 browser_->profile()->GetOriginalProfile()->GetProfileSyncService()); |
| 515 } | 511 } |
| OLD | NEW |