| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/global_error_service.h" | 14 #include "chrome/browser/ui/global_error_service.h" |
| 15 #include "chrome/browser/ui/global_error_service_factory.h" | 15 #include "chrome/browser/ui/global_error_service_factory.h" |
| 16 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 16 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 17 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" |
| 18 #include "chrome/browser/ui/views/browser_actions_container.h" | 18 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 19 #include "chrome/browser/ui/views/event_utils.h" | 19 #include "chrome/browser/ui/views/event_utils.h" |
| 20 #include "chrome/browser/ui/views/window.h" | 20 #include "chrome/browser/ui/views/window.h" |
| 21 #include "chrome/browser/ui/views/wrench_menu.h" | 21 #include "chrome/browser/ui/views/wrench_menu.h" |
| 22 #include "chrome/browser/upgrade_detector.h" | 22 #include "chrome/browser/upgrade_detector.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "content/browser/accessibility/browser_accessibility_state.h" | 25 #include "content/browser/accessibility/browser_accessibility_state.h" |
| 26 #include "content/browser/user_metrics.h" | |
| 27 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/user_metrics.h" |
| 28 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 30 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 31 #include "grit/theme_resources_standard.h" | 31 #include "grit/theme_resources_standard.h" |
| 32 #include "ui/base/accessibility/accessible_view_state.h" | 32 #include "ui/base/accessibility/accessible_view_state.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 35 #include "ui/base/theme_provider.h" | 35 #include "ui/base/theme_provider.h" |
| 36 #include "ui/gfx/canvas.h" | 36 #include "ui/gfx/canvas.h" |
| 37 #include "ui/gfx/canvas_skia.h" | 37 #include "ui/gfx/canvas_skia.h" |
| 38 #include "ui/gfx/skbitmap_operations.h" | 38 #include "ui/gfx/skbitmap_operations.h" |
| 39 #include "ui/views/controls/button/button_dropdown.h" | 39 #include "ui/views/controls/button/button_dropdown.h" |
| 40 #include "ui/views/controls/menu/menu_listener.h" | 40 #include "ui/views/controls/menu/menu_listener.h" |
| 41 #include "ui/views/focus/view_storage.h" | 41 #include "ui/views/focus/view_storage.h" |
| 42 #include "ui/views/widget/tooltip_manager.h" | 42 #include "ui/views/widget/tooltip_manager.h" |
| 43 #include "ui/views/window/non_client_view.h" | 43 #include "ui/views/window/non_client_view.h" |
| 44 | 44 |
| 45 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 46 #include "chrome/browser/enumerate_modules_model_win.h" | 46 #include "chrome/browser/enumerate_modules_model_win.h" |
| 47 #include "chrome/browser/ui/views/critical_notification_bubble_view.h" | 47 #include "chrome/browser/ui/views/critical_notification_bubble_view.h" |
| 48 #if !defined(USE_AURA) | 48 #if !defined(USE_AURA) |
| 49 #include "chrome/browser/ui/views/app_menu_button_win.h" | 49 #include "chrome/browser/ui/views/app_menu_button_win.h" |
| 50 #endif | 50 #endif |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 53 using content::UserMetricsAction; |
| 54 |
| 53 // static | 55 // static |
| 54 const char ToolbarView::kViewClassName[] = "browser/ui/views/ToolbarView"; | 56 const char ToolbarView::kViewClassName[] = "browser/ui/views/ToolbarView"; |
| 55 // The space between items is 4 px in general. | 57 // The space between items is 4 px in general. |
| 56 const int ToolbarView::kStandardSpacing = 4; | 58 const int ToolbarView::kStandardSpacing = 4; |
| 57 // The top of the toolbar has an edge we have to skip over in addition to the 4 | 59 // The top of the toolbar has an edge we have to skip over in addition to the 4 |
| 58 // px of spacing. | 60 // px of spacing. |
| 59 const int ToolbarView::kVertSpacing = kStandardSpacing + 1; | 61 const int ToolbarView::kVertSpacing = kStandardSpacing + 1; |
| 60 // The edge graphics have some built-in spacing/shadowing, so we have to adjust | 62 // The edge graphics have some built-in spacing/shadowing, so we have to adjust |
| 61 // our spacing to make it still appear to be 4 px. | 63 // our spacing to make it still appear to be 4 px. |
| 62 static const int kEdgeSpacing = ToolbarView::kStandardSpacing - 1; | 64 static const int kEdgeSpacing = ToolbarView::kStandardSpacing - 1; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 SkBitmap badge; | 284 SkBitmap badge; |
| 283 // Only one badge can be active at any given time. The Upgrade notification | 285 // Only one badge can be active at any given time. The Upgrade notification |
| 284 // is deemed most important, then the DLL conflict badge. | 286 // is deemed most important, then the DLL conflict badge. |
| 285 if (IsUpgradeRecommended()) { | 287 if (IsUpgradeRecommended()) { |
| 286 badge = *tp->GetBitmapNamed( | 288 badge = *tp->GetBitmapNamed( |
| 287 UpgradeDetector::GetInstance()->GetIconResourceID( | 289 UpgradeDetector::GetInstance()->GetIconResourceID( |
| 288 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE)); | 290 UpgradeDetector::UPGRADE_ICON_TYPE_BADGE)); |
| 289 } else if (ShouldShowIncompatibilityWarning()) { | 291 } else if (ShouldShowIncompatibilityWarning()) { |
| 290 #if defined(OS_WIN) | 292 #if defined(OS_WIN) |
| 291 if (!was_showing) | 293 if (!was_showing) |
| 292 UserMetrics::RecordAction(UserMetricsAction("ConflictBadge")); | 294 content::RecordAction(UserMetricsAction("ConflictBadge")); |
| 293 badge = *tp->GetBitmapNamed(IDR_CONFLICT_BADGE); | 295 badge = *tp->GetBitmapNamed(IDR_CONFLICT_BADGE); |
| 294 incompatibility_badge_showing = true; | 296 incompatibility_badge_showing = true; |
| 295 #else | 297 #else |
| 296 NOTREACHED(); | 298 NOTREACHED(); |
| 297 #endif | 299 #endif |
| 298 } else if (error_badge_id) { | 300 } else if (error_badge_id) { |
| 299 badge = *tp->GetBitmapNamed(error_badge_id); | 301 badge = *tp->GetBitmapNamed(error_badge_id); |
| 300 } else { | 302 } else { |
| 301 NOTREACHED(); | 303 NOTREACHED(); |
| 302 } | 304 } |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 accname_app = l10n_util::GetStringFUTF16( | 733 accname_app = l10n_util::GetStringFUTF16( |
| 732 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); | 734 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); |
| 733 } | 735 } |
| 734 app_menu_->SetAccessibleName(accname_app); | 736 app_menu_->SetAccessibleName(accname_app); |
| 735 | 737 |
| 736 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); | 738 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); |
| 737 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); | 739 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); |
| 738 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); | 740 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); |
| 739 SchedulePaint(); | 741 SchedulePaint(); |
| 740 } | 742 } |
| OLD | NEW |