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

Unified Diff: chrome/browser/extensions/api/runtime/runtime_api.h

Issue 69883007: Extract chrome.runtime API code from extensions::EventRouter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/runtime_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/runtime/runtime_api.h
diff --git a/chrome/browser/extensions/api/runtime/runtime_api.h b/chrome/browser/extensions/api/runtime/runtime_api.h
index 14c5f79e956ff88dcf455423dc06c3ea5ed54158..abd966757c54a1f499157a6228ad35699216dadc 100644
--- a/chrome/browser/extensions/api/runtime/runtime_api.h
+++ b/chrome/browser/extensions/api/runtime/runtime_api.h
@@ -9,6 +9,7 @@
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/common/extensions/api/runtime.h"
+#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -26,6 +27,36 @@ namespace extensions {
class Extension;
class ExtensionHost;
+// Runtime API dispatches onStartup, onInstalled, and similar events to
+// extensions. There is one instance shared between a browser context and
+// its related incognito instance.
+class RuntimeAPI : public BrowserContextKeyedService,
+ public content::NotificationObserver {
+ public:
+ explicit RuntimeAPI(content::BrowserContext* context);
+ virtual ~RuntimeAPI();
+
+ // content::NotificationObserver overrides:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ private:
+ void OnExtensionsReady();
+ void OnExtensionLoaded(const Extension* extension);
+ void OnExtensionInstalled(const Extension* extension);
+
+ content::BrowserContext* browser_context_;
+
+ // True if we should dispatch the chrome.runtime.onInstalled event with
+ // reason "chrome_update" upon loading each extension.
+ bool dispatch_chrome_updated_event_;
+
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(RuntimeAPI);
+};
+
class RuntimeEventRouter {
public:
// Dispatches the onStartup event to all currently-loaded extensions.
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/runtime_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698