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

Unified Diff: ui/app_list/views/search_box_view.cc

Issue 149753002: Enables the 'hotword not listening' icon in the search box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix breaks Created 6 years, 11 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 | « ui/app_list/views/search_box_view.h ('k') | ui/app_list/views/speech_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/search_box_view.cc
diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc
index f7a84f43654ac7b1b77e928148883a0f7efee783..aee2c2f0edd9f5a732f50e65b66fdb3efe32f8cb 100644
--- a/ui/app_list/views/search_box_view.cc
+++ b/ui/app_list/views/search_box_view.cc
@@ -10,6 +10,7 @@
#include "ui/app_list/app_list_model.h"
#include "ui/app_list/app_list_view_delegate.h"
#include "ui/app_list/search_box_model.h"
+#include "ui/app_list/speech_ui_model.h"
#include "ui/app_list/views/app_list_menu_views.h"
#include "ui/app_list/views/contents_view.h"
#include "ui/app_list/views/search_box_view_delegate.h"
@@ -70,10 +71,12 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
search_box_->set_controller(this);
AddChildView(search_box_);
+ view_delegate_->GetSpeechUI()->AddObserver(this);
ModelChanged();
}
SearchBoxView::~SearchBoxView() {
+ view_delegate_->GetSpeechUI()->RemoveObserver(this);
model_->search_box()->RemoveObserver(this);
}
@@ -210,16 +213,24 @@ void SearchBoxView::IconChanged() {
}
void SearchBoxView::SpeechRecognitionButtonPropChanged() {
- const SearchBoxModel::ButtonProperty* speech_button_prop =
+ const SearchBoxModel::SpeechButtonProperty* speech_button_prop =
model_->search_box()->speech_button();
if (speech_button_prop) {
if (!speech_button_) {
speech_button_ = new views::ImageButton(this);
AddChildView(speech_button_);
}
- speech_button_->SetImage(views::Button::STATE_NORMAL,
- &speech_button_prop->icon);
- speech_button_->SetTooltipText(speech_button_prop->tooltip);
+
+ if (view_delegate_->GetSpeechUI()->state() ==
+ SPEECH_RECOGNITION_HOTWORD_LISTENING) {
+ speech_button_->SetImage(
+ views::Button::STATE_NORMAL, &speech_button_prop->on_icon);
+ speech_button_->SetTooltipText(speech_button_prop->on_tooltip);
+ } else {
+ speech_button_->SetImage(
+ views::Button::STATE_NORMAL, &speech_button_prop->off_icon);
+ speech_button_->SetTooltipText(speech_button_prop->off_tooltip);
+ }
} else {
if (speech_button_) {
// Deleting a view will detach it from its parent.
@@ -242,4 +253,10 @@ void SearchBoxView::TextChanged() {
NotifyQueryChanged();
}
+void SearchBoxView::OnSpeechRecognitionStateChanged(
+ SpeechRecognitionState new_state) {
+ SpeechRecognitionButtonPropChanged();
+ SchedulePaint();
+}
+
} // namespace app_list
« no previous file with comments | « ui/app_list/views/search_box_view.h ('k') | ui/app_list/views/speech_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698