OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SPEECH_TTS_ENGINE_EXTENSION_OBSERVER_H_ | |
dmazzoni
2014/07/07 15:37:26
Move this into the extension_api directory. I'm tr
| |
6 #define CHROME_BROWSER_SPEECH_TTS_ENGINE_EXTENSION_OBSERVER_H_ | |
7 | |
8 #include "base/scoped_observer.h" | |
9 #include "components/keyed_service/core/keyed_service.h" | |
10 #include "extensions/browser/event_router.h" | |
11 #include "extensions/browser/extension_registry.h" | |
12 #include "extensions/browser/extension_registry_observer.h" | |
13 | |
14 class Profile; | |
15 | |
16 // Profile-keyed class that observes the extension registry to determine load of | |
17 // extension-based tts engines. | |
18 class TtsEngineExtensionObserver | |
19 : public KeyedService, | |
20 public extensions::EventRouter::Observer, | |
21 public extensions::ExtensionRegistryObserver { | |
22 public: | |
23 static TtsEngineExtensionObserver* GetInstance(Profile* profile); | |
24 | |
25 // Returns if this observer saw the given extension load. Adds |extension_id| | |
26 // as loaded immediately if |update| is set to true. | |
27 bool SawExtensionLoad(const std::string& extension_id, bool update); | |
dmazzoni
2014/07/07 15:37:26
Is it possible for the extension to load before th
David Tseng
2014/07/08 23:43:31
See the new change; I think TtsApi gets initialize
| |
28 | |
29 // Implementation of KeyedService. | |
30 virtual void Shutdown() OVERRIDE; | |
31 | |
32 // Implementation of extensions::EventRouter::Observer. | |
33 virtual void OnListenerAdded( | |
34 const extensions::EventListenerInfo& details) OVERRIDE; | |
35 | |
36 // extensions::ExtensionRegistryObserver overrides. | |
37 virtual void OnExtensionUnloaded( | |
38 content::BrowserContext* browser_context, | |
39 const extensions::Extension* extension, | |
40 extensions::UnloadedExtensionInfo::Reason reason); | |
41 | |
42 private: | |
43 explicit TtsEngineExtensionObserver(Profile* profile); | |
44 virtual ~TtsEngineExtensionObserver() {} | |
45 | |
46 bool IsLoadedTtsEngine(const std::string& extension_id); | |
47 | |
48 ScopedObserver<extensions::ExtensionRegistry, | |
49 extensions::ExtensionRegistryObserver> | |
50 extension_registry_observer_; | |
51 | |
52 Profile* profile_; | |
53 | |
54 bool saw_tts_engine_added_; | |
55 | |
56 std::set<std::string> engine_extension_ids_; | |
57 | |
58 friend class TtsEngineExtensionObserverFactory; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(TtsEngineExtensionObserver); | |
61 }; | |
62 | |
63 #endif // CHROME_BROWSER_SPEECH_TTS_ENGINE_EXTENSION_OBSERVER_H_ | |
OLD | NEW |