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" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/search/search.h" | 20 #include "chrome/browser/search/search.h" |
21 #include "chrome/browser/signin/signin_manager.h" | 21 #include "chrome/browser/signin/signin_manager.h" |
22 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
23 #include "chrome/browser/signin/signin_ui_util.h" | 23 #include "chrome/browser/signin/signin_ui_util.h" |
24 #include "chrome/browser/task_manager/task_manager.h" | 24 #include "chrome/browser/task_manager/task_manager.h" |
| 25 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
27 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
28 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
29 #include "chrome/browser/ui/global_error/global_error.h" | 30 #include "chrome/browser/ui/global_error/global_error.h" |
30 #include "chrome/browser/ui/global_error/global_error_service.h" | 31 #include "chrome/browser/ui/global_error/global_error_service.h" |
31 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 32 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
33 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" | 34 #include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h" |
34 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 35 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { | 396 bool WrenchMenuModel::IsCommandIdEnabled(int command_id) const { |
396 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( | 397 GlobalError* error = GlobalErrorServiceFactory::GetForProfile( |
397 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); | 398 browser_->profile())->GetGlobalErrorByMenuItemCommandID(command_id); |
398 if (error) | 399 if (error) |
399 return true; | 400 return true; |
400 | 401 |
401 return chrome::IsCommandEnabled(browser_, command_id); | 402 return chrome::IsCommandEnabled(browser_, command_id); |
402 } | 403 } |
403 | 404 |
404 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { | 405 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { |
| 406 switch (command_id) { |
405 #if defined(OS_WIN) | 407 #if defined(OS_WIN) |
406 if (command_id == IDC_VIEW_INCOMPATIBILITIES) { | 408 case IDC_VIEW_INCOMPATIBILITIES: { |
407 EnumerateModulesModel* loaded_modules = | 409 EnumerateModulesModel* loaded_modules = |
408 EnumerateModulesModel::GetInstance(); | 410 EnumerateModulesModel::GetInstance(); |
409 if (loaded_modules->confirmed_bad_modules_detected() <= 0) | 411 if (loaded_modules->confirmed_bad_modules_detected() <= 0) |
| 412 return false; |
| 413 // We'll leave the wrench adornment on until the user clicks the link. |
| 414 if (loaded_modules->modules_to_notify_about() <= 0) |
| 415 loaded_modules->AcknowledgeConflictNotification(); |
| 416 return true; |
| 417 } |
| 418 case IDC_PIN_TO_START_SCREEN: |
| 419 return base::win::IsMetroProcess(); |
| 420 #else |
| 421 case IDC_VIEW_INCOMPATIBILITIES: |
| 422 case IDC_PIN_TO_START_SCREEN: |
410 return false; | 423 return false; |
411 // We'll leave the wrench adornment on until the user clicks the link. | |
412 if (loaded_modules->modules_to_notify_about() <= 0) | |
413 loaded_modules->AcknowledgeConflictNotification(); | |
414 return true; | |
415 } else if (command_id == IDC_PIN_TO_START_SCREEN) { | |
416 return base::win::IsMetroProcess(); | |
417 #else | |
418 if (command_id == IDC_VIEW_INCOMPATIBILITIES || | |
419 command_id == IDC_PIN_TO_START_SCREEN) { | |
420 return false; | |
421 #endif | 424 #endif |
422 } else if (command_id == IDC_UPGRADE_DIALOG) { | 425 case IDC_UPGRADE_DIALOG: |
423 return UpgradeDetector::GetInstance()->notify_upgrade(); | 426 return UpgradeDetector::GetInstance()->notify_upgrade(); |
| 427 #if defined(OS_MACOSX) |
| 428 case IDC_BOOKMARK_PAGE: |
| 429 return chrome::ShouldShowBookmarkPageMenuItem(browser_->profile()); |
| 430 #endif |
| 431 default: |
| 432 return true; |
424 } | 433 } |
425 return true; | |
426 } | 434 } |
427 | 435 |
428 bool WrenchMenuModel::GetAcceleratorForCommandId( | 436 bool WrenchMenuModel::GetAcceleratorForCommandId( |
429 int command_id, | 437 int command_id, |
430 ui::Accelerator* accelerator) { | 438 ui::Accelerator* accelerator) { |
431 return provider_->GetAcceleratorForCommandId(command_id, accelerator); | 439 return provider_->GetAcceleratorForCommandId(command_id, accelerator); |
432 } | 440 } |
433 | 441 |
434 void WrenchMenuModel::ActiveTabChanged(WebContents* old_contents, | 442 void WrenchMenuModel::ActiveTabChanged(WebContents* old_contents, |
435 WebContents* new_contents, | 443 WebContents* new_contents, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 &enable_increment, &enable_decrement); | 784 &enable_increment, &enable_decrement); |
777 } | 785 } |
778 zoom_label_ = l10n_util::GetStringFUTF16( | 786 zoom_label_ = l10n_util::GetStringFUTF16( |
779 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 787 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
780 } | 788 } |
781 | 789 |
782 void WrenchMenuModel::OnZoomLevelChanged( | 790 void WrenchMenuModel::OnZoomLevelChanged( |
783 const content::HostZoomMap::ZoomLevelChange& change) { | 791 const content::HostZoomMap::ZoomLevelChange& change) { |
784 UpdateZoomControls(); | 792 UpdateZoomControls(); |
785 } | 793 } |
OLD | NEW |