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

Side by Side Diff: chrome/browser/speech/chrome_speech_recognition_manager_delegate.h

Issue 10933018: Speech JavaScript API: Use the MediaStreamManager to ask for user permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Satish's comments Created 8 years, 3 months 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 | Annotate | Revision Log
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 CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ 6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/speech/speech_recognition_bubble_controller.h" 10 #include "chrome/browser/speech/speech_recognition_bubble_controller.h"
11 #include "content/public/browser/speech_recognition_event_listener.h" 11 #include "content/public/browser/speech_recognition_event_listener.h"
12 #include "content/public/browser/speech_recognition_manager_delegate.h" 12 #include "content/public/browser/speech_recognition_manager_delegate.h"
13 #include "content/public/browser/speech_recognition_session_config.h" 13 #include "content/public/browser/speech_recognition_session_config.h"
14 14
15 class SpeechRecognitionTrayIconController; 15 class SpeechRecognitionTrayIconController;
16 16
17 namespace speech { 17 namespace speech {
18
18 // This is Chrome's implementation of the SpeechRecognitionManagerDelegate 19 // This is Chrome's implementation of the SpeechRecognitionManagerDelegate
19 // interface. 20 // interface.
20 class ChromeSpeechRecognitionManagerDelegate 21 class ChromeSpeechRecognitionManagerDelegate
21 : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate), 22 : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate),
22 public content::SpeechRecognitionEventListener, 23 public content::SpeechRecognitionEventListener,
23 public SpeechRecognitionBubbleControllerDelegate { 24 public SpeechRecognitionBubbleControllerDelegate {
24 public: 25 public:
25 ChromeSpeechRecognitionManagerDelegate(); 26 ChromeSpeechRecognitionManagerDelegate();
26 virtual ~ChromeSpeechRecognitionManagerDelegate(); 27 virtual ~ChromeSpeechRecognitionManagerDelegate();
27 28
(...skipping 16 matching lines...) Expand all
44 virtual void OnRecognitionError( 45 virtual void OnRecognitionError(
45 int session_id, const content::SpeechRecognitionError& error) OVERRIDE; 46 int session_id, const content::SpeechRecognitionError& error) OVERRIDE;
46 virtual void OnAudioLevelsChange(int session_id, float volume, 47 virtual void OnAudioLevelsChange(int session_id, float volume,
47 float noise_volume) OVERRIDE; 48 float noise_volume) OVERRIDE;
48 49
49 // SpeechRecognitionManagerDelegate methods. 50 // SpeechRecognitionManagerDelegate methods.
50 virtual void GetDiagnosticInformation(bool* can_report_metrics, 51 virtual void GetDiagnosticInformation(bool* can_report_metrics,
51 std::string* hardware_info) OVERRIDE; 52 std::string* hardware_info) OVERRIDE;
52 virtual void CheckRecognitionIsAllowed( 53 virtual void CheckRecognitionIsAllowed(
53 int session_id, 54 int session_id,
54 base::Callback<void(int session_id, bool is_allowed)> callback) OVERRIDE; 55 base::Callback<void(bool ask_user, bool is_allowed)> callback) OVERRIDE;
55 virtual content::SpeechRecognitionEventListener* GetEventListener() OVERRIDE; 56 virtual content::SpeechRecognitionEventListener* GetEventListener() OVERRIDE;
56 57
57 private: 58 private:
58 class OptionalRequestInfo; 59 class OptionalRequestInfo;
59 class TabWatcher; 60 class TabWatcher;
60 61
61 // Shows the recognition tray icon for a given |context_name|, eventually 62 // Shows the recognition tray icon for a given |context_name|, eventually
62 // with a notification balloon. The balloon is shown only once per profile 63 // with a notification balloon. The balloon is shown only once per profile
63 // for a given context_name. |render_process_id| is required to lookup the 64 // for a given context_name. |render_process_id| is required to lookup the
64 // profile associated with the renderer that initiated the recognition. 65 // profile associated with the renderer that initiated the recognition.
65 static void ShowTrayIconOnUIThread( 66 static void ShowTrayIconOnUIThread(
66 const std::string& context_name, 67 const std::string& context_name,
67 int render_process_id, 68 int render_process_id,
68 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller); 69 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller);
69 70
70 // Checks for VIEW_TYPE_TAB_CONTENTS host in the UI thread and notifies back 71 // Checks for VIEW_TYPE_TAB_CONTENTS host in the UI thread and notifies back
71 // the result in the IO thread through |callback|. 72 // the result in the IO thread through |callback|.
72 static void CheckRenderViewType( 73 static void CheckRenderViewType(
73 int session_id, 74 int session_id,
74 base::Callback<void(int session_id, bool is_allowed)> callback, 75 base::Callback<void(bool ask_user, bool is_allowed)> callback,
75 int render_process_id, 76 int render_process_id,
76 int render_view_id); 77 int render_view_id,
78 bool js_api);
77 79
78 // Starts a new recognition session, using the config of the last one 80 // Starts a new recognition session, using the config of the last one
79 // (which is copied into |last_session_config_|). Used for "try again". 81 // (which is copied into |last_session_config_|). Used for "try again".
80 void RestartLastSession(); 82 void RestartLastSession();
81 83
82 // Callback called by |tab_watcher_| on the IO thread to signal tab closure. 84 // Callback called by |tab_watcher_| on the IO thread to signal tab closure.
83 void TabClosedCallback(int render_process_id, int render_view_id); 85 void TabClosedCallback(int render_process_id, int render_view_id);
84 86
85 // Lazy initializers for bubble and tray icon controller. 87 // Lazy initializers for bubble and tray icon controller.
86 SpeechRecognitionBubbleController* GetBubbleController(); 88 SpeechRecognitionBubbleController* GetBubbleController();
87 SpeechRecognitionTrayIconController* GetTrayIconController(); 89 SpeechRecognitionTrayIconController* GetTrayIconController();
88 90
89 scoped_refptr<SpeechRecognitionBubbleController> bubble_controller_; 91 scoped_refptr<SpeechRecognitionBubbleController> bubble_controller_;
90 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller_; 92 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller_;
91 scoped_refptr<OptionalRequestInfo> optional_request_info_; 93 scoped_refptr<OptionalRequestInfo> optional_request_info_;
92 scoped_ptr<content::SpeechRecognitionSessionConfig> last_session_config_; 94 scoped_ptr<content::SpeechRecognitionSessionConfig> last_session_config_;
93 scoped_refptr<TabWatcher> tab_watcher_; 95 scoped_refptr<TabWatcher> tab_watcher_;
94 96
95 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate); 97 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate);
96 }; 98 };
97 99
98 } // namespace speech 100 } // namespace speech
99 101
100 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ 102 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698