| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app_menu_icon_controller.h" | 5 #include "chrome/browser/ui/toolbar/app_menu_icon_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/ui/global_error/global_error_service.h" | 10 #include "chrome/browser/ui/global_error/global_error_service.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 AppMenuIconController::AppMenuIconController(Profile* profile, | 68 AppMenuIconController::AppMenuIconController(Profile* profile, |
| 69 Delegate* delegate) | 69 Delegate* delegate) |
| 70 : profile_(profile), delegate_(delegate) { | 70 : profile_(profile), delegate_(delegate) { |
| 71 DCHECK(profile_); | 71 DCHECK(profile_); |
| 72 DCHECK(delegate_); | 72 DCHECK(delegate_); |
| 73 | 73 |
| 74 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | |
| 75 content::NotificationService::AllSources()); | |
| 76 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 74 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 77 content::Source<Profile>(profile_)); | 75 content::Source<Profile>(profile_)); |
| 78 | 76 |
| 77 UpgradeDetector::GetInstance()->AddObserver(this); |
| 78 |
| 79 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
| 80 auto* modules = EnumerateModulesModel::GetInstance(); | 80 auto* modules = EnumerateModulesModel::GetInstance(); |
| 81 modules->AddObserver(this); | 81 modules->AddObserver(this); |
| 82 modules->MaybePostScanningTask(); | 82 modules->MaybePostScanningTask(); |
| 83 #endif | 83 #endif |
| 84 } | 84 } |
| 85 | 85 |
| 86 AppMenuIconController::~AppMenuIconController() { | 86 AppMenuIconController::~AppMenuIconController() { |
| 87 UpgradeDetector::GetInstance()->RemoveObserver(this); |
| 88 |
| 87 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
| 88 EnumerateModulesModel::GetInstance()->RemoveObserver(this); | 90 EnumerateModulesModel::GetInstance()->RemoveObserver(this); |
| 89 #endif | 91 #endif |
| 90 } | 92 } |
| 91 | 93 |
| 92 void AppMenuIconController::UpdateDelegate() { | 94 void AppMenuIconController::UpdateDelegate() { |
| 93 if (ShouldShowUpgradeRecommended()) { | 95 if (ShouldShowUpgradeRecommended()) { |
| 94 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level = | 96 UpgradeDetector::UpgradeNotificationAnnoyanceLevel level = |
| 95 UpgradeDetector::GetInstance()->upgrade_notification_stage(); | 97 UpgradeDetector::GetInstance()->upgrade_notification_stage(); |
| 96 delegate_->UpdateSeverity(IconType::UPGRADE_NOTIFICATION, | 98 delegate_->UpdateSeverity(IconType::UPGRADE_NOTIFICATION, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 124 | 126 |
| 125 void AppMenuIconController::OnConflictsAcknowledged() { | 127 void AppMenuIconController::OnConflictsAcknowledged() { |
| 126 UpdateDelegate(); | 128 UpdateDelegate(); |
| 127 } | 129 } |
| 128 #endif | 130 #endif |
| 129 | 131 |
| 130 void AppMenuIconController::Observe( | 132 void AppMenuIconController::Observe( |
| 131 int type, | 133 int type, |
| 132 const content::NotificationSource& source, | 134 const content::NotificationSource& source, |
| 133 const content::NotificationDetails& details) { | 135 const content::NotificationDetails& details) { |
| 136 DCHECK_EQ(chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, type); |
| 134 UpdateDelegate(); | 137 UpdateDelegate(); |
| 135 } | 138 } |
| 139 |
| 140 void AppMenuIconController::OnUpgradeRecommended() { |
| 141 UpdateDelegate(); |
| 142 } |
| OLD | NEW |