#include "base/callback.h"
#include "base/files/file_path.h"
+#include "base/metrics/user_metrics.h"
#include "base/stl_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/user_metrics.h"
+#include "grit/theme_resources.h"
#include "ui/app_list/app_list_view_delegate_observer.h"
#include "ui/app_list/search_box_model.h"
#include "ui/app_list/speech_ui_model.h"
+#include "ui/base/resource/resource_bundle.h"
#if defined(USE_ASH)
#include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h"
namespace {
-const int kAutoLaunchDefaultTimeoutSec = 3;
+const int kAutoLaunchDefaultTimeoutMilliSec = 50;
#if defined(OS_WIN)
void CreateShortcutInWebAppDir(
CHECK(controller_);
RegisterForNotifications();
g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
- OnProfileChanged(); // sets model_
+
app_list::StartPageService* service =
app_list::StartPageService::Get(profile_);
+ speech_ui_.reset(new app_list::SpeechUIModel(
+ service ? service->state() : app_list::SPEECH_RECOGNITION_OFF));
+
+#if defined(GOOGLE_CHROME_BUILD)
+ speech_ui_->set_logo(
+ *ui::ResourceBundle::GetSharedInstance().
+ GetImageSkiaNamed(IDR_APP_LIST_GOOGLE_LOGO_VOICE_SEARCH));
+#endif
+
+ OnProfileChanged(); // sets model_
if (service)
service->AddObserver(this);
}
service->RemoveObserver(this);
g_browser_process->
profile_manager()->GetProfileInfoCache().RemoveObserver(this);
+ // Ensure search controller is released prior to speech_ui_.
+ search_controller_.reset();
}
void AppListViewDelegate::RegisterForNotifications() {
profile_)->model();
search_controller_.reset(new app_list::SearchController(
- profile_, model_->search_box(), model_->results(), controller_));
+ profile_, model_->search_box(), model_->results(),
+ speech_ui_.get(), controller_));
signin_delegate_.SetProfile(profile_);
}
app_list::SpeechUIModel* AppListViewDelegate::GetSpeechUI() {
- return &speech_ui_;
+ return speech_ui_.get();
}
void AppListViewDelegate::GetShortcutPathForApp(
void AppListViewDelegate::OpenSearchResult(
app_list::SearchResult* result,
+ bool auto_launch,
int event_flags) {
+ if (auto_launch)
+ base::RecordAction(base::UserMetricsAction("AppList_AutoLaunched"));
search_controller_->OpenResult(result, event_flags);
}
}
void AppListViewDelegate::AutoLaunchCanceled() {
+ base::RecordAction(base::UserMetricsAction("AppList_AutoLaunchCanceled"));
auto_launch_timeout_ = base::TimeDelta();
}
void AppListViewDelegate::OnSpeechResult(const base::string16& result,
bool is_final) {
- speech_ui_.SetSpeechResult(result, is_final);
+ speech_ui_->SetSpeechResult(result, is_final);
if (is_final) {
- auto_launch_timeout_ = base::TimeDelta::FromSeconds(
- kAutoLaunchDefaultTimeoutSec);
+ auto_launch_timeout_ = base::TimeDelta::FromMilliseconds(
+ kAutoLaunchDefaultTimeoutMilliSec);
model_->search_box()->SetText(result);
}
}
void AppListViewDelegate::OnSpeechSoundLevelChanged(int16 level) {
- speech_ui_.UpdateSoundLevel(level);
+ speech_ui_->UpdateSoundLevel(level);
}
void AppListViewDelegate::OnSpeechRecognitionStateChanged(
app_list::SpeechRecognitionState new_state) {
- speech_ui_.SetSpeechRecognitionState(new_state);
+ speech_ui_->SetSpeechRecognitionState(new_state);
}
void AppListViewDelegate::Observe(