| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 return chrome::IsCommandEnabled(browser_, command_id); | 408 return chrome::IsCommandEnabled(browser_, command_id); |
| 409 } | 409 } |
| 410 | 410 |
| 411 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { | 411 bool WrenchMenuModel::IsCommandIdVisible(int command_id) const { |
| 412 #if defined(OS_WIN) | 412 #if defined(OS_WIN) |
| 413 if (command_id == IDC_VIEW_INCOMPATIBILITIES) { | 413 if (command_id == IDC_VIEW_INCOMPATIBILITIES) { |
| 414 EnumerateModulesModel* loaded_modules = | 414 EnumerateModulesModel* loaded_modules = |
| 415 EnumerateModulesModel::GetInstance(); | 415 EnumerateModulesModel::GetInstance(); |
| 416 if (loaded_modules->confirmed_bad_modules_detected() <= 0) | 416 if (loaded_modules->confirmed_bad_modules_detected() <= 0) |
| 417 return false; | 417 return false; |
| 418 loaded_modules->AcknowledgeConflictNotification(); | 418 // We'll leave the wrench adornment on until the user clicks the link. |
| 419 if (loaded_modules->modules_to_notify_about() <= 0) |
| 420 loaded_modules->AcknowledgeConflictNotification(); |
| 419 return true; | 421 return true; |
| 420 } else if (command_id == IDC_PIN_TO_START_SCREEN) { | 422 } else if (command_id == IDC_PIN_TO_START_SCREEN) { |
| 421 return base::win::IsMetroProcess(); | 423 return base::win::IsMetroProcess(); |
| 422 #else | 424 #else |
| 423 if (command_id == IDC_VIEW_INCOMPATIBILITIES || | 425 if (command_id == IDC_VIEW_INCOMPATIBILITIES || |
| 424 command_id == IDC_PIN_TO_START_SCREEN) { | 426 command_id == IDC_PIN_TO_START_SCREEN) { |
| 425 return false; | 427 return false; |
| 426 #endif | 428 #endif |
| 427 } else if (command_id == IDC_UPGRADE_DIALOG) { | 429 } else if (command_id == IDC_UPGRADE_DIALOG) { |
| 428 return UpgradeDetector::GetInstance()->notify_upgrade(); | 430 return UpgradeDetector::GetInstance()->notify_upgrade(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 472 |
| 471 // For testing. | 473 // For testing. |
| 472 WrenchMenuModel::WrenchMenuModel() | 474 WrenchMenuModel::WrenchMenuModel() |
| 473 : ui::SimpleMenuModel(this), | 475 : ui::SimpleMenuModel(this), |
| 474 provider_(NULL), | 476 provider_(NULL), |
| 475 browser_(NULL), | 477 browser_(NULL), |
| 476 tab_strip_model_(NULL) { | 478 tab_strip_model_(NULL) { |
| 477 } | 479 } |
| 478 | 480 |
| 479 void WrenchMenuModel::Build(bool is_new_menu) { | 481 void WrenchMenuModel::Build(bool is_new_menu) { |
| 482 #if defined(OS_WIN) |
| 483 AddItem(IDC_VIEW_INCOMPATIBILITIES, |
| 484 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); |
| 485 EnumerateModulesModel* model = |
| 486 EnumerateModulesModel::GetInstance(); |
| 487 if (model->modules_to_notify_about() > 0 || |
| 488 model->confirmed_bad_modules_detected() > 0) |
| 489 AddSeparator(ui::NORMAL_SEPARATOR); |
| 490 #endif |
| 491 |
| 480 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 492 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
| 481 #if defined(OS_WIN) | 493 #if defined(OS_WIN) |
| 482 if (win8::IsSingleWindowMetroMode()) { | 494 if (win8::IsSingleWindowMetroMode()) { |
| 483 // In Win8's single window Metro mode, we only show the New Window options | 495 // In Win8's single window Metro mode, we only show the New Window options |
| 484 // if there isn't already a window of the requested type (incognito or not) | 496 // if there isn't already a window of the requested type (incognito or not) |
| 485 // that is available. | 497 // that is available. |
| 486 if (browser_->profile()->IsOffTheRecord()) { | 498 if (browser_->profile()->IsOffTheRecord()) { |
| 487 if (chrome::FindBrowserWithProfile( | 499 if (chrome::FindBrowserWithProfile( |
| 488 browser_->profile()->GetOriginalProfile(), | 500 browser_->profile()->GetOriginalProfile(), |
| 489 browser_->host_desktop_type()) == NULL) { | 501 browser_->host_desktop_type()) == NULL) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 string16 num_background_pages = base::FormatNumber( | 612 string16 num_background_pages = base::FormatNumber( |
| 601 TaskManager::GetBackgroundPageCount()); | 613 TaskManager::GetBackgroundPageCount()); |
| 602 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( | 614 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( |
| 603 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); | 615 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); |
| 604 } | 616 } |
| 605 } | 617 } |
| 606 | 618 |
| 607 if (browser_defaults::kShowUpgradeMenuItem) | 619 if (browser_defaults::kShowUpgradeMenuItem) |
| 608 AddItem(IDC_UPGRADE_DIALOG, GetUpgradeDialogMenuItemName()); | 620 AddItem(IDC_UPGRADE_DIALOG, GetUpgradeDialogMenuItemName()); |
| 609 | 621 |
| 610 AddItem(IDC_VIEW_INCOMPATIBILITIES, l10n_util::GetStringUTF16( | |
| 611 IDS_VIEW_INCOMPATIBILITIES)); | |
| 612 | |
| 613 #if defined(OS_WIN) | 622 #if defined(OS_WIN) |
| 614 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), | 623 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), |
| 615 ui::ResourceBundle::GetSharedInstance(). | 624 ui::ResourceBundle::GetSharedInstance(). |
| 616 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); | 625 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); |
| 617 #endif | 626 #endif |
| 618 | 627 |
| 619 if (!is_new_menu) { | 628 if (!is_new_menu) { |
| 620 AddItemWithStringId(IDC_HELP_PAGE_VIA_MENU, IDS_HELP_PAGE); | 629 AddItemWithStringId(IDC_HELP_PAGE_VIA_MENU, IDS_HELP_PAGE); |
| 621 | 630 |
| 622 if (browser_defaults::kShowHelpMenuItemIcon) { | 631 if (browser_defaults::kShowHelpMenuItemIcon) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 &enable_increment, &enable_decrement); | 768 &enable_increment, &enable_decrement); |
| 760 } | 769 } |
| 761 zoom_label_ = l10n_util::GetStringFUTF16( | 770 zoom_label_ = l10n_util::GetStringFUTF16( |
| 762 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 771 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 763 } | 772 } |
| 764 | 773 |
| 765 void WrenchMenuModel::OnZoomLevelChanged( | 774 void WrenchMenuModel::OnZoomLevelChanged( |
| 766 const content::HostZoomMap::ZoomLevelChange& change) { | 775 const content::HostZoomMap::ZoomLevelChange& change) { |
| 767 UpdateZoomControls(); | 776 UpdateZoomControls(); |
| 768 } | 777 } |
| OLD | NEW |