summaryrefslogtreecommitdiffstats
path: root/ui/app_list
diff options
context:
space:
mode:
authortapted <tapted@chromium.org>2014-09-08 23:49:40 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-09 06:59:37 +0000
commit966607ad9fc89b31dfc991ab65ba941132e2d2bf (patch)
tree386dd74098b9cd781fd2330088f8ed03c92c5299 /ui/app_list
parentb7eac8ac9889cced43322b75c969dd5c49869569 (diff)
downloadchromium_src-966607ad9fc89b31dfc991ab65ba941132e2d2bf.zip
chromium_src-966607ad9fc89b31dfc991ab65ba941132e2d2bf.tar.gz
chromium_src-966607ad9fc89b31dfc991ab65ba941132e2d2bf.tar.bz2
Fix SpeechUIModel lifetime issue in Chrome's AppListViewDelegate when switching profiles
The AppListView observes the SpeechUIModel directly, so SpeechUIModel must outlive profile changes within Chrome's AppListViewDelegate. Profile changes only recreate the app_list::ContentView and subviews, which updates app_list::AppListModel observers, but not app_list::SpeechUIModel observers. This comes up when switching profiles in the desktop app list. To fix, this change gives SpeechUIModel a default constructor to simplify setting the initial speech recognition state, which needs the profile. Then, decouples the lifetime of the SpeechUIModel from the Profile in Chrome's AppListViewDelegate. BUG=405827 TBR=jamescook@chromium.org Review URL: https://codereview.chromium.org/550883002 Cr-Commit-Position: refs/heads/master@{#293878}
Diffstat (limited to 'ui/app_list')
-rw-r--r--ui/app_list/speech_ui_model.cc9
-rw-r--r--ui/app_list/speech_ui_model.h3
-rw-r--r--ui/app_list/test/app_list_test_view_delegate.cc3
3 files changed, 9 insertions, 6 deletions
diff --git a/ui/app_list/speech_ui_model.cc b/ui/app_list/speech_ui_model.cc
index 7f144db..57a123c 100644
--- a/ui/app_list/speech_ui_model.cc
+++ b/ui/app_list/speech_ui_model.cc
@@ -15,10 +15,13 @@ const int16 kDefaultSoundLevel = 200;
} // namespace
-SpeechUIModel::SpeechUIModel(SpeechRecognitionState initial_state)
- : state_(initial_state),
+SpeechUIModel::SpeechUIModel()
+ : is_final_(false),
+ sound_level_(0),
+ state_(app_list::SPEECH_RECOGNITION_OFF),
minimum_sound_level_(kDefaultSoundLevel),
- maximum_sound_level_(kDefaultSoundLevel) {}
+ maximum_sound_level_(kDefaultSoundLevel) {
+}
SpeechUIModel::~SpeechUIModel() {}
diff --git a/ui/app_list/speech_ui_model.h b/ui/app_list/speech_ui_model.h
index c89c4ba..aafd003 100644
--- a/ui/app_list/speech_ui_model.h
+++ b/ui/app_list/speech_ui_model.h
@@ -17,7 +17,8 @@ namespace app_list {
// SpeechUIModel provides the interface to update the UI for speech recognition.
class APP_LIST_EXPORT SpeechUIModel {
public:
- explicit SpeechUIModel(SpeechRecognitionState initial_state);
+ // Construct the model, initially in state SPEECH_RECOGNITION_OFF.
+ SpeechUIModel();
virtual ~SpeechUIModel();
void SetSpeechResult(const base::string16& result, bool is_final);
diff --git a/ui/app_list/test/app_list_test_view_delegate.cc b/ui/app_list/test/app_list_test_view_delegate.cc
index 56c2e8f..99b2cd2 100644
--- a/ui/app_list/test/app_list_test_view_delegate.cc
+++ b/ui/app_list/test/app_list_test_view_delegate.cc
@@ -23,8 +23,7 @@ AppListTestViewDelegate::AppListTestViewDelegate()
toggle_speech_recognition_count_(0),
open_search_result_count_(0),
next_profile_app_count_(0),
- model_(new AppListTestModel),
- speech_ui_(SPEECH_RECOGNITION_OFF) {
+ model_(new AppListTestModel) {
model_->SetFoldersEnabled(true);
}