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

Unified Diff: chrome/browser/speech/tts_engine_extension_observer.h

Issue 361363003: Support onvoiceschanged for extension-based tts engines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/speech/tts_engine_extension_observer.h
diff --git a/chrome/browser/speech/tts_engine_extension_observer.h b/chrome/browser/speech/tts_engine_extension_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..299a175abe8e9ce734c027dd00f7a4e11a8662b2
--- /dev/null
+++ b/chrome/browser/speech/tts_engine_extension_observer.h
@@ -0,0 +1,63 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#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
+#define CHROME_BROWSER_SPEECH_TTS_ENGINE_EXTENSION_OBSERVER_H_
+
+#include "base/scoped_observer.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_registry_observer.h"
+
+class Profile;
+
+// Profile-keyed class that observes the extension registry to determine load of
+// extension-based tts engines.
+class TtsEngineExtensionObserver
+ : public KeyedService,
+ public extensions::EventRouter::Observer,
+ public extensions::ExtensionRegistryObserver {
+ public:
+ static TtsEngineExtensionObserver* GetInstance(Profile* profile);
+
+ // Returns if this observer saw the given extension load. Adds |extension_id|
+ // as loaded immediately if |update| is set to true.
+ 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
+
+ // Implementation of KeyedService.
+ virtual void Shutdown() OVERRIDE;
+
+ // Implementation of extensions::EventRouter::Observer.
+ virtual void OnListenerAdded(
+ const extensions::EventListenerInfo& details) OVERRIDE;
+
+ // extensions::ExtensionRegistryObserver overrides.
+ virtual void OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionInfo::Reason reason);
+
+ private:
+ explicit TtsEngineExtensionObserver(Profile* profile);
+ virtual ~TtsEngineExtensionObserver() {}
+
+ bool IsLoadedTtsEngine(const std::string& extension_id);
+
+ ScopedObserver<extensions::ExtensionRegistry,
+ extensions::ExtensionRegistryObserver>
+ extension_registry_observer_;
+
+ Profile* profile_;
+
+ bool saw_tts_engine_added_;
+
+ std::set<std::string> engine_extension_ids_;
+
+ friend class TtsEngineExtensionObserverFactory;
+
+ DISALLOW_COPY_AND_ASSIGN(TtsEngineExtensionObserver);
+};
+
+#endif // CHROME_BROWSER_SPEECH_TTS_ENGINE_EXTENSION_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698