| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SPELLCHECK_SPELLCHECK_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_ |
| 7 | 7 |
| 8 #include "base/scoped_observer.h" |
| 8 #include "content/public/browser/notification_observer.h" | 9 #include "content/public/browser/notification_observer.h" |
| 9 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| 10 #include "extensions/browser/browser_context_keyed_api_factory.h" | 11 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 11 | 12 #include "extensions/browser/extension_registry_observer.h" |
| 12 class Profile; | |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 class ExtensionRegistry; |
| 15 | 16 |
| 16 class SpellcheckAPI : public BrowserContextKeyedAPI, | 17 class SpellcheckAPI : public BrowserContextKeyedAPI, |
| 17 public content::NotificationObserver { | 18 public ExtensionRegistryObserver { |
| 18 public: | 19 public: |
| 19 explicit SpellcheckAPI(content::BrowserContext* context); | 20 explicit SpellcheckAPI(content::BrowserContext* context); |
| 20 virtual ~SpellcheckAPI(); | 21 virtual ~SpellcheckAPI(); |
| 21 | 22 |
| 22 // BrowserContextKeyedAPI implementation. | 23 // BrowserContextKeyedAPI implementation. |
| 23 static BrowserContextKeyedAPIFactory<SpellcheckAPI>* GetFactoryInstance(); | 24 static BrowserContextKeyedAPIFactory<SpellcheckAPI>* GetFactoryInstance(); |
| 24 | 25 |
| 25 private: | 26 private: |
| 26 friend class BrowserContextKeyedAPIFactory<SpellcheckAPI>; | 27 friend class BrowserContextKeyedAPIFactory<SpellcheckAPI>; |
| 27 | 28 |
| 28 // content::NotificationDelegate implementation. | 29 // ExtensionRegistryObserver implementation. |
| 29 virtual void Observe(int type, | 30 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 30 const content::NotificationSource& source, | 31 const Extension* extension) OVERRIDE; |
| 31 const content::NotificationDetails& details) OVERRIDE; | 32 virtual void OnExtensionUnloaded( |
| 33 content::BrowserContext* browser_context, |
| 34 const Extension* extension, |
| 35 UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 32 | 36 |
| 33 // BrowserContextKeyedAPI implementation. | 37 // BrowserContextKeyedAPI implementation. |
| 34 static const char* service_name() { | 38 static const char* service_name() { |
| 35 return "SpellcheckAPI"; | 39 return "SpellcheckAPI"; |
| 36 } | 40 } |
| 37 | 41 |
| 38 content::NotificationRegistrar registrar_; | 42 // Listen to extension load, unloaded notifications. |
| 43 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 44 extension_registry_observer_; |
| 39 | 45 |
| 40 DISALLOW_COPY_AND_ASSIGN(SpellcheckAPI); | 46 DISALLOW_COPY_AND_ASSIGN(SpellcheckAPI); |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 template <> | 49 template <> |
| 44 void BrowserContextKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies(); | 50 void BrowserContextKeyedAPIFactory<SpellcheckAPI>::DeclareFactoryDependencies(); |
| 45 | 51 |
| 46 } // namespace extensions | 52 } // namespace extensions |
| 47 | 53 |
| 48 #endif // CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_API_SPELLCHECK_SPELLCHECK_API_H_ |
| OLD | NEW |