Add protos to control device disabling during normal operation
[chromium-blink-merge.git] / ui / app_list / search_box_model.cc
blob006c4b3f312b27e24908764d889ceba73f4d7243
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/app_list/search_box_model.h"
7 #include "base/metrics/histogram.h"
8 #include "ui/app_list/search_box_model_observer.h"
10 namespace app_list {
12 SearchBoxModel::SpeechButtonProperty::SpeechButtonProperty(
13 const gfx::ImageSkia& on_icon,
14 const base::string16& on_tooltip,
15 const gfx::ImageSkia& off_icon,
16 const base::string16& off_tooltip)
17 : on_icon(on_icon),
18 on_tooltip(on_tooltip),
19 off_icon(off_icon),
20 off_tooltip(off_tooltip) {
23 SearchBoxModel::SpeechButtonProperty::~SpeechButtonProperty() {
26 SearchBoxModel::SearchBoxModel() {
29 SearchBoxModel::~SearchBoxModel() {
32 void SearchBoxModel::SetIcon(const gfx::ImageSkia& icon) {
33 icon_ = icon;
34 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, IconChanged());
37 void SearchBoxModel::SetSpeechRecognitionButton(
38 scoped_ptr<SearchBoxModel::SpeechButtonProperty> speech_button) {
39 speech_button_ = speech_button.Pass();
40 FOR_EACH_OBSERVER(SearchBoxModelObserver,
41 observers_,
42 SpeechRecognitionButtonPropChanged());
45 void SearchBoxModel::SetHintText(const base::string16& hint_text) {
46 if (hint_text_ == hint_text)
47 return;
49 hint_text_ = hint_text;
50 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, HintTextChanged());
53 void SearchBoxModel::SetSelectionModel(const gfx::SelectionModel& sel) {
54 if (selection_model_ == sel)
55 return;
57 selection_model_ = sel;
58 FOR_EACH_OBSERVER(SearchBoxModelObserver,
59 observers_,
60 SelectionModelChanged());
63 void SearchBoxModel::SetText(const base::string16& text) {
64 if (text_ == text)
65 return;
67 // Log that a new search has been commenced whenever the text box text
68 // transitions from empty to non-empty.
69 if (text_.empty() && !text.empty()) {
70 UMA_HISTOGRAM_ENUMERATION("Apps.AppListSearchCommenced", 1, 2);
72 text_ = text;
73 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, TextChanged());
76 void SearchBoxModel::AddObserver(SearchBoxModelObserver* observer) {
77 observers_.AddObserver(observer);
80 void SearchBoxModel::RemoveObserver(SearchBoxModelObserver* observer) {
81 observers_.RemoveObserver(observer);
84 } // namespace app_list