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"
12 SearchBoxModel::SearchBoxModel() {
15 SearchBoxModel::~SearchBoxModel() {
18 void SearchBoxModel::SetIcon(const gfx::ImageSkia& icon) {
20 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, IconChanged());
23 void SearchBoxModel::SetHintText(const base::string16& hint_text) {
24 if (hint_text_ == hint_text)
27 hint_text_ = hint_text;
28 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, HintTextChanged());
31 void SearchBoxModel::SetSelectionModel(const gfx::SelectionModel& sel) {
32 if (selection_model_ == sel)
35 selection_model_ = sel;
36 FOR_EACH_OBSERVER(SearchBoxModelObserver,
38 SelectionModelChanged());
41 void SearchBoxModel::SetText(const base::string16& text) {
45 // Log that a new search has been commenced whenever the text box text
46 // transitions from empty to non-empty.
47 if (text_.empty() && !text.empty()) {
48 UMA_HISTOGRAM_ENUMERATION("Apps.AppListSearchCommenced", 1, 2);
51 FOR_EACH_OBSERVER(SearchBoxModelObserver, observers_, TextChanged());
54 void SearchBoxModel::AddObserver(SearchBoxModelObserver* observer) {
55 observers_.AddObserver(observer);
58 void SearchBoxModel::RemoveObserver(SearchBoxModelObserver* observer) {
59 observers_.RemoveObserver(observer);
62 } // namespace app_list