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

Side by Side Diff: content/public/browser/speech_recognition_manager.h

Issue 636863003: Make SpeechRecognition per RenderFrame instead of per RenderView. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanups Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_
6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/public/common/speech_recognition_result.h" 11 #include "content/public/common/speech_recognition_result.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class RenderFrameHost;
15 class SpeechRecognitionEventListener; 16 class SpeechRecognitionEventListener;
16 struct SpeechRecognitionSessionConfig; 17 struct SpeechRecognitionSessionConfig;
17 struct SpeechRecognitionSessionContext; 18 struct SpeechRecognitionSessionContext;
18 19
19 // The SpeechRecognitionManager (SRM) is a singleton class that handles SR 20 // The SpeechRecognitionManager (SRM) is a singleton class that handles SR
20 // functionalities within Chrome. Everyone that needs to perform SR should 21 // functionalities within Chrome. Everyone that needs to perform SR should
21 // interface exclusively with the SRM, receiving events through the callback 22 // interface exclusively with the SRM, receiving events through the callback
22 // interface SpeechRecognitionEventListener. 23 // interface SpeechRecognitionEventListener.
23 // Since many different sources can use SR in different times (some overlapping 24 // Since many different sources can use SR in different times (some overlapping
24 // is allowed while waiting for results), the SRM has the further responsibility 25 // is allowed while waiting for results), the SRM has the further responsibility
(...skipping 16 matching lines...) Expand all
41 // Creates a new recognition session. 42 // Creates a new recognition session.
42 virtual int CreateSession(const SpeechRecognitionSessionConfig& config) = 0; 43 virtual int CreateSession(const SpeechRecognitionSessionConfig& config) = 0;
43 44
44 // Starts/restarts recognition for an existing session, after performing a 45 // Starts/restarts recognition for an existing session, after performing a
45 // premilinary check on the delegate (CheckRecognitionIsAllowed). 46 // premilinary check on the delegate (CheckRecognitionIsAllowed).
46 virtual void StartSession(int session_id) = 0; 47 virtual void StartSession(int session_id) = 0;
47 48
48 // Aborts recognition for an existing session, without providing any result. 49 // Aborts recognition for an existing session, without providing any result.
49 virtual void AbortSession(int session_id) = 0; 50 virtual void AbortSession(int session_id) = 0;
50 51
51 // Aborts all sessions for a given render process, 52 // Aborts all sessions for a given RenderFrame, without providing any result.
52 // without providing any result. 53 virtual void AbortAllSessionsForRenderFrame(
53 virtual void AbortAllSessionsForRenderProcess(int render_process_id) = 0; 54 RenderFrameHost* render_frame_host) = 0;
54
55 // Aborts all sessions for a given RenderView, without providing any result.
56 virtual void AbortAllSessionsForRenderView(int render_process_id,
57 int render_view_id) = 0;
58 55
59 // Stops audio capture for an existing session. The audio captured before the 56 // Stops audio capture for an existing session. The audio captured before the
60 // call will be processed, possibly ending up with a result. 57 // call will be processed, possibly ending up with a result.
61 virtual void StopAudioCaptureForSession(int session_id) = 0; 58 virtual void StopAudioCaptureForSession(int session_id) = 0;
62 59
63 // Retrieves the configuration of a session, as provided by the caller 60 // Retrieves the configuration of a session, as provided by the caller
64 // upon CreateSession. 61 // upon CreateSession.
65 virtual const SpeechRecognitionSessionConfig& GetSessionConfig(int session_id) 62 virtual const SpeechRecognitionSessionConfig& GetSessionConfig(int session_id)
66 const = 0; 63 const = 0;
67 64
68 // Retrieves the context associated to a session. 65 // Retrieves the context associated to a session.
69 virtual SpeechRecognitionSessionContext GetSessionContext( 66 virtual SpeechRecognitionSessionContext GetSessionContext(
70 int session_id) const = 0; 67 int session_id) const = 0;
71 68
72 // Looks-up an existing session from the context tuple 69 // Looks-up an existing session from the context tuple
73 // {render_view_id, render_view_id, request_id}. 70 // {render_frame_host, request_id}.
74 virtual int GetSession(int render_process_id, 71 virtual int GetSession(RenderFrameHost* render_frame_host,
75 int render_view_id,
76 int request_id) const = 0; 72 int request_id) const = 0;
77 73
78 // Returns true if the OS reports existence of audio recording devices. 74 // Returns true if the OS reports existence of audio recording devices.
79 virtual bool HasAudioInputDevices() = 0; 75 virtual bool HasAudioInputDevices() = 0;
80 76
81 // Returns a human readable string for the model/make of the active audio 77 // Returns a human readable string for the model/make of the active audio
82 // input device for this computer. 78 // input device for this computer.
83 virtual base::string16 GetAudioInputDeviceModel() = 0; 79 virtual base::string16 GetAudioInputDeviceModel() = 0;
84 80
85 // Invokes the platform provided microphone settings UI in a non-blocking way, 81 // Invokes the platform provided microphone settings UI in a non-blocking way,
86 // via the BrowserThread::FILE thread. 82 // via the BrowserThread::FILE thread.
87 virtual void ShowAudioInputSettings() = 0; 83 virtual void ShowAudioInputSettings() = 0;
88 84
89 protected: 85 protected:
90 virtual ~SpeechRecognitionManager() {} 86 virtual ~SpeechRecognitionManager() {}
91 87
92 private: 88 private:
93 static SpeechRecognitionManager* manager_for_tests_; 89 static SpeechRecognitionManager* manager_for_tests_;
94 }; 90 };
95 91
96 } // namespace content 92 } // namespace content
97 93
98 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ 94 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698