Chromium Code Reviews| 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" | 14 #include "base/sequence_checker.h" |
| 15 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
| 16 #include "extensions/browser/extension_registry_observer.h" | 16 #include "extensions/browser/extension_registry_observer.h" |
| 17 #include "extensions/browser/warning_set.h" | 17 #include "extensions/browser/warning_set.h" |
| 18 | 18 |
| 19 // TODO(battre) Remove the Extension prefix. | 19 // TODO(battre) Remove the Extension prefix. |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 class BrowserContext; | 22 class BrowserContext; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace extensions { | 25 namespace extensions { |
| 26 | 26 |
| 27 class ExtensionRegistry; | 27 class ExtensionRegistry; |
| 28 | 28 |
| 29 // Manages a set of warnings caused by extensions. These warnings (e.g. | 29 // Manages a set of warnings caused by extensions. These warnings (e.g. |
| 30 // conflicting modifications of network requests by extensions, slow extensions, | 30 // conflicting modifications of network requests by extensions, slow extensions, |
| 31 // etc.) trigger a warning badge in the UI and and provide means to resolve | 31 // 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. | 32 // them. This class must be used on the UI thread only. |
|
Devlin
2017/05/30 19:06:47
I'm not sure that SequenceChecker is right for thi
gab
2017/05/31 17:52:28
Done.
| |
| 33 class WarningService : public KeyedService, | 33 class WarningService : public KeyedService, public ExtensionRegistryObserver { |
| 34 public ExtensionRegistryObserver, | |
| 35 public base::NonThreadSafe { | |
| 36 public: | 34 public: |
| 37 class Observer { | 35 class Observer { |
| 38 public: | 36 public: |
| 39 virtual void ExtensionWarningsChanged( | 37 virtual void ExtensionWarningsChanged( |
| 40 const ExtensionIdSet& affected_extensions) = 0; | 38 const ExtensionIdSet& affected_extensions) = 0; |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 // |browser_context| may be NULL for testing. In this case, be sure to not | 41 // |browser_context| may be NULL for testing. In this case, be sure to not |
| 44 // insert any warnings. | 42 // insert any warnings. |
| 45 explicit WarningService(content::BrowserContext* browser_context); | 43 explicit WarningService(content::BrowserContext* browser_context); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 // Currently existing warnings. | 82 // Currently existing warnings. |
| 85 WarningSet warnings_; | 83 WarningSet warnings_; |
| 86 | 84 |
| 87 content::BrowserContext* const browser_context_; | 85 content::BrowserContext* const browser_context_; |
| 88 | 86 |
| 89 // Listen to extension unloaded notifications. | 87 // Listen to extension unloaded notifications. |
| 90 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 88 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 91 extension_registry_observer_; | 89 extension_registry_observer_; |
| 92 | 90 |
| 93 base::ObserverList<Observer> observer_list_; | 91 base::ObserverList<Observer> observer_list_; |
| 92 | |
| 93 SEQUENCE_CHECKER(sequence_checker_); | |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace extensions | 96 } // namespace extensions |
| 97 | 97 |
| 98 #endif // EXTENSIONS_BROWSER_WARNING_SERVICE_H_ | 98 #endif // EXTENSIONS_BROWSER_WARNING_SERVICE_H_ |
| OLD | NEW |