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 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/api/profile_keyed_api_factory.h" | |
11 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
12 #include "chrome/common/extensions/api/runtime.h" | 11 #include "chrome/common/extensions/api/runtime.h" |
13 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
14 #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" |
15 #include "extensions/browser/update_observer.h" | 15 #include "extensions/browser/update_observer.h" |
16 | 16 |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class Version; | 20 class Version; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 class BrowserContext; | 24 class BrowserContext; |
25 } | 25 } |
26 | 26 |
27 namespace extensions { | 27 namespace extensions { |
28 class Extension; | 28 class Extension; |
29 class ExtensionHost; | 29 class ExtensionHost; |
30 | 30 |
31 // Runtime API dispatches onStartup, onInstalled, and similar events to | 31 // Runtime API dispatches onStartup, onInstalled, and similar events to |
32 // extensions. There is one instance shared between a browser context and | 32 // extensions. There is one instance shared between a browser context and |
33 // its related incognito instance. | 33 // its related incognito instance. |
34 class RuntimeAPI : public ProfileKeyedAPI, | 34 class RuntimeAPI : public BrowserContextKeyedAPI, |
35 public content::NotificationObserver, | 35 public content::NotificationObserver, |
36 public extensions::UpdateObserver { | 36 public extensions::UpdateObserver { |
37 public: | 37 public: |
38 static ProfileKeyedAPIFactory<RuntimeAPI>* GetFactoryInstance(); | 38 static BrowserContextKeyedAPIFactory<RuntimeAPI>* GetFactoryInstance(); |
39 | 39 |
40 explicit RuntimeAPI(content::BrowserContext* context); | 40 explicit RuntimeAPI(content::BrowserContext* context); |
41 virtual ~RuntimeAPI(); | 41 virtual ~RuntimeAPI(); |
42 | 42 |
43 // content::NotificationObserver overrides: | 43 // content::NotificationObserver overrides: |
44 virtual void Observe(int type, | 44 virtual void Observe(int type, |
45 const content::NotificationSource& source, | 45 const content::NotificationSource& source, |
46 const content::NotificationDetails& details) OVERRIDE; | 46 const content::NotificationDetails& details) OVERRIDE; |
47 | 47 |
48 private: | 48 private: |
49 friend class ProfileKeyedAPIFactory<RuntimeAPI>; | 49 friend class BrowserContextKeyedAPIFactory<RuntimeAPI>; |
50 | 50 |
51 void OnExtensionsReady(); | 51 void OnExtensionsReady(); |
52 void OnExtensionLoaded(const Extension* extension); | 52 void OnExtensionLoaded(const Extension* extension); |
53 void OnExtensionInstalled(const Extension* extension); | 53 void OnExtensionInstalled(const Extension* extension); |
54 void OnExtensionUninstalled(const Extension* extension); | 54 void OnExtensionUninstalled(const Extension* extension); |
55 | 55 |
56 // ProfileKeyedAPI implementation: | 56 // BrowserContextKeyedAPI implementation: |
57 static const char* service_name() { return "RuntimeAPI"; } | 57 static const char* service_name() { return "RuntimeAPI"; } |
58 static const bool kServiceRedirectedInIncognito = true; | 58 static const bool kServiceRedirectedInIncognito = true; |
59 static const bool kServiceIsNULLWhileTesting = true; | 59 static const bool kServiceIsNULLWhileTesting = true; |
60 | 60 |
61 // extensions::UpdateObserver overrides: | 61 // extensions::UpdateObserver overrides: |
62 virtual void OnAppUpdateAvailable(const Extension* extension) OVERRIDE; | 62 virtual void OnAppUpdateAvailable(const Extension* extension) OVERRIDE; |
63 virtual void OnChromeUpdateAvailable() OVERRIDE; | 63 virtual void OnChromeUpdateAvailable() OVERRIDE; |
64 | 64 |
65 content::BrowserContext* browser_context_; | 65 content::BrowserContext* browser_context_; |
66 | 66 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 RUNTIME_GETPACKAGEDIRECTORYENTRY) | 189 RUNTIME_GETPACKAGEDIRECTORYENTRY) |
190 | 190 |
191 protected: | 191 protected: |
192 virtual ~RuntimeGetPackageDirectoryEntryFunction() {} | 192 virtual ~RuntimeGetPackageDirectoryEntryFunction() {} |
193 virtual bool RunImpl() OVERRIDE; | 193 virtual bool RunImpl() OVERRIDE; |
194 }; | 194 }; |
195 | 195 |
196 } // namespace extensions | 196 } // namespace extensions |
197 | 197 |
198 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_ | 198 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_ |
OLD | NEW |