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"
16 namespace extensions
{
18 // A service that is responsible for showing an extension warning badge on the
20 class WarningBadgeService
: public KeyedService
,
21 public WarningService::Observer
,
22 public base::NonThreadSafe
{
24 explicit WarningBadgeService(Profile
* profile
);
25 ~WarningBadgeService() override
;
27 static WarningBadgeService
* Get(content::BrowserContext
* context
);
29 // Black lists all currently active extension warnings, so that they do not
30 // trigger a warning badge again for the life-time of the browsing session.
31 void SuppressCurrentWarnings();
34 // Virtual for testing.
35 virtual const std::set
<Warning
>& GetCurrentWarnings() const;
38 // Implementation of WarningService::Observer.
39 void ExtensionWarningsChanged(
40 const ExtensionIdSet
& affected_extensions
) override
;
42 void UpdateBadgeStatus();
43 virtual void ShowBadge(bool show
);
47 ScopedObserver
<WarningService
, WarningService::Observer
>
48 warning_service_observer_
;
50 // Warnings that do not trigger a badge on the wrench menu.
51 WarningSet suppressed_warnings_
;
53 DISALLOW_COPY_AND_ASSIGN(WarningBadgeService
);
56 } // namespace extensions
58 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_BADGE_SERVICE_H_