summaryrefslogtreecommitdiffstats
path: root/chrome/browser/speech/tts_extension_loader_chromeos.h
blob: b989de4531803d87d752ce43a3245182e3c43192 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2012 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_EXTENSION_LOADER_CHROMEOS_H_
#define CHROME_BROWSER_SPEECH_TTS_EXTENSION_LOADER_CHROMEOS_H_

#include "chrome/browser/extensions/event_router.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"

// Profile-keyed class that loads a built-in TTS component extension
// into a given profile on Chrome OS.
class TtsExtensionLoaderChromeOs
    : public ProfileKeyedService,
      public extensions::EventRouter::Observer {
 public:
  static TtsExtensionLoaderChromeOs* GetInstance(Profile* profile);

  // Returns true if the extension was not previously loaded and is now
  // loading. This class will call
  // ExtensionTtsController::RetrySpeakingQueuedUtterances when the
  // extension finishes loading.
  bool LoadTtsExtension();

  // Implementation of extensions::EventRouter::Observer.
  virtual void OnListenerAdded(const extensions::EventListenerInfo& details)
      OVERRIDE;

 private:
  // The state of TTS for this profile.
  enum TtsState {
    TTS_NOT_LOADED,
    TTS_LOAD_REQUESTED,
    TTS_LOADING,
    TTS_LOADED
  };

  explicit TtsExtensionLoaderChromeOs(Profile* profile);
  virtual ~TtsExtensionLoaderChromeOs() {}

  bool IsTtsLoadedInThisProfile();

  Profile* profile_;
  TtsState tts_state_;

  friend class TtsExtensionLoaderChromeOsFactory;

  DISALLOW_COPY_AND_ASSIGN(TtsExtensionLoaderChromeOs);
};

#endif  // CHROME_BROWSER_SPEECH_TTS_EXTENSION_LOADER_CHROMEOS_H_