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