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

Side by Side Diff: chrome/browser/extensions/api/runtime/runtime_api.h

Issue 212603020: Break extensions ProcessManager dependency on Runtime API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (pm-observer) Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/runtime_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/extensions/chrome_extension_function.h" 10 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "chrome/common/extensions/api/runtime.h" 11 #include "chrome/common/extensions/api/runtime.h"
12 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
14 #include "extensions/browser/browser_context_keyed_api_factory.h" 14 #include "extensions/browser/browser_context_keyed_api_factory.h"
15 #include "extensions/browser/process_manager_observer.h"
15 #include "extensions/browser/update_observer.h" 16 #include "extensions/browser/update_observer.h"
16 17
17 class Profile; 18 class Profile;
18 19
19 namespace base { 20 namespace base {
20 class Version; 21 class Version;
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 class BrowserContext; 25 class BrowserContext;
25 } 26 }
26 27
27 namespace extensions { 28 namespace extensions {
28 class Extension; 29 class Extension;
29 class ExtensionHost; 30 class ExtensionHost;
30 31
31 // Runtime API dispatches onStartup, onInstalled, and similar events to 32 // Runtime API dispatches onStartup, onInstalled, and similar events to
32 // extensions. There is one instance shared between a browser context and 33 // extensions. There is one instance shared between a browser context and
33 // its related incognito instance. 34 // its related incognito instance.
34 class RuntimeAPI : public BrowserContextKeyedAPI, 35 class RuntimeAPI : public BrowserContextKeyedAPI,
35 public content::NotificationObserver, 36 public content::NotificationObserver,
36 public extensions::UpdateObserver { 37 public UpdateObserver,
38 public ProcessManagerObserver {
37 public: 39 public:
38 static BrowserContextKeyedAPIFactory<RuntimeAPI>* GetFactoryInstance(); 40 static BrowserContextKeyedAPIFactory<RuntimeAPI>* GetFactoryInstance();
39 41
40 explicit RuntimeAPI(content::BrowserContext* context); 42 explicit RuntimeAPI(content::BrowserContext* context);
41 virtual ~RuntimeAPI(); 43 virtual ~RuntimeAPI();
42 44
43 // content::NotificationObserver overrides: 45 // content::NotificationObserver overrides:
44 virtual void Observe(int type, 46 virtual void Observe(int type,
45 const content::NotificationSource& source, 47 const content::NotificationSource& source,
46 const content::NotificationDetails& details) OVERRIDE; 48 const content::NotificationDetails& details) OVERRIDE;
47 49
48 private: 50 private:
49 friend class BrowserContextKeyedAPIFactory<RuntimeAPI>; 51 friend class BrowserContextKeyedAPIFactory<RuntimeAPI>;
50 52
51 void OnExtensionsReady(); 53 void OnExtensionsReady();
52 void OnExtensionLoaded(const Extension* extension); 54 void OnExtensionLoaded(const Extension* extension);
53 void OnExtensionInstalled(const Extension* extension); 55 void OnExtensionInstalled(const Extension* extension);
54 void OnExtensionUninstalled(const Extension* extension); 56 void OnExtensionUninstalled(const Extension* extension);
55 57
56 // BrowserContextKeyedAPI implementation: 58 // BrowserContextKeyedAPI implementation:
57 static const char* service_name() { return "RuntimeAPI"; } 59 static const char* service_name() { return "RuntimeAPI"; }
58 static const bool kServiceRedirectedInIncognito = true; 60 static const bool kServiceRedirectedInIncognito = true;
59 static const bool kServiceIsNULLWhileTesting = true; 61 static const bool kServiceIsNULLWhileTesting = true;
62 virtual void Shutdown() OVERRIDE;
60 63
61 // extensions::UpdateObserver overrides: 64 // extensions::UpdateObserver overrides:
62 virtual void OnAppUpdateAvailable(const Extension* extension) OVERRIDE; 65 virtual void OnAppUpdateAvailable(const Extension* extension) OVERRIDE;
63 virtual void OnChromeUpdateAvailable() OVERRIDE; 66 virtual void OnChromeUpdateAvailable() OVERRIDE;
64 67
68 // ProcessManagerObserver implementation:
69 virtual void OnBackgroundHostStartup(const Extension* extension) OVERRIDE;
70
65 content::BrowserContext* browser_context_; 71 content::BrowserContext* browser_context_;
66 72
67 // True if we should dispatch the chrome.runtime.onInstalled event with 73 // True if we should dispatch the chrome.runtime.onInstalled event with
68 // reason "chrome_update" upon loading each extension. 74 // reason "chrome_update" upon loading each extension.
69 bool dispatch_chrome_updated_event_; 75 bool dispatch_chrome_updated_event_;
70 76
71 // Whether the API registered with the ExtensionService to receive 77 // Whether the API registered with the ExtensionService to receive
72 // update notifications. 78 // update notifications.
73 bool registered_for_updates_; 79 bool registered_for_updates_;
74 80
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 RUNTIME_GETPACKAGEDIRECTORYENTRY) 195 RUNTIME_GETPACKAGEDIRECTORYENTRY)
190 196
191 protected: 197 protected:
192 virtual ~RuntimeGetPackageDirectoryEntryFunction() {} 198 virtual ~RuntimeGetPackageDirectoryEntryFunction() {}
193 virtual bool RunImpl() OVERRIDE; 199 virtual bool RunImpl() OVERRIDE;
194 }; 200 };
195 201
196 } // namespace extensions 202 } // namespace extensions
197 203
198 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_ 204 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_
OLDNEW
« 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