629745cd4802242ab91374e4b64318fc663b1d3e
[platform/framework/web/crosswalk.git] / src / chrome / browser / speech / tts_message_filter.h
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_SPEECH_TTS_MESSAGE_FILTER_H_
6 #define CHROME_BROWSER_SPEECH_TTS_MESSAGE_FILTER_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/speech/tts_controller.h"
10 #include "chrome/common/tts_messages.h"
11 #include "content/public/browser/browser_message_filter.h"
12
13 class Profile;
14
15 class TtsMessageFilter
16     : public content::BrowserMessageFilter,
17       public UtteranceEventDelegate,
18       public VoicesChangedDelegate,
19       public base::SupportsWeakPtr<TtsMessageFilter> {
20  public:
21   TtsMessageFilter(int render_process_id, Profile* profile);
22
23   // content::BrowserMessageFilter implementation.
24   virtual void OverrideThreadForMessage(
25       const IPC::Message& message,
26       content::BrowserThread::ID* thread) OVERRIDE;
27   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
28   virtual void OnChannelClosing() OVERRIDE;
29
30   // UtteranceEventDelegate implementation.
31   virtual void OnTtsEvent(Utterance* utterance,
32                           TtsEventType event_type,
33                           int char_index,
34                           const std::string& error_message) OVERRIDE;
35
36   // VoicesChangedDelegate implementation.
37   virtual void OnVoicesChanged() OVERRIDE;
38
39  private:
40   virtual ~TtsMessageFilter();
41
42   void OnInitializeVoiceList();
43   void OnSpeak(const TtsUtteranceRequest& utterance);
44   void OnPause();
45   void OnResume();
46   void OnCancel();
47
48   void OnChannelClosingInUIThread();
49
50   int render_process_id_;
51   Profile* profile_;
52
53   DISALLOW_COPY_AND_ASSIGN(TtsMessageFilter);
54 };
55
56 #endif  // CHROME_BROWSER_SPEECH_TTS_MESSAGE_FILTER_H_