| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/toolbar_view.h" | 5 #include "chrome/browser/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 12 #include "chrome/browser/accessibility/browser_accessibility_state.h" |
| 13 #include "chrome/browser/background_page_tracker.h" | 13 #include "chrome/browser/background_page_tracker.h" |
| 14 #include "chrome/browser/metrics/user_metrics.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/themes/browser_theme_provider.h" | 17 #include "chrome/browser/themes/browser_theme_provider.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 19 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 20 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 20 #include "chrome/browser/ui/view_ids.h" | 21 #include "chrome/browser/ui/view_ids.h" |
| 21 #include "chrome/browser/ui/views/browser_actions_container.h" | 22 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 22 #include "chrome/browser/ui/views/event_utils.h" | 23 #include "chrome/browser/ui/views/event_utils.h" |
| 23 #include "chrome/browser/ui/views/frame/browser_view.h" | 24 #include "chrome/browser/ui/views/frame/browser_view.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 726 |
| 726 int id = 0; | 727 int id = 0; |
| 727 switch (state) { | 728 switch (state) { |
| 728 case views::CustomButton::BS_NORMAL: id = IDR_TOOLS; break; | 729 case views::CustomButton::BS_NORMAL: id = IDR_TOOLS; break; |
| 729 case views::CustomButton::BS_HOT: id = IDR_TOOLS_H; break; | 730 case views::CustomButton::BS_HOT: id = IDR_TOOLS_H; break; |
| 730 case views::CustomButton::BS_PUSHED: id = IDR_TOOLS_P; break; | 731 case views::CustomButton::BS_PUSHED: id = IDR_TOOLS_P; break; |
| 731 default: NOTREACHED(); break; | 732 default: NOTREACHED(); break; |
| 732 } | 733 } |
| 733 SkBitmap icon = *tp->GetBitmapNamed(id); | 734 SkBitmap icon = *tp->GetBitmapNamed(id); |
| 734 | 735 |
| 736 #if defined(OS_WIN) |
| 737 // Keep track of whether we were showing the badge before, so we don't send |
| 738 // multiple UMA events for example when multiple Chrome windows are open. |
| 739 static bool incompatibility_badge_showing = false; |
| 740 // Save the old value before resetting it. |
| 741 bool was_showing = incompatibility_badge_showing; |
| 742 incompatibility_badge_showing = false; |
| 743 #endif |
| 744 |
| 735 bool add_badge = IsUpgradeRecommended() || | 745 bool add_badge = IsUpgradeRecommended() || |
| 736 ShouldShowIncompatibilityWarning() || | 746 ShouldShowIncompatibilityWarning() || |
| 737 ShouldShowBackgroundPageBadge(); | 747 ShouldShowBackgroundPageBadge(); |
| 738 if (!add_badge) | 748 if (!add_badge) |
| 739 return icon; | 749 return icon; |
| 740 | 750 |
| 741 // Draw the chrome app menu icon onto the canvas. | 751 // Draw the chrome app menu icon onto the canvas. |
| 742 scoped_ptr<gfx::CanvasSkia> canvas( | 752 scoped_ptr<gfx::CanvasSkia> canvas( |
| 743 new gfx::CanvasSkia(icon.width(), icon.height(), false)); | 753 new gfx::CanvasSkia(icon.width(), icon.height(), false)); |
| 744 canvas->DrawBitmapInt(icon, 0, 0); | 754 canvas->DrawBitmapInt(icon, 0, 0); |
| 745 | 755 |
| 746 SkBitmap badge; | 756 SkBitmap badge; |
| 747 // Only one badge can be active at any given time. The Upgrade notification | 757 // Only one badge can be active at any given time. The Upgrade notification |
| 748 // is deemed most important, then the temporary background page badge, | 758 // is deemed most important, then the temporary background page badge, |
| 749 // then the DLL conflict badge. | 759 // then the DLL conflict badge. |
| 750 if (IsUpgradeRecommended()) { | 760 if (IsUpgradeRecommended()) { |
| 751 badge = *tp->GetBitmapNamed(IDR_UPDATE_BADGE); | 761 badge = *tp->GetBitmapNamed(IDR_UPDATE_BADGE); |
| 752 } else if (ShouldShowBackgroundPageBadge()) { | 762 } else if (ShouldShowBackgroundPageBadge()) { |
| 753 badge = *tp->GetBitmapNamed(IDR_BACKGROUND_BADGE); | 763 badge = *tp->GetBitmapNamed(IDR_BACKGROUND_BADGE); |
| 754 } else if (ShouldShowIncompatibilityWarning()) { | 764 } else if (ShouldShowIncompatibilityWarning()) { |
| 755 #if defined(OS_WIN) | 765 #if defined(OS_WIN) |
| 766 if (!was_showing) |
| 767 UserMetrics::RecordAction(UserMetricsAction("ConflictBadge"), profile_); |
| 756 badge = *tp->GetBitmapNamed(IDR_CONFLICT_BADGE); | 768 badge = *tp->GetBitmapNamed(IDR_CONFLICT_BADGE); |
| 769 incompatibility_badge_showing = true; |
| 757 #else | 770 #else |
| 758 NOTREACHED(); | 771 NOTREACHED(); |
| 759 #endif | 772 #endif |
| 760 } else { | 773 } else { |
| 761 NOTREACHED(); | 774 NOTREACHED(); |
| 762 } | 775 } |
| 763 | 776 |
| 764 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin); | 777 canvas->DrawBitmapInt(badge, icon.width() - badge.width(), kBadgeTopMargin); |
| 765 | 778 |
| 766 return canvas->ExtractBitmap(); | 779 return canvas->ExtractBitmap(); |
| 767 } | 780 } |
| OLD | NEW |