OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_SPEECH_SYNTHESIS_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_SPEECH_SYNTHESIS_LOADER_H_ |
| 7 |
| 8 #include "base/containers/hash_tables.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/prefs/pref_change_registrar.h" |
| 11 #include "chrome/browser/extensions/external_loader.h" |
| 12 #include "chrome/browser/profiles/profile.h" |
| 13 |
| 14 namespace user_prefs { |
| 15 class PrefRegistrySyncable; |
| 16 } |
| 17 |
| 18 class PrefChanceRegistrar; |
| 19 |
| 20 namespace chromeos { |
| 21 |
| 22 // Chrome OS comes with medium-quality speech synthesis extensions built-in. |
| 23 // When the user speaks a certain threshold of utterances in the same session, |
| 24 // we set a preference indicating that high quality speech is enabled for that |
| 25 // language. This class is the external extension loader that checks the |
| 26 // preference and prepares the list of external extensions to be installed |
| 27 // from the web store automatically. The high-quality speech synthesis |
| 28 // extensions are installed silently as component extensions. |
| 29 class SpeechSynthesisLoader |
| 30 : public extensions::ExternalLoader, |
| 31 public base::SupportsWeakPtr<SpeechSynthesisLoader> { |
| 32 public: |
| 33 explicit SpeechSynthesisLoader(Profile* profile); |
| 34 virtual ~SpeechSynthesisLoader(); |
| 35 |
| 36 // Implementation of extensions::ExternalLoader: |
| 37 virtual void StartLoading() OVERRIDE; |
| 38 |
| 39 // Register speech synthesis prefs for a profile. |
| 40 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 41 |
| 42 private: |
| 43 // The profile that this loader is associated with. It listens for |
| 44 // preference changes for that profile. |
| 45 Profile* profile_; |
| 46 |
| 47 // The pref change registrar, so we can watch for pref changes. |
| 48 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 49 |
| 50 // A weak ptr factory, so we can safely bind pref change registrar |
| 51 // callbacks to this class. |
| 52 base::WeakPtrFactory<SpeechSynthesisLoader> weak_ptr_factory_; |
| 53 |
| 54 // A map from language code to the extension id of the high-quality |
| 55 // extension for that language in the web store, if any. |
| 56 base::hash_map<std::string, std::string> lang_to_extension_id_map_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(SpeechSynthesisLoader); |
| 59 }; |
| 60 |
| 61 } // namespace chromeos |
| 62 |
| 63 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_SPEECH_SYNTHESIS_LOADER_H_ |
OLD | NEW |