Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / speech / extension_api / tts_engine_extension_observer.h
blob08d38c21ad910b1f7d0bdcac56e0510f5a2ef37a
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.
5 #ifndef CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_
6 #define CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_
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"
14 class Profile;
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);
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);
29 // Implementation of KeyedService.
30 void Shutdown() override;
32 // Implementation of extensions::EventRouter::Observer.
33 void OnListenerAdded(const extensions::EventListenerInfo& details) override;
35 // extensions::ExtensionRegistryObserver overrides.
36 void OnExtensionUnloaded(
37 content::BrowserContext* browser_context,
38 const extensions::Extension* extension,
39 extensions::UnloadedExtensionInfo::Reason reason) override;
41 private:
42 explicit TtsEngineExtensionObserver(Profile* profile);
43 ~TtsEngineExtensionObserver() override;
45 bool IsLoadedTtsEngine(const std::string& extension_id);
47 ScopedObserver<extensions::ExtensionRegistry,
48 extensions::ExtensionRegistryObserver>
49 extension_registry_observer_;
51 Profile* profile_;
53 std::set<std::string> engine_extension_ids_;
55 friend class TtsEngineExtensionObserverFactory;
57 DISALLOW_COPY_AND_ASSIGN(TtsEngineExtensionObserver);
60 #endif // CHROME_BROWSER_SPEECH_EXTENSION_API_TTS_ENGINE_EXTENSION_OBSERVER_H_