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 EXTENSIONS_BROWSER_WARNING_SERVICE_H_ | 5 #ifndef EXTENSIONS_BROWSER_WARNING_SERVICE_H_ |
6 #define EXTENSIONS_BROWSER_WARNING_SERVICE_H_ | 6 #define EXTENSIONS_BROWSER_WARNING_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
14 #include "base/threading/non_thread_safe.h" | |
15 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
16 #include "extensions/browser/extension_registry_observer.h" | 15 #include "extensions/browser/extension_registry_observer.h" |
17 #include "extensions/browser/warning_set.h" | 16 #include "extensions/browser/warning_set.h" |
18 | 17 |
19 // TODO(battre) Remove the Extension prefix. | 18 // TODO(battre) Remove the Extension prefix. |
20 | 19 |
21 namespace content { | 20 namespace content { |
22 class BrowserContext; | 21 class BrowserContext; |
23 } | 22 } |
24 | 23 |
25 namespace extensions { | 24 namespace extensions { |
26 | 25 |
27 class ExtensionRegistry; | 26 class ExtensionRegistry; |
28 | 27 |
29 // Manages a set of warnings caused by extensions. These warnings (e.g. | 28 // Manages a set of warnings caused by extensions. These warnings (e.g. |
30 // conflicting modifications of network requests by extensions, slow extensions, | 29 // conflicting modifications of network requests by extensions, slow extensions, |
31 // etc.) trigger a warning badge in the UI and and provide means to resolve | 30 // etc.) trigger a warning badge in the UI and and provide means to resolve |
32 // them. This class must be used on the UI thread only. | 31 // them. This class must be used on the UI thread only. |
33 class WarningService : public KeyedService, | 32 class WarningService : public KeyedService, public ExtensionRegistryObserver { |
34 public ExtensionRegistryObserver, | |
35 public base::NonThreadSafe { | |
36 public: | 33 public: |
37 class Observer { | 34 class Observer { |
38 public: | 35 public: |
39 virtual void ExtensionWarningsChanged( | 36 virtual void ExtensionWarningsChanged( |
40 const ExtensionIdSet& affected_extensions) = 0; | 37 const ExtensionIdSet& affected_extensions) = 0; |
41 }; | 38 }; |
42 | 39 |
43 // |browser_context| may be NULL for testing. In this case, be sure to not | 40 // |browser_context| may be NULL for testing. In this case, be sure to not |
44 // insert any warnings. | 41 // insert any warnings. |
45 explicit WarningService(content::BrowserContext* browser_context); | 42 explicit WarningService(content::BrowserContext* browser_context); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Listen to extension unloaded notifications. | 86 // Listen to extension unloaded notifications. |
90 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 87 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
91 extension_registry_observer_; | 88 extension_registry_observer_; |
92 | 89 |
93 base::ObserverList<Observer> observer_list_; | 90 base::ObserverList<Observer> observer_list_; |
94 }; | 91 }; |
95 | 92 |
96 } // namespace extensions | 93 } // namespace extensions |
97 | 94 |
98 #endif // EXTENSIONS_BROWSER_WARNING_SERVICE_H_ | 95 #endif // EXTENSIONS_BROWSER_WARNING_SERVICE_H_ |
OLD | NEW |