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

Unified Diff: extensions/browser/events/lazy_event_dispatch_util.h

Issue 2893693002: Remove NOTIFICATION_EXTENSION_ENABLED. (Closed)
Patch Set: sync and rebase theme_service.cc Created 3 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/events/lazy_event_dispatch_util.h
diff --git a/extensions/browser/events/lazy_event_dispatch_util.h b/extensions/browser/events/lazy_event_dispatch_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..4f3077d5b72e47e76864936d7bd840f697fffd41
--- /dev/null
+++ b/extensions/browser/events/lazy_event_dispatch_util.h
@@ -0,0 +1,68 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_EVENTS_LAZY_EVENT_DISPATCH_UTIL_H_
+#define EXTENSIONS_BROWSER_EVENTS_LAZY_EVENT_DISPATCH_UTIL_H_
+
+#include "base/observer_list.h"
+#include "base/scoped_observer.h"
+#include "extensions/browser/extension_registry_observer.h"
+#include "extensions/browser/uninstall_reason.h"
+
+namespace base {
+class Version;
+}
+
+namespace extensions {
+
+class LazyEventDispatchUtil : public ExtensionRegistryObserver {
Devlin 2017/06/05 15:38:38 class comments. In particular, it might be nice t
lazyboy 2017/06/05 21:54:01 Done.
+ public:
+ // Helps observer with events for lazy event dispatching.
+ class Observer {
+ public:
+ // Called when an extension is loaded after installation, for one of the
+ // following scenarios:
+ // 1. New extension is installed.
+ // 2. An extension is updated and loaded.
+ // 3. An extension is enabled after it was disabled during an update.
+ virtual void OnExtensionInstalledAndLoaded(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ const base::Version& old_version) {}
+ };
+
+ explicit LazyEventDispatchUtil(content::BrowserContext* browser_context);
+ ~LazyEventDispatchUtil() override;
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ // ExtensionRegistryObserver:
+ void OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) override;
+ void OnExtensionWillBeInstalled(content::BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update,
+ const std::string& old_name) override;
+ void OnExtensionUninstalled(content::BrowserContext* browser_context,
+ const Extension* extension,
+ UninstallReason reason) override;
+
+ private:
+ bool ReadPendingOnInstallInfoFromPref(const ExtensionId& extension_id,
+ base::Version* previous_version);
+ void RemovePendingOnInstallInfoFromPref(const ExtensionId& extension_id);
+ void StorePendingOnInstallInfoToPref(const Extension* extension);
+
+ content::BrowserContext* browser_context_;
+ base::ObserverList<Observer> observers_;
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ extension_registry_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(LazyEventDispatchUtil);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_EVENTS_LAZY_EVENT_DISPATCH_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698