| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ | 6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
| 9 #include "components/keyed_service/core/keyed_service.h" | 9 #include "components/keyed_service/core/keyed_service.h" |
| 10 #include "extensions/browser/event_router.h" | 10 #include "extensions/browser/event_router.h" |
| 11 #include "extensions/browser/extension_registry.h" | 11 #include "extensions/browser/extension_registry.h" |
| 12 #include "extensions/browser/extension_registry_observer.h" | 12 #include "extensions/browser/extension_registry_observer.h" |
| 13 | 13 |
| 14 class Profile; | 14 class Profile; |
| 15 | 15 |
| 16 // Profile-keyed class that observes the extension registry to determine load of | 16 // Profile-keyed class that observes the extension registry to determine load of |
| 17 // extension-based tts engines. | 17 // extension-based tts engines. |
| 18 class TtsEngineExtensionObserver | 18 class TtsEngineExtensionObserver |
| 19 : public KeyedService, | 19 : public KeyedService, |
| 20 public extensions::EventRouter::Observer, | 20 public extensions::EventRouter::Observer, |
| 21 public extensions::ExtensionRegistryObserver { | 21 public extensions::ExtensionRegistryObserver { |
| 22 public: | 22 public: |
| 23 static TtsEngineExtensionObserver* GetInstance(Profile* profile); | 23 static TtsEngineExtensionObserver* GetInstance(Profile* profile); |
| 24 | 24 |
| 25 // Returns if this observer saw the given extension load. Adds |extension_id| | 25 // Returns if this observer saw the given extension load. Adds |extension_id| |
| 26 // as loaded immediately if |update| is set to true. | 26 // as loaded immediately if |update| is set to true. |
| 27 bool SawExtensionLoad(const std::string& extension_id, bool update); | 27 bool SawExtensionLoad(const std::string& extension_id, bool update); |
| 28 | 28 |
| 29 // Implementation of KeyedService. | 29 // Implementation of KeyedService. |
| 30 virtual void Shutdown() OVERRIDE; | 30 virtual void Shutdown() override; |
| 31 | 31 |
| 32 // Implementation of extensions::EventRouter::Observer. | 32 // Implementation of extensions::EventRouter::Observer. |
| 33 virtual void OnListenerAdded( | 33 virtual void OnListenerAdded( |
| 34 const extensions::EventListenerInfo& details) OVERRIDE; | 34 const extensions::EventListenerInfo& details) override; |
| 35 | 35 |
| 36 // extensions::ExtensionRegistryObserver overrides. | 36 // extensions::ExtensionRegistryObserver overrides. |
| 37 virtual void OnExtensionUnloaded( | 37 virtual void OnExtensionUnloaded( |
| 38 content::BrowserContext* browser_context, | 38 content::BrowserContext* browser_context, |
| 39 const extensions::Extension* extension, | 39 const extensions::Extension* extension, |
| 40 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; | 40 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 explicit TtsEngineExtensionObserver(Profile* profile); | 43 explicit TtsEngineExtensionObserver(Profile* profile); |
| 44 virtual ~TtsEngineExtensionObserver(); | 44 virtual ~TtsEngineExtensionObserver(); |
| 45 | 45 |
| 46 bool IsLoadedTtsEngine(const std::string& extension_id); | 46 bool IsLoadedTtsEngine(const std::string& extension_id); |
| 47 | 47 |
| 48 ScopedObserver<extensions::ExtensionRegistry, | 48 ScopedObserver<extensions::ExtensionRegistry, |
| 49 extensions::ExtensionRegistryObserver> | 49 extensions::ExtensionRegistryObserver> |
| 50 extension_registry_observer_; | 50 extension_registry_observer_; |
| 51 | 51 |
| 52 Profile* profile_; | 52 Profile* profile_; |
| 53 | 53 |
| 54 std::set<std::string> engine_extension_ids_; | 54 std::set<std::string> engine_extension_ids_; |
| 55 | 55 |
| 56 friend class TtsEngineExtensionObserverFactory; | 56 friend class TtsEngineExtensionObserverFactory; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(TtsEngineExtensionObserver); | 58 DISALLOW_COPY_AND_ASSIGN(TtsEngineExtensionObserver); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ | 61 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_ |
| OLD | NEW |