summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 19:03:34 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-17 19:03:34 +0000
commit4e8d5c8ada6452b59975f9da496d7c8b4858763e (patch)
tree65d033d479612af90e2eb487dd6442096f71cfeb
parentac8590d09c85a19107294e1d5d3b554bd9005132 (diff)
downloadchromium_src-4e8d5c8ada6452b59975f9da496d7c8b4858763e.zip
chromium_src-4e8d5c8ada6452b59975f9da496d7c8b4858763e.tar.gz
chromium_src-4e8d5c8ada6452b59975f9da496d7c8b4858763e.tar.bz2
Extract SpeechInputManager delegate into its own header and put it in the content namespace.
BUG=98716 R=jam@chromium.org Review URL: https://chromiumcodereview.appspot.com/9413017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122546 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/speech/speech_input_browsertest.cc18
-rw-r--r--content/browser/speech/speech_input_dispatcher_host.cc1
-rw-r--r--content/browser/speech/speech_input_dispatcher_host.h7
-rw-r--r--content/browser/speech/speech_input_manager.cc6
-rw-r--r--content/browser/speech/speech_input_manager.h31
-rw-r--r--content/browser/speech/speech_input_manager_delegate.h29
-rw-r--r--content/content_browser.gypi1
7 files changed, 59 insertions, 34 deletions
diff --git a/content/browser/speech/speech_input_browsertest.cc b/content/browser/speech/speech_input_browsertest.cc
index b7f24a0..872d2cd 100644
--- a/content/browser/speech/speech_input_browsertest.cc
+++ b/content/browser/speech/speech_input_browsertest.cc
@@ -29,7 +29,7 @@ class FakeSpeechInputManager;
namespace speech_input {
-const char* kTestResult = "Pictures of the moon";
+const char kTestResult[] = "Pictures of the moon";
class FakeSpeechInputManager : public SpeechInputManager {
public:
@@ -62,9 +62,14 @@ class FakeSpeechInputManager : public SpeechInputManager {
}
// SpeechInputManager methods.
- virtual void StartRecognition(Delegate* delegate, int caller_id,
- int render_process_id, int render_view_id, const gfx::Rect& element_rect,
- const std::string& language, const std::string& grammar,
+ virtual void StartRecognition(
+ content::SpeechInputManagerDelegate* delegate,
+ int caller_id,
+ int render_process_id,
+ int render_view_id,
+ const gfx::Rect& element_rect,
+ const std::string& language,
+ const std::string& grammar,
const std::string& origin_url,
net::URLRequestContextGetter* context_getter,
content::SpeechInputPreferences* speech_input_prefs,
@@ -99,7 +104,8 @@ class FakeSpeechInputManager : public SpeechInputManager {
EXPECT_EQ(caller_id_, caller_id);
// Nothing to do here since we aren't really recording.
}
- virtual void CancelAllRequestsWithDelegate(Delegate* delegate) OVERRIDE {
+ virtual void CancelAllRequestsWithDelegate(
+ content::SpeechInputManagerDelegate* delegate) OVERRIDE {
VLOG(1) << "CancelAllRequestsWithDelegate invoked.";
// delegate_ is set to NULL if a fake result was received (see below), so
// check that delegate_ matches the incoming parameter only when there is
@@ -142,7 +148,7 @@ class FakeSpeechInputManager : public SpeechInputManager {
}
int caller_id_;
- Delegate* delegate_;
+ content::SpeechInputManagerDelegate* delegate_;
std::string grammar_;
bool did_cancel_all_;
bool should_send_fake_response_;
diff --git a/content/browser/speech/speech_input_dispatcher_host.cc b/content/browser/speech/speech_input_dispatcher_host.cc
index 7ad7798..3511123 100644
--- a/content/browser/speech/speech_input_dispatcher_host.cc
+++ b/content/browser/speech/speech_input_dispatcher_host.cc
@@ -5,6 +5,7 @@
#include "content/browser/speech/speech_input_dispatcher_host.h"
#include "base/lazy_instance.h"
+#include "content/browser/speech/speech_input_manager.h"
#include "content/browser/speech/speech_recognizer.h"
#include "content/common/speech_input_messages.h"
#include "content/public/browser/content_browser_client.h"
diff --git a/content/browser/speech/speech_input_dispatcher_host.h b/content/browser/speech/speech_input_dispatcher_host.h
index 391d94e..a955c83 100644
--- a/content/browser/speech/speech_input_dispatcher_host.h
+++ b/content/browser/speech/speech_input_dispatcher_host.h
@@ -6,7 +6,7 @@
#define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_
#include "base/memory/scoped_ptr.h"
-#include "content/browser/speech/speech_input_manager.h"
+#include "content/browser/speech/speech_input_manager_delegate.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_message_filter.h"
#include "net/url_request/url_request_context_getter.h"
@@ -15,15 +15,18 @@ struct SpeechInputHostMsg_StartRecognition_Params;
namespace content {
class ResourceContext;
+class SpeechInputPreferences;
}
namespace speech_input {
+class SpeechInputManager;
+
// SpeechInputDispatcherHost is a delegate for Speech API messages used by
// RenderMessageFilter.
// It's the complement of SpeechInputDispatcher (owned by RenderView).
class SpeechInputDispatcherHost : public content::BrowserMessageFilter,
- public SpeechInputManager::Delegate {
+ public content::SpeechInputManagerDelegate {
public:
class SpeechInputCallers;
diff --git a/content/browser/speech/speech_input_manager.cc b/content/browser/speech/speech_input_manager.cc
index b30abed..b8e8f98 100644
--- a/content/browser/speech/speech_input_manager.cc
+++ b/content/browser/speech/speech_input_manager.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/speech/speech_input_manager_delegate.h"
#include "content/browser/speech/speech_recognizer.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host_delegate.h"
@@ -15,11 +16,12 @@
#include "media/audio/audio_manager.h"
using content::BrowserThread;
+using content::SpeechInputManagerDelegate;
namespace speech_input {
struct SpeechInputManager::SpeechInputParams {
- SpeechInputParams(Delegate* delegate,
+ SpeechInputParams(SpeechInputManagerDelegate* delegate,
int caller_id,
int render_process_id,
int render_view_id,
@@ -43,7 +45,7 @@ struct SpeechInputManager::SpeechInputParams {
audio_manager_(audio_manager) {
}
- Delegate* delegate;
+ SpeechInputManagerDelegate* delegate;
int caller_id;
int render_process_id;
int render_view_id;
diff --git a/content/browser/speech/speech_input_manager.h b/content/browser/speech/speech_input_manager.h
index 45cc71f..b5976f3 100644
--- a/content/browser/speech/speech_input_manager.h
+++ b/content/browser/speech/speech_input_manager.h
@@ -11,8 +11,8 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
-#include "content/public/browser/speech_recognizer_delegate.h"
#include "content/common/content_export.h"
+#include "content/public/browser/speech_recognizer_delegate.h"
#include "ui/gfx/rect.h"
class AudioManager;
@@ -20,6 +20,7 @@ class AudioManager;
namespace content {
class ResourceContext;
class SpeechInputPreferences;
+class SpeechInputManagerDelegate;
struct SpeechInputResult;
}
@@ -38,19 +39,6 @@ class SpeechRecognizer;
class CONTENT_EXPORT SpeechInputManager
: public NON_EXPORTED_BASE(content::SpeechRecognizerDelegate) {
public:
- // Implemented by the dispatcher host to relay events to the render views.
- class Delegate {
- public:
- virtual void SetRecognitionResult(
- int caller_id,
- const content::SpeechInputResult& result) = 0;
- virtual void DidCompleteRecording(int caller_id) = 0;
- virtual void DidCompleteRecognition(int caller_id) = 0;
-
- protected:
- virtual ~Delegate() {}
- };
-
// Describes the microphone errors that are reported via ShowMicError.
enum MicError {
kNoDeviceAvailable = 0,
@@ -80,7 +68,7 @@ class CONTENT_EXPORT SpeechInputManager
// |element_rect| is the display bounds of the html element requesting speech
// input (in page coordinates).
virtual void StartRecognition(
- Delegate* delegate,
+ content::SpeechInputManagerDelegate* delegate,
int caller_id,
int render_process_id,
int render_view_id,
@@ -92,7 +80,8 @@ class CONTENT_EXPORT SpeechInputManager
content::SpeechInputPreferences* speech_input_prefs,
AudioManager* audio_manager);
virtual void CancelRecognition(int caller_id);
- virtual void CancelAllRequestsWithDelegate(Delegate* delegate);
+ virtual void CancelAllRequestsWithDelegate(
+ content::SpeechInputManagerDelegate* delegate);
virtual void StopRecording(int caller_id);
// Overridden from content::SpeechRecognizerDelegate:
@@ -166,14 +155,14 @@ class CONTENT_EXPORT SpeechInputManager
SpeechInputRequest();
~SpeechInputRequest();
- Delegate* delegate;
+ content::SpeechInputManagerDelegate* delegate;
scoped_refptr<SpeechRecognizer> recognizer;
bool is_active; // Set to true when recording or recognition is going on.
};
struct SpeechInputParams;
- Delegate* GetDelegate(int caller_id) const;
+ content::SpeechInputManagerDelegate* GetDelegate(int caller_id) const;
void CheckRenderViewTypeAndStartRecognition(const SpeechInputParams& params);
void ProceedStartingRecognition(const SpeechInputParams& params);
@@ -185,12 +174,6 @@ class CONTENT_EXPORT SpeechInputManager
int recording_caller_id_;
};
-// This typedef is to workaround the issue with certain versions of
-// Visual Studio where it gets confused between multiple Delegate
-// classes and gives a C2500 error. (I saw this error on the try bots -
-// the workaround was not needed for my machine).
-typedef SpeechInputManager::Delegate SpeechInputManagerDelegate;
-
} // namespace speech_input
#endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
diff --git a/content/browser/speech/speech_input_manager_delegate.h b/content/browser/speech/speech_input_manager_delegate.h
new file mode 100644
index 0000000..5d0ac18
--- /dev/null
+++ b/content/browser/speech/speech_input_manager_delegate.h
@@ -0,0 +1,29 @@
+// 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 CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_DELEGATE_H_
+#define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_DELEGATE_H_
+#pragma once
+
+namespace content {
+
+struct SpeechInputResult;
+
+// Implemented by the dispatcher host to relay events to the render views.
+class SpeechInputManagerDelegate {
+ public:
+ virtual void SetRecognitionResult(int caller_id,
+ const SpeechInputResult& result) = 0;
+
+ virtual void DidCompleteRecording(int caller_id) = 0;
+
+ virtual void DidCompleteRecognition(int caller_id) = 0;
+
+ protected:
+ virtual ~SpeechInputManagerDelegate() {}
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_DELEGATE_H_
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 55c7f13..c1b81a50 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -598,6 +598,7 @@
'browser/speech/speech_input_dispatcher_host.h',
'browser/speech/speech_input_manager.cc',
'browser/speech/speech_input_manager.h',
+ 'browser/speech/speech_input_manager_delegate.h',
'browser/speech/speech_recognition_request.cc',
'browser/speech/speech_recognition_request.h',
'browser/speech/speech_recognizer.cc',