Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: extensions/browser/warning_service.h

Issue 1146693004: [Extensions] Move remaining notifications out of ExtensionSettingsHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ben's Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 20 matching lines...) Expand all
31 // Manages a set of warnings caused by extensions. These warnings (e.g. 31 // Manages a set of warnings caused by extensions. These warnings (e.g.
32 // conflicting modifications of network requests by extensions, slow extensions, 32 // conflicting modifications of network requests by extensions, slow extensions,
33 // etc.) trigger a warning badge in the UI and and provide means to resolve 33 // etc.) trigger a warning badge in the UI and and provide means to resolve
34 // them. This class must be used on the UI thread only. 34 // them. This class must be used on the UI thread only.
35 class WarningService : public KeyedService, 35 class WarningService : public KeyedService,
36 public ExtensionRegistryObserver, 36 public ExtensionRegistryObserver,
37 public base::NonThreadSafe { 37 public base::NonThreadSafe {
38 public: 38 public:
39 class Observer { 39 class Observer {
40 public: 40 public:
41 virtual void ExtensionWarningsChanged() = 0; 41 virtual void ExtensionWarningsChanged(
42 const ExtensionIdSet& affected_extensions) = 0;
42 }; 43 };
43 44
44 // |browser_context| may be NULL for testing. In this case, be sure to not 45 // |browser_context| may be NULL for testing. In this case, be sure to not
45 // insert any warnings. 46 // insert any warnings.
46 explicit WarningService(content::BrowserContext* browser_context); 47 explicit WarningService(content::BrowserContext* browser_context);
47 ~WarningService() override; 48 ~WarningService() override;
48 49
49 // Get the instance of the WarningService for |browser_context|. 50 // Get the instance of the WarningService for |browser_context|.
50 // Redirected in incognito. 51 // Redirected in incognito.
51 static WarningService* Get(content::BrowserContext* browser_context); 52 static WarningService* Get(content::BrowserContext* browser_context);
(...skipping 16 matching lines...) Expand all
68 void AddWarnings(const WarningSet& warnings); 69 void AddWarnings(const WarningSet& warnings);
69 70
70 // Notifies the WarningService of browser_context |browser_context_id| that 71 // Notifies the WarningService of browser_context |browser_context_id| that
71 // new |warnings| occurred and triggers a warning badge. 72 // new |warnings| occurred and triggers a warning badge.
72 static void NotifyWarningsOnUI(void* profile_id, const WarningSet& warnings); 73 static void NotifyWarningsOnUI(void* profile_id, const WarningSet& warnings);
73 74
74 void AddObserver(Observer* observer); 75 void AddObserver(Observer* observer);
75 void RemoveObserver(Observer* observer); 76 void RemoveObserver(Observer* observer);
76 77
77 private: 78 private:
78 void NotifyWarningsChanged(); 79 void NotifyWarningsChanged(const ExtensionIdSet& affected_extensions);
79 80
80 // ExtensionRegistryObserver implementation. 81 // ExtensionRegistryObserver implementation.
81 void OnExtensionUnloaded(content::BrowserContext* browser_context, 82 void OnExtensionUnloaded(content::BrowserContext* browser_context,
82 const Extension* extension, 83 const Extension* extension,
83 UnloadedExtensionInfo::Reason reason) override; 84 UnloadedExtensionInfo::Reason reason) override;
84 85
85 // Currently existing warnings. 86 // Currently existing warnings.
86 WarningSet warnings_; 87 WarningSet warnings_;
87 88
88 content::BrowserContext* const browser_context_; 89 content::BrowserContext* const browser_context_;
89 90
90 // Listen to extension unloaded notifications. 91 // Listen to extension unloaded notifications.
91 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 92 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
92 extension_registry_observer_; 93 extension_registry_observer_;
93 94
94 ObserverList<Observer> observer_list_; 95 ObserverList<Observer> observer_list_;
95 }; 96 };
96 97
97 } // namespace extensions 98 } // namespace extensions
98 99
99 #endif // EXTENSIONS_BROWSER_WARNING_SERVICE_H_ 100 #endif // EXTENSIONS_BROWSER_WARNING_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/developer_private.idl ('k') | extensions/browser/warning_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698