| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 #if defined(USE_ASH) | 65 #if defined(USE_ASH) |
| 66 #include "ash/shell.h" | 66 #include "ash/shell.h" |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 using content::HostZoomMap; | 69 using content::HostZoomMap; |
| 70 using content::UserMetricsAction; | 70 using content::UserMetricsAction; |
| 71 using content::WebContents; | 71 using content::WebContents; |
| 72 | 72 |
| 73 namespace { |
| 74 // Conditionally return the update app menu item title based on upgrade detector |
| 75 // state. |
| 76 string16 GetUpgradeDialogMenuItemName() { |
| 77 if (UpgradeDetector::GetInstance()->is_outdated_install()) { |
| 78 return l10n_util::GetStringFUTF16( |
| 79 IDS_UPGRADE_BUBBLE_MENU_ITEM, |
| 80 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 81 } else { |
| 82 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); |
| 83 } |
| 84 } |
| 85 } // namespace |
| 86 |
| 73 //////////////////////////////////////////////////////////////////////////////// | 87 //////////////////////////////////////////////////////////////////////////////// |
| 74 // EncodingMenuModel | 88 // EncodingMenuModel |
| 75 | 89 |
| 76 EncodingMenuModel::EncodingMenuModel(Browser* browser) | 90 EncodingMenuModel::EncodingMenuModel(Browser* browser) |
| 77 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | 91 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
| 78 browser_(browser) { | 92 browser_(browser) { |
| 79 Build(); | 93 Build(); |
| 80 } | 94 } |
| 81 | 95 |
| 82 EncodingMenuModel::~EncodingMenuModel() { | 96 EncodingMenuModel::~EncodingMenuModel() { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return l10n_util::GetStringUTF16(string_id); | 286 return l10n_util::GetStringUTF16(string_id); |
| 273 } | 287 } |
| 274 #endif | 288 #endif |
| 275 case IDC_VIEW_BACKGROUND_PAGES: { | 289 case IDC_VIEW_BACKGROUND_PAGES: { |
| 276 string16 num_background_pages = base::FormatNumber( | 290 string16 num_background_pages = base::FormatNumber( |
| 277 TaskManager::GetBackgroundPageCount()); | 291 TaskManager::GetBackgroundPageCount()); |
| 278 return l10n_util::GetStringFUTF16(IDS_VIEW_BACKGROUND_PAGES, | 292 return l10n_util::GetStringFUTF16(IDS_VIEW_BACKGROUND_PAGES, |
| 279 num_background_pages); | 293 num_background_pages); |
| 280 } | 294 } |
| 281 case IDC_UPGRADE_DIALOG: | 295 case IDC_UPGRADE_DIALOG: |
| 282 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); | 296 return GetUpgradeDialogMenuItemName(); |
| 283 case IDC_SHOW_SIGNIN: | 297 case IDC_SHOW_SIGNIN: |
| 284 return signin_ui_util::GetSigninMenuLabel( | 298 return signin_ui_util::GetSigninMenuLabel( |
| 285 browser_->profile()->GetOriginalProfile()); | 299 browser_->profile()->GetOriginalProfile()); |
| 286 default: | 300 default: |
| 287 NOTREACHED(); | 301 NOTREACHED(); |
| 288 return string16(); | 302 return string16(); |
| 289 } | 303 } |
| 290 } | 304 } |
| 291 | 305 |
| 292 bool WrenchMenuModel::GetIconForCommandId(int command_id, | 306 bool WrenchMenuModel::GetIconForCommandId(int command_id, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 // We use the task manager to show background pages. | 575 // We use the task manager to show background pages. |
| 562 if (chrome::CanOpenTaskManager()) { | 576 if (chrome::CanOpenTaskManager()) { |
| 563 string16 num_background_pages = base::FormatNumber( | 577 string16 num_background_pages = base::FormatNumber( |
| 564 TaskManager::GetBackgroundPageCount()); | 578 TaskManager::GetBackgroundPageCount()); |
| 565 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( | 579 AddItem(IDC_VIEW_BACKGROUND_PAGES, l10n_util::GetStringFUTF16( |
| 566 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); | 580 IDS_VIEW_BACKGROUND_PAGES, num_background_pages)); |
| 567 } | 581 } |
| 568 } | 582 } |
| 569 | 583 |
| 570 if (browser_defaults::kShowUpgradeMenuItem) | 584 if (browser_defaults::kShowUpgradeMenuItem) |
| 571 AddItem(IDC_UPGRADE_DIALOG, l10n_util::GetStringUTF16(IDS_UPDATE_NOW)); | 585 AddItem(IDC_UPGRADE_DIALOG, GetUpgradeDialogMenuItemName()); |
| 586 |
| 572 AddItem(IDC_VIEW_INCOMPATIBILITIES, l10n_util::GetStringUTF16( | 587 AddItem(IDC_VIEW_INCOMPATIBILITIES, l10n_util::GetStringUTF16( |
| 573 IDS_VIEW_INCOMPATIBILITIES)); | 588 IDS_VIEW_INCOMPATIBILITIES)); |
| 574 | 589 |
| 575 #if defined(OS_WIN) | 590 #if defined(OS_WIN) |
| 576 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), | 591 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), |
| 577 ui::ResourceBundle::GetSharedInstance(). | 592 ui::ResourceBundle::GetSharedInstance(). |
| 578 GetNativeImageNamed(IDR_CONFLICT_MENU)); | 593 GetNativeImageNamed(IDR_CONFLICT_MENU)); |
| 579 #endif | 594 #endif |
| 580 | 595 |
| 581 if (!is_new_menu) { | 596 if (!is_new_menu) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 bool enable_decrement = false; | 705 bool enable_decrement = false; |
| 691 int zoom_percent = 100; | 706 int zoom_percent = 100; |
| 692 if (browser_->tab_strip_model()->GetActiveWebContents()) { | 707 if (browser_->tab_strip_model()->GetActiveWebContents()) { |
| 693 zoom_percent = | 708 zoom_percent = |
| 694 browser_->tab_strip_model()->GetActiveWebContents()->GetZoomPercent( | 709 browser_->tab_strip_model()->GetActiveWebContents()->GetZoomPercent( |
| 695 &enable_increment, &enable_decrement); | 710 &enable_increment, &enable_decrement); |
| 696 } | 711 } |
| 697 zoom_label_ = l10n_util::GetStringFUTF16( | 712 zoom_label_ = l10n_util::GetStringFUTF16( |
| 698 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 713 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 699 } | 714 } |
| OLD | NEW |