| Index: chrome/browser/ui/views/toolbar/toolbar_view.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/toolbar/toolbar_view.cc (revision 283822)
|
| +++ chrome/browser/ui/views/toolbar/toolbar_view.cc (working copy)
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
|
|
|
| +#include <algorithm>
|
| +
|
| #include "base/command_line.h"
|
| #include "base/debug/trace_event.h"
|
| #include "base/i18n/number_formatting.h"
|
| @@ -44,7 +46,6 @@
|
| #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
|
| #include "chrome/browser/ui/views/toolbar/wrench_menu.h"
|
| #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h"
|
| -#include "chrome/browser/upgrade_detector.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "content/public/browser/browser_accessibility_state.h"
|
| @@ -73,8 +74,6 @@
|
| #include "ui/views/window/non_client_view.h"
|
|
|
| #if defined(OS_WIN)
|
| -#include "base/win/windows_version.h"
|
| -#include "chrome/browser/enumerate_modules_model_win.h"
|
| #include "chrome/browser/ui/views/conflicting_module_view_win.h"
|
| #include "chrome/browser/ui/views/critical_notification_bubble_view.h"
|
| #endif
|
| @@ -136,6 +135,7 @@
|
| browser_actions_(NULL),
|
| app_menu_(NULL),
|
| browser_(browser),
|
| + badge_controller_(browser->profile(), this),
|
| extension_message_bubble_factory_(
|
| new extensions::ExtensionMessageBubbleFactory(browser->profile(),
|
| this)) {
|
| @@ -166,16 +166,7 @@
|
| #if defined(OS_WIN)
|
| registrar_.Add(this, chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED,
|
| content::NotificationService::AllSources());
|
| - if (base::win::GetVersion() == base::win::VERSION_XP) {
|
| - registrar_.Add(this, chrome::NOTIFICATION_MODULE_LIST_ENUMERATED,
|
| - content::NotificationService::AllSources());
|
| - }
|
| #endif
|
| - registrar_.Add(this,
|
| - chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE,
|
| - content::NotificationService::AllSources());
|
| - registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
|
| - content::Source<Profile>(browser_->profile()));
|
| }
|
|
|
| ToolbarView::~ToolbarView() {
|
| @@ -264,7 +255,7 @@
|
| // Add any necessary badges to the menu item based on the system state.
|
| // Do this after |app_menu_| has been added as a bubble may be shown that
|
| // needs the widget (widget found by way of app_menu_->GetWidget()).
|
| - UpdateAppMenuState();
|
| + badge_controller_.UpdateDelegate();
|
|
|
| location_bar_->Init();
|
|
|
| @@ -490,12 +481,6 @@
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| switch (type) {
|
| - case chrome::NOTIFICATION_UPGRADE_RECOMMENDED:
|
| - case chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_BADGE_CHANGE:
|
| - case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED:
|
| - case chrome::NOTIFICATION_MODULE_LIST_ENUMERATED:
|
| - UpdateAppMenuState();
|
| - break;
|
| case chrome::NOTIFICATION_OUTDATED_INSTALL:
|
| ShowOutdatedInstallNotification(true);
|
| break;
|
| @@ -714,24 +699,38 @@
|
| return ViewTargeterDelegate::DoesIntersectRect(this, rect);
|
| }
|
|
|
| -bool ToolbarView::ShouldShowUpgradeRecommended() {
|
| -#if defined(OS_CHROMEOS)
|
| - // In chromeos, the update recommendation is shown in the system tray. So it
|
| - // should not be displayed in the wrench menu.
|
| - return false;
|
| -#else
|
| - return (UpgradeDetector::GetInstance()->notify_upgrade());
|
| -#endif
|
| -}
|
| +void ToolbarView::UpdateBadgeSeverity(WrenchMenuBadgeController::BadgeType type,
|
| + WrenchIconPainter::Severity severity,
|
| + bool animate) {
|
| + // Showing the bubble requires |app_menu_| to be in a widget. See comment
|
| + // in ConflictingModuleView for details.
|
| + DCHECK(app_menu_->GetWidget());
|
|
|
| -bool ToolbarView::ShouldShowIncompatibilityWarning() {
|
| + base::string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP);
|
| + if (type == WrenchMenuBadgeController::BADGE_TYPE_UPGRADE_NOTIFICATION) {
|
| + accname_app = l10n_util::GetStringFUTF16(
|
| + IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app);
|
| + }
|
| + app_menu_->SetAccessibleName(accname_app);
|
| + app_menu_->SetSeverity(severity, animate);
|
| +
|
| + // Keep track of whether we were showing the badge before, so we don't send
|
| + // multiple UMA events for example when multiple Chrome windows are open.
|
| + static bool incompatibility_badge_showing = false;
|
| + // Save the old value before resetting it.
|
| + bool was_showing = incompatibility_badge_showing;
|
| + incompatibility_badge_showing = false;
|
| +
|
| + if (type == WrenchMenuBadgeController::BADGE_TYPE_INCOMPATIBILITY_WARNING) {
|
| + if (!was_showing) {
|
| + content::RecordAction(UserMetricsAction("ConflictBadge"));
|
| #if defined(OS_WIN)
|
| - EnumerateModulesModel* loaded_modules = EnumerateModulesModel::GetInstance();
|
| - loaded_modules->MaybePostScanningTask();
|
| - return loaded_modules->ShouldShowConflictWarning();
|
| -#else
|
| - return false;
|
| + ConflictingModuleView::MaybeShow(browser_, app_menu_);
|
| #endif
|
| + }
|
| + incompatibility_badge_showing = true;
|
| + return;
|
| + }
|
| }
|
|
|
| int ToolbarView::PopupTopSpacing() const {
|
| @@ -791,62 +790,6 @@
|
| }
|
| }
|
|
|
| -void ToolbarView::UpdateAppMenuState() {
|
| - base::string16 accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP);
|
| - if (ShouldShowUpgradeRecommended()) {
|
| - accname_app = l10n_util::GetStringFUTF16(
|
| - IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app);
|
| - }
|
| - app_menu_->SetAccessibleName(accname_app);
|
| -
|
| - UpdateWrenchButtonSeverity();
|
| - SchedulePaint();
|
| -}
|
| -
|
| -void ToolbarView::UpdateWrenchButtonSeverity() {
|
| - // Showing the bubble requires |app_menu_| to be in a widget. See comment
|
| - // in ConflictingModuleView for details.
|
| - DCHECK(app_menu_->GetWidget());
|
| -
|
| - // Keep track of whether we were showing the badge before, so we don't send
|
| - // multiple UMA events for example when multiple Chrome windows are open.
|
| - static bool incompatibility_badge_showing = false;
|
| - // Save the old value before resetting it.
|
| - bool was_showing = incompatibility_badge_showing;
|
| - incompatibility_badge_showing = false;
|
| -
|
| - if (ShouldShowUpgradeRecommended()) {
|
| - UpgradeDetector::UpgradeNotificationAnnoyanceLevel level =
|
| - UpgradeDetector::GetInstance()->upgrade_notification_stage();
|
| - app_menu_->SetSeverity(WrenchIconPainter::SeverityFromUpgradeLevel(level),
|
| - WrenchIconPainter::ShouldAnimateUpgradeLevel(level));
|
| - return;
|
| - }
|
| -
|
| - if (ShouldShowIncompatibilityWarning()) {
|
| - if (!was_showing) {
|
| - content::RecordAction(UserMetricsAction("ConflictBadge"));
|
| -#if defined(OS_WIN)
|
| - ConflictingModuleView::MaybeShow(browser_, app_menu_);
|
| -#endif
|
| - }
|
| - app_menu_->SetSeverity(WrenchIconPainter::SEVERITY_MEDIUM, true);
|
| - incompatibility_badge_showing = true;
|
| - return;
|
| - }
|
| -
|
| - GlobalErrorService* service =
|
| - GlobalErrorServiceFactory::GetForProfile(browser_->profile());
|
| - GlobalError* error =
|
| - service->GetHighestSeverityGlobalErrorWithWrenchMenuItem();
|
| - if (error) {
|
| - app_menu_->SetSeverity(WrenchIconPainter::GlobalErrorSeverity(), true);
|
| - return;
|
| - }
|
| -
|
| - app_menu_->SetSeverity(WrenchIconPainter::SEVERITY_NONE, true);
|
| -}
|
| -
|
| void ToolbarView::OnShowHomeButtonChanged() {
|
| Layout();
|
| SchedulePaint();
|
|
|