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

Unified Diff: chrome/browser/ui/webui/app_list/start_page_handler.cc

Issue 105773004: Introduces the speech recognition UI to app_list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/app_list/start_page_handler.h ('k') | ui/app_list/app_list.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/app_list/start_page_handler.cc
diff --git a/chrome/browser/ui/webui/app_list/start_page_handler.cc b/chrome/browser/ui/webui/app_list/start_page_handler.cc
index eb0b89cd63d980598c5defb066b85422db2f5319..c93dab21c51e98841359d841ff8384d02523d7a0 100644
--- a/chrome/browser/ui/webui/app_list/start_page_handler.cc
+++ b/chrome/browser/ui/webui/app_list/start_page_handler.cc
@@ -22,6 +22,7 @@
#include "content/public/browser/web_contents_view.h"
#include "content/public/browser/web_ui.h"
#include "extensions/common/extension.h"
+#include "ui/app_list/speech_ui_model_observer.h"
#include "ui/events/event_constants.h"
namespace app_list {
@@ -65,8 +66,13 @@ void StartPageHandler::RegisterMessages() {
"launchApp",
base::Bind(&StartPageHandler::HandleLaunchApp, base::Unretained(this)));
web_ui()->RegisterMessageCallback(
- "search",
- base::Bind(&StartPageHandler::HandleSearch, base::Unretained(this)));
+ "speechResult",
+ base::Bind(&StartPageHandler::HandleSpeechResult,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "speechSoundLevel",
+ base::Bind(&StartPageHandler::HandleSpeechSoundLevel,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"setSpeechRecognitionState",
base::Bind(&StartPageHandler::HandleSpeechRecognition,
@@ -124,20 +130,38 @@ void StartPageHandler::HandleLaunchApp(const base::ListValue* args) {
ui::EF_NONE);
}
-void StartPageHandler::HandleSearch(const base::ListValue* args) {
+void StartPageHandler::HandleSpeechResult(const base::ListValue* args) {
base::string16 query;
+ bool is_final = false;
CHECK(args->GetString(0, &query));
+ CHECK(args->GetBoolean(1, &is_final));
- StartPageService::Get(Profile::FromWebUI(web_ui()))->OnSearch(query);
+ StartPageService::Get(Profile::FromWebUI(web_ui()))->OnSpeechResult(
+ query, is_final);
+}
+
+void StartPageHandler::HandleSpeechSoundLevel(const base::ListValue* args) {
+ double level;
+ CHECK(args->GetDouble(0, &level));
+
+ StartPageService* service =
+ StartPageService::Get(Profile::FromWebUI(web_ui()));
+ service->OnSpeechSoundLevelChanged(static_cast<int16>(level));
}
void StartPageHandler::HandleSpeechRecognition(const base::ListValue* args) {
- bool recognizing;
- CHECK(args->GetBoolean(0, &recognizing));
+ std::string state_string;
+ CHECK(args->GetString(0, &state_string));
+
+ SpeechRecognitionState new_state = SPEECH_RECOGNITION_NOT_STARTED;
+ if (state_string == "on")
+ new_state = SPEECH_RECOGNITION_ON;
+ else if (state_string == "in-speech")
+ new_state = SPEECH_RECOGNITION_IN_SPEECH;
StartPageService* service =
StartPageService::Get(Profile::FromWebUI(web_ui()));
- service->OnSpeechRecognitionStateChanged(recognizing);
+ service->OnSpeechRecognitionStateChanged(new_state);
}
} // namespace app_list
« no previous file with comments | « chrome/browser/ui/webui/app_list/start_page_handler.h ('k') | ui/app_list/app_list.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698