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