| 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/extensions/warning_badge_service.h" | 5 #include "chrome/browser/extensions/warning_badge_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/extensions/warning_badge_service_factory.h" | 13 #include "chrome/browser/extensions/warning_badge_service_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
| 15 #include "chrome/browser/ui/global_error/global_error.h" | 16 #include "chrome/browser/ui/global_error/global_error.h" |
| 16 #include "chrome/browser/ui/global_error/global_error_service.h" | 17 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 17 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 18 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 18 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 ShowBadge(non_suppressed_warnings_exist); | 148 ShowBadge(non_suppressed_warnings_exist); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void WarningBadgeService::ShowBadge(bool show) { | 151 void WarningBadgeService::ShowBadge(bool show) { |
| 151 GlobalErrorService* service = | 152 GlobalErrorService* service = |
| 152 GlobalErrorServiceFactory::GetForProfile(profile_); | 153 GlobalErrorServiceFactory::GetForProfile(profile_); |
| 153 GlobalError* error = service->GetGlobalErrorByMenuItemCommandID( | 154 GlobalError* error = service->GetGlobalErrorByMenuItemCommandID( |
| 154 ErrorBadge::GetMenuItemCommandID()); | 155 ErrorBadge::GetMenuItemCommandID()); |
| 155 | 156 |
| 156 // Activate or hide the warning badge in case the current state is incorrect. | 157 // Activate or hide the warning badge in case the current state is incorrect. |
| 157 if (error && !show) { | 158 if (error && !show) |
| 158 service->RemoveGlobalError(error); | 159 service->RemoveGlobalError(error); |
| 159 delete error; | 160 else if (!error && show) |
| 160 } else if (!error && show) { | 161 service->AddGlobalError(base::MakeUnique<ErrorBadge>(this)); |
| 161 service->AddGlobalError(new ErrorBadge(this)); | |
| 162 } | |
| 163 } | 162 } |
| 164 | 163 |
| 165 } // namespace extensions | 164 } // namespace extensions |
| OLD | NEW |