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

Unified Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 151903007: Introduces UMA for app-list voice search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.h ('k') | tools/metrics/actions/chromeactions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/start_page_service.cc
diff --git a/chrome/browser/ui/app_list/start_page_service.cc b/chrome/browser/ui/app_list/start_page_service.cc
index 6c897bf5f6c73bf7d2df6b63eefa888ce76a981c..721699b3e3a66602dead099171263342ec88f144 100644
--- a/chrome/browser/ui/app_list/start_page_service.cc
+++ b/chrome/browser/ui/app_list/start_page_service.cc
@@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/memory/singleton.h"
+#include "base/metrics/user_metrics.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/media/media_stream_infobar_delegate.h"
#include "chrome/browser/profiles/profile.h"
@@ -26,8 +27,20 @@
#include "extensions/common/extension.h"
#include "ui/app_list/app_list_switches.h"
+using base::RecordAction;
+using base::UserMetricsAction;
+
namespace app_list {
+namespace {
+
+bool InSpeechRecognition(SpeechRecognitionState state) {
+ return state == SPEECH_RECOGNITION_RECOGNIZING ||
+ state == SPEECH_RECOGNITION_IN_SPEECH;
+}
+
+}
+
class StartPageService::ProfileDestroyObserver
: public content::NotificationObserver {
public:
@@ -82,7 +95,9 @@ StartPageService::StartPageService(Profile* profile)
: profile_(profile),
profile_destroy_observer_(new ProfileDestroyObserver(this)),
recommended_apps_(new RecommendedApps(profile)),
- state_(app_list::SPEECH_RECOGNITION_OFF) {
+ state_(app_list::SPEECH_RECOGNITION_OFF),
+ speech_button_toggled_manually_(false),
+ speech_result_obtained_(false) {
#if defined(OS_CHROMEOS)
// Updates the default state to hotword listening, because this is
// the default behavior. This will be updated when the page is loaded and
@@ -121,6 +136,7 @@ void StartPageService::RemoveObserver(StartPageObserver* observer) {
}
void StartPageService::ToggleSpeechRecognition() {
+ speech_button_toggled_manually_ = true;
contents_->GetWebUI()->CallJavascriptFunction(
"appList.startPage.toggleSpeechRecognition");
}
@@ -136,6 +152,10 @@ content::WebContents* StartPageService::GetSpeechRecognitionContents() {
void StartPageService::OnSpeechResult(
const base::string16& query, bool is_final) {
+ if (is_final) {
+ speech_result_obtained_ = true;
+ RecordAction(UserMetricsAction("AppList_SearchedBySpeech"));
+ }
FOR_EACH_OBSERVER(StartPageObserver,
observers_,
OnSpeechResult(query, is_final));
@@ -149,6 +169,19 @@ void StartPageService::OnSpeechSoundLevelChanged(int16 level) {
void StartPageService::OnSpeechRecognitionStateChanged(
SpeechRecognitionState new_state) {
+ if (!InSpeechRecognition(state_) && InSpeechRecognition(new_state)) {
+ if (!speech_button_toggled_manually_ &&
+ state_ == SPEECH_RECOGNITION_HOTWORD_LISTENING) {
+ RecordAction(UserMetricsAction("AppList_HotwordRecognized"));
+ } else {
+ RecordAction(UserMetricsAction("AppList_VoiceSearchStartedManually"));
+ }
+ } else if (InSpeechRecognition(state_) && !InSpeechRecognition(new_state) &&
+ !speech_result_obtained_) {
+ RecordAction(UserMetricsAction("AppList_VoiceSearchCanceled"));
+ }
+ speech_button_toggled_manually_ = false;
+ speech_result_obtained_ = false;
state_ = new_state;
FOR_EACH_OBSERVER(StartPageObserver,
observers_,
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.h ('k') | tools/metrics/actions/chromeactions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698