Home | History | Annotate | Download | only in speech
      1 // Copyright (c) 2012 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_EXTENSION_LOADER_CHROMEOS_H_
      6 #define CHROME_BROWSER_SPEECH_TTS_EXTENSION_LOADER_CHROMEOS_H_
      7 
      8 #include "chrome/browser/extensions/event_router.h"
      9 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
     10 
     11 // Profile-keyed class that loads a built-in TTS component extension
     12 // into a given profile on Chrome OS.
     13 class TtsExtensionLoaderChromeOs
     14     : public BrowserContextKeyedService,
     15       public extensions::EventRouter::Observer {
     16  public:
     17   static TtsExtensionLoaderChromeOs* GetInstance(Profile* profile);
     18 
     19   // Returns true if the extension was not previously loaded and is now
     20   // loading. This class will call
     21   // ExtensionTtsController::RetrySpeakingQueuedUtterances when the
     22   // extension finishes loading.
     23   bool LoadTtsExtension();
     24 
     25   // Implementation of extensions::EventRouter::Observer.
     26   virtual void OnListenerAdded(const extensions::EventListenerInfo& details)
     27       OVERRIDE;
     28 
     29  private:
     30   // The state of TTS for this profile.
     31   enum TtsState {
     32     TTS_NOT_LOADED,
     33     TTS_LOAD_REQUESTED,
     34     TTS_LOADING,
     35     TTS_LOADED
     36   };
     37 
     38   explicit TtsExtensionLoaderChromeOs(Profile* profile);
     39   virtual ~TtsExtensionLoaderChromeOs() {}
     40 
     41   bool IsTtsLoadedInThisProfile();
     42 
     43   Profile* profile_;
     44   TtsState tts_state_;
     45 
     46   friend class TtsExtensionLoaderChromeOsFactory;
     47 
     48   DISALLOW_COPY_AND_ASSIGN(TtsExtensionLoaderChromeOs);
     49 };
     50 
     51 #endif  // CHROME_BROWSER_SPEECH_TTS_EXTENSION_LOADER_CHROMEOS_H_
     52