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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_BADGE_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_BADGE_SERVICE_H_
8 #include "base/compiler_specific.h"
9 #include "base/threading/non_thread_safe.h"
10 #include "components/keyed_service/core/keyed_service.h"
11 #include "extensions/browser/warning_service.h"
12 #include "extensions/browser/warning_set.h"
14 // TODO(battre): Rename ExtensionWarningBadgeService to WarningBadgeService.
18 namespace extensions {
20 // A service that is responsible for showing an extension warning badge on the
22 class ExtensionWarningBadgeService : public KeyedService,
23 public WarningService::Observer,
24 public base::NonThreadSafe {
26 explicit ExtensionWarningBadgeService(Profile* profile);
27 virtual ~ExtensionWarningBadgeService();
29 static ExtensionWarningBadgeService* Get(content::BrowserContext* context);
31 // Black lists all currently active extension warnings, so that they do not
32 // trigger a warning badge again for the life-time of the browsing session.
33 void SuppressCurrentWarnings();
36 // Virtual for testing.
37 virtual const std::set<Warning>& GetCurrentWarnings() const;
40 // Implementation of WarningService::Observer.
41 void ExtensionWarningsChanged() override;
43 void UpdateBadgeStatus();
44 virtual void ShowBadge(bool show);
48 ScopedObserver<WarningService, WarningService::Observer>
49 warning_service_observer_;
51 // Warnings that do not trigger a badge on the wrench menu.
52 WarningSet suppressed_warnings_;
54 DISALLOW_COPY_AND_ASSIGN(ExtensionWarningBadgeService);
57 } // namespace extensions
59 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_BADGE_SERVICE_H_