| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 bool EncodingMenuModel::IsCommandIdChecked(int command_id) const { | 112 bool EncodingMenuModel::IsCommandIdChecked(int command_id) const { |
| 113 WebContents* current_tab = browser_->GetActiveWebContents(); | 113 WebContents* current_tab = browser_->GetActiveWebContents(); |
| 114 if (!current_tab) | 114 if (!current_tab) |
| 115 return false; | 115 return false; |
| 116 EncodingMenuController controller; | 116 EncodingMenuController controller; |
| 117 return controller.IsItemChecked(browser_->profile(), | 117 return controller.IsItemChecked(browser_->profile(), |
| 118 current_tab->GetEncoding(), command_id); | 118 current_tab->GetEncoding(), command_id); |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool EncodingMenuModel::IsCommandIdEnabled(int command_id) const { | 121 bool EncodingMenuModel::IsCommandIdEnabled(int command_id) const { |
| 122 bool enabled = browser_->command_updater()->IsCommandEnabled(command_id); | 122 bool enabled = chrome::IsCommandEnabled(browser_, command_id); |
| 123 // Special handling for the contents of the Encoding submenu. On Mac OS, | 123 // Special handling for the contents of the Encoding submenu. On Mac OS, |
| 124 // instead of enabling/disabling the top-level menu item, the submenu's | 124 // instead of enabling/disabling the top-level menu item, the submenu's |
| 125 // contents get disabled, per Apple's HIG. | 125 // contents get disabled, per Apple's HIG. |
| 126 #if defined(OS_MACOSX) | 126 #if defined(OS_MACOSX) |
| 127 enabled &= browser_->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU); | 127 enabled &= chrome::IsCommandEnabled(browser_, IDC_ENCODING_MENU); |
| 128 #endif | 128 #endif |
| 129 return enabled; | 129 return enabled; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool EncodingMenuModel::GetAcceleratorForCommandId( | 132 bool EncodingMenuModel::GetAcceleratorForCommandId( |
| 133 int command_id, | 133 int command_id, |
| 134 ui::Accelerator* accelerator) { | 134 ui::Accelerator* accelerator) { |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 | 137 |
| 138 void EncodingMenuModel::ExecuteCommand(int command_id) { | 138 void EncodingMenuModel::ExecuteCommand(int command_id) { |
| 139 browser_->ExecuteCommand(command_id); | 139 chrome::ExecuteCommand(browser_, command_id); |
| 140 } | 140 } |
| 141 | 141 |
| 142 //////////////////////////////////////////////////////////////////////////////// | 142 //////////////////////////////////////////////////////////////////////////////// |
| 143 // ZoomMenuModel | 143 // ZoomMenuModel |
| 144 | 144 |
| 145 ZoomMenuModel::ZoomMenuModel(ui::SimpleMenuModel::Delegate* delegate) | 145 ZoomMenuModel::ZoomMenuModel(ui::SimpleMenuModel::Delegate* delegate) |
| 146 : SimpleMenuModel(delegate) { | 146 : SimpleMenuModel(delegate) { |
| 147 Build(); | 147 Build(); |
| 148 } | 148 } |
| 149 | 149 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 SyncGlobalError* error = service->sync_global_error(); | 335 SyncGlobalError* error = service->sync_global_error(); |
| 336 if (error && error->HasCustomizedSyncMenuItem()) { | 336 if (error && error->HasCustomizedSyncMenuItem()) { |
| 337 error->ExecuteMenuItem(browser_); | 337 error->ExecuteMenuItem(browser_); |
| 338 return; | 338 return; |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 if (command_id == IDC_HELP_PAGE_VIA_MENU) | 342 if (command_id == IDC_HELP_PAGE_VIA_MENU) |
| 343 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); | 343 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); |
| 344 | 344 |
| 345 browser_->ExecuteCommand(command_id); | 345 chrome::ExecuteCommand(browser_, command_id); |
| 346 } | 346 } |
| 347 | 347 |
| 348 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { | 348 bool WrenchMenuModel::IsCommandIdChecked(int command_id) const { |
| 349 if (command_id == IDC_SHOW_BOOKMARK_BAR) { | 349 if (command_id == IDC_SHOW_BOOKMARK_BAR) { |
| 350 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); | 350 return browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar); |
| 351 } else if (command_id == IDC_PROFILING_ENABLED) { | 351 } else if (command_id == IDC_PROFILING_ENABLED) { |
| 352 return Profiling::BeingProfiled(); | 352 return Profiling::BeingProfiled(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 return false; | 355 return false; |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 358 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
| 359 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( | 359 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( |
| 360 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); | 360 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); |
| 361 if (error) | 361 if (error) |
| 362 return true; | 362 return true; |
| 363 | 363 |
| 364 return browser_->command_updater()->IsCommandEnabled(command_id); | 364 return chrome::IsCommandEnabled(browser_, command_id); |
| 365 } | 365 } |
| 366 | 366 |
| 367 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { | 367 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { |
| 368 #if defined(OS_WIN) | 368 #if defined(OS_WIN) |
| 369 if (command_id == IDC_VIEW_INCOMPATIBILITIES) { | 369 if (command_id == IDC_VIEW_INCOMPATIBILITIES) { |
| 370 EnumerateModulesModel* loaded_modules = | 370 EnumerateModulesModel* loaded_modules = |
| 371 EnumerateModulesModel::GetInstance(); | 371 EnumerateModulesModel::GetInstance(); |
| 372 if (loaded_modules->confirmed_bad_modules_detected() <= 0) | 372 if (loaded_modules->confirmed_bad_modules_detected() <= 0) |
| 373 return false; | 373 return false; |
| 374 loaded_modules->AcknowledgeConflictNotification(); | 374 loaded_modules->AcknowledgeConflictNotification(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 zoom_label_ = l10n_util::GetStringFUTF16( | 619 zoom_label_ = l10n_util::GetStringFUTF16( |
| 620 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 620 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 621 } | 621 } |
| 622 | 622 |
| 623 string16 WrenchMenuModel::GetSyncMenuLabel() const { | 623 string16 WrenchMenuModel::GetSyncMenuLabel() const { |
| 624 Profile* profile = browser_->profile()->GetOriginalProfile(); | 624 Profile* profile = browser_->profile()->GetOriginalProfile(); |
| 625 return sync_ui_util::GetSyncMenuLabel( | 625 return sync_ui_util::GetSyncMenuLabel( |
| 626 ProfileSyncServiceFactory::GetForProfile(profile), | 626 ProfileSyncServiceFactory::GetForProfile(profile), |
| 627 *SigninManagerFactory::GetForProfile(profile)); | 627 *SigninManagerFactory::GetForProfile(profile)); |
| 628 } | 628 } |
| OLD | NEW |