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

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

Issue 168253002: Cleanup many APIs to use ProfileKeyedAPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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
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/api/profile_keyed_api_factory.h"
10 #include "chrome/browser/extensions/chrome_extension_function.h" 11 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "chrome/common/extensions/api/runtime.h" 12 #include "chrome/common/extensions/api/runtime.h"
12 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.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 BrowserContextKeyedService, 34 class RuntimeAPI : public ProfileKeyedAPI,
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();
39
38 explicit RuntimeAPI(content::BrowserContext* context); 40 explicit RuntimeAPI(content::BrowserContext* context);
39 virtual ~RuntimeAPI(); 41 virtual ~RuntimeAPI();
40 42
41 // content::NotificationObserver overrides: 43 // content::NotificationObserver overrides:
42 virtual void Observe(int type, 44 virtual void Observe(int type,
43 const content::NotificationSource& source, 45 const content::NotificationSource& source,
44 const content::NotificationDetails& details) OVERRIDE; 46 const content::NotificationDetails& details) OVERRIDE;
45 47
46 private: 48 private:
49 friend class ProfileKeyedAPIFactory<RuntimeAPI>;
50
47 void OnExtensionsReady(); 51 void OnExtensionsReady();
48 void OnExtensionLoaded(const Extension* extension); 52 void OnExtensionLoaded(const Extension* extension);
49 void OnExtensionInstalled(const Extension* extension); 53 void OnExtensionInstalled(const Extension* extension);
50 void OnExtensionUninstalled(const Extension* extension); 54 void OnExtensionUninstalled(const Extension* extension);
51 55
56 // ProfileKeyedAPI implementation:
57 static const char* service_name() { return "RuntimeAPI"; }
58 static const bool kServiceRedirectedInIncognito = true;
59 static const bool kServiceIsNULLWhileTesting = true;
60
52 // extensions::UpdateObserver overrides: 61 // extensions::UpdateObserver overrides:
53 virtual void OnAppUpdateAvailable(const Extension* extension) OVERRIDE; 62 virtual void OnAppUpdateAvailable(const Extension* extension) OVERRIDE;
54 virtual void OnChromeUpdateAvailable() OVERRIDE; 63 virtual void OnChromeUpdateAvailable() OVERRIDE;
55 64
56 content::BrowserContext* browser_context_; 65 content::BrowserContext* browser_context_;
57 66
58 // True if we should dispatch the chrome.runtime.onInstalled event with 67 // True if we should dispatch the chrome.runtime.onInstalled event with
59 // reason "chrome_update" upon loading each extension. 68 // reason "chrome_update" upon loading each extension.
60 bool dispatch_chrome_updated_event_; 69 bool dispatch_chrome_updated_event_;
61 70
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 RUNTIME_GETPACKAGEDIRECTORYENTRY) 189 RUNTIME_GETPACKAGEDIRECTORYENTRY)
181 190
182 protected: 191 protected:
183 virtual ~RuntimeGetPackageDirectoryEntryFunction() {} 192 virtual ~RuntimeGetPackageDirectoryEntryFunction() {}
184 virtual bool RunImpl() OVERRIDE; 193 virtual bool RunImpl() OVERRIDE;
185 }; 194 };
186 195
187 } // namespace extensions 196 } // namespace extensions
188 197
189 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_ 198 #endif // CHROME_BROWSER_EXTENSIONS_API_RUNTIME_RUNTIME_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698