OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_BADGE_SERVICE_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_BADGE_SERVICE_H_ | |
7 | |
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" | |
13 | |
14 // TODO(battre): Rename ExtensionWarningBadgeService to WarningBadgeService. | |
15 | |
16 class Profile; | |
17 | |
18 namespace extensions { | |
19 | |
20 // A service that is responsible for showing an extension warning badge on the | |
21 // wrench menu. | |
22 class ExtensionWarningBadgeService : public KeyedService, | |
23 public WarningService::Observer, | |
24 public base::NonThreadSafe { | |
25 public: | |
26 explicit ExtensionWarningBadgeService(Profile* profile); | |
27 ~ExtensionWarningBadgeService() override; | |
28 | |
29 static ExtensionWarningBadgeService* Get(content::BrowserContext* context); | |
30 | |
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(); | |
34 | |
35 protected: | |
36 // Virtual for testing. | |
37 virtual const std::set<Warning>& GetCurrentWarnings() const; | |
38 | |
39 private: | |
40 // Implementation of WarningService::Observer. | |
41 void ExtensionWarningsChanged() override; | |
42 | |
43 void UpdateBadgeStatus(); | |
44 virtual void ShowBadge(bool show); | |
45 | |
46 Profile* profile_; | |
47 | |
48 ScopedObserver<WarningService, WarningService::Observer> | |
49 warning_service_observer_; | |
50 | |
51 // Warnings that do not trigger a badge on the wrench menu. | |
52 WarningSet suppressed_warnings_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(ExtensionWarningBadgeService); | |
55 }; | |
56 | |
57 } // namespace extensions | |
58 | |
59 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WARNING_BADGE_SERVICE_H_ | |
OLD | NEW |