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

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

Issue 10663018: Changing tab closure handling logic in speech recognition code and cleaning bubble controller. (Spe… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved TabWatcher as a private class in chrome_speech_recognition_manager_delegate.cc Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/speech/speech_recognition_bubble_controller.h" 11 #include "chrome/browser/speech/speech_recognition_bubble_controller.h"
12 #include "content/public/browser/speech_recognition_event_listener.h" 12 #include "content/public/browser/speech_recognition_event_listener.h"
13 #include "content/public/browser/speech_recognition_manager_delegate.h" 13 #include "content/public/browser/speech_recognition_manager_delegate.h"
14 #include "content/public/browser/speech_recognition_session_config.h" 14 #include "content/public/browser/speech_recognition_session_config.h"
15 15
16 class SpeechRecognitionTrayIconController; 16 class SpeechRecognitionTrayIconController;
17 17
18 namespace speech { 18 namespace speech {
19
20 // This is Chrome's implementation of the SpeechRecognitionManagerDelegate 19 // This is Chrome's implementation of the SpeechRecognitionManagerDelegate
21 // interface. 20 // interface.
22 class ChromeSpeechRecognitionManagerDelegate 21 class ChromeSpeechRecognitionManagerDelegate
23 : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate), 22 : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate),
24 public content::SpeechRecognitionEventListener, 23 public content::SpeechRecognitionEventListener,
25 public SpeechRecognitionBubbleControllerDelegate { 24 public SpeechRecognitionBubbleControllerDelegate {
26 public: 25 public:
27 ChromeSpeechRecognitionManagerDelegate(); 26 ChromeSpeechRecognitionManagerDelegate();
28 virtual ~ChromeSpeechRecognitionManagerDelegate(); 27 virtual ~ChromeSpeechRecognitionManagerDelegate();
29 28
(...skipping 21 matching lines...) Expand all
51 // SpeechRecognitionManagerDelegate methods. 50 // SpeechRecognitionManagerDelegate methods.
52 virtual void GetDiagnosticInformation(bool* can_report_metrics, 51 virtual void GetDiagnosticInformation(bool* can_report_metrics,
53 std::string* hardware_info) OVERRIDE; 52 std::string* hardware_info) OVERRIDE;
54 virtual void CheckRecognitionIsAllowed( 53 virtual void CheckRecognitionIsAllowed(
55 int session_id, 54 int session_id,
56 base::Callback<void(int session_id, bool is_allowed)> callback) OVERRIDE; 55 base::Callback<void(int session_id, bool is_allowed)> callback) OVERRIDE;
57 virtual content::SpeechRecognitionEventListener* GetEventListener() OVERRIDE; 56 virtual content::SpeechRecognitionEventListener* GetEventListener() OVERRIDE;
58 57
59 private: 58 private:
60 class OptionalRequestInfo; 59 class OptionalRequestInfo;
60 class TabWatcher;
61 61
62 // Shows the recognition tray icon for a given |context_name|, eventually 62 // Shows the recognition tray icon for a given |context_name|, eventually
63 // 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
64 // 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
65 // profile associated with the renderer that initiated the recognition. 65 // profile associated with the renderer that initiated the recognition.
66 static void ShowTrayIconOnUIThread( 66 static void ShowTrayIconOnUIThread(
67 const std::string& context_name, 67 const std::string& context_name,
68 int render_process_id, 68 int render_process_id,
69 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller); 69 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller);
70 70
71 // 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
72 // the result in the IO thread through |callback|. 72 // the result in the IO thread through |callback|.
73 static void CheckRenderViewType( 73 static void CheckRenderViewType(
74 int session_id, 74 int session_id,
75 base::Callback<void(int session_id, bool is_allowed)> callback, 75 base::Callback<void(int session_id, bool is_allowed)> callback,
76 int render_process_id, 76 int render_process_id,
77 int render_view_id); 77 int render_view_id);
78 78
79 // Starts a new recognition session, using the config of the last one 79 // Starts a new recognition session, using the config of the last one
80 // (which is copied into |last_session_config_|). Used for "try again". 80 // (which is copied into |last_session_config_|). Used for "try again".
81 void RestartLastSession(); 81 void RestartLastSession();
82 82
83 // Callback called by |tab_watcher_| on the IO thread to signal tab closure.
84 void TabClosedCallback(int render_process_id, int render_view_id);
85
83 // Lazy initializers for bubble and tray icon controller. 86 // Lazy initializers for bubble and tray icon controller.
84 SpeechRecognitionBubbleController* GetBubbleController(); 87 SpeechRecognitionBubbleController* GetBubbleController();
85 SpeechRecognitionTrayIconController* GetTrayIconController(); 88 SpeechRecognitionTrayIconController* GetTrayIconController();
86 89
87 scoped_refptr<SpeechRecognitionBubbleController> bubble_controller_; 90 scoped_refptr<SpeechRecognitionBubbleController> bubble_controller_;
88 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller_; 91 scoped_refptr<SpeechRecognitionTrayIconController> tray_icon_controller_;
89 scoped_refptr<OptionalRequestInfo> optional_request_info_; 92 scoped_refptr<OptionalRequestInfo> optional_request_info_;
90 scoped_ptr<content::SpeechRecognitionSessionConfig> last_session_config_; 93 scoped_ptr<content::SpeechRecognitionSessionConfig> last_session_config_;
91 94 scoped_refptr<TabWatcher> tab_watcher_;
92 // TODO(primiano) this information should be kept into the bubble_controller_.
93 int active_bubble_session_id_;
94 95
95 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate); 96 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate);
96 }; 97 };
97 98
98 } // namespace speech 99 } // namespace speech
99 100
100 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ 101 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/speech/chrome_speech_recognition_manager_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698