Revert 285871 "Revert 285867 "Revert 285832 "Disable accessible ..."
[chromium-blink-merge.git] / ui / app_list / search_box_model.h
blob0512c2e195a0f69897c3248eeeefd985900ba690
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 #ifndef UI_APP_LIST_SEARCH_BOX_MODEL_H_
6 #define UI_APP_LIST_SEARCH_BOX_MODEL_H_
8 #include "base/basictypes.h"
9 #include "base/observer_list.h"
10 #include "base/strings/string16.h"
11 #include "ui/app_list/app_list_export.h"
12 #include "ui/gfx/image/image_skia.h"
13 #include "ui/gfx/selection_model.h"
15 namespace app_list {
17 class SearchBoxModelObserver;
19 // SearchBoxModel consisits of an icon, a hint text, a user text and a selection
20 // model. The icon is rendered to the side of the query editor. The hint text
21 // is used as query edit control's placeholder text and displayed when there is
22 // no user text in the control. The selection model and the text represents the
23 // text, cursor position and selected text in edit control.
24 class APP_LIST_EXPORT SearchBoxModel {
25 public:
26 // The properties of the speech button.
27 struct APP_LIST_EXPORT SpeechButtonProperty {
28 SpeechButtonProperty(const gfx::ImageSkia& on_icon,
29 const base::string16& on_tooltip,
30 const gfx::ImageSkia& off_icon,
31 const base::string16& off_tooltip);
32 ~SpeechButtonProperty();
34 // The icon/tooltip when the hotword is on.
35 gfx::ImageSkia on_icon;
36 base::string16 on_tooltip;
38 // The icon/tooltip when the hotword is off.
39 gfx::ImageSkia off_icon;
40 base::string16 off_tooltip;
43 SearchBoxModel();
44 ~SearchBoxModel();
46 // Sets/gets the icon on the left side of edit box.
47 void SetIcon(const gfx::ImageSkia& icon);
48 const gfx::ImageSkia& icon() const { return icon_; }
50 // Sets/gets the properties for the button of speech recognition.
51 void SetSpeechRecognitionButton(
52 scoped_ptr<SpeechButtonProperty> speech_button);
53 const SpeechButtonProperty* speech_button() const {
54 return speech_button_.get();
57 // Sets/gets the hint text to display when there is in input.
58 void SetHintText(const base::string16& hint_text);
59 const base::string16& hint_text() const { return hint_text_; }
61 // Sets/gets the selection model for the search box's Textfield.
62 void SetSelectionModel(const gfx::SelectionModel& sel);
63 const gfx::SelectionModel& selection_model() const {
64 return selection_model_;
67 // Sets/gets the text for the search box's Textfield.
68 void SetText(const base::string16& text);
69 const base::string16& text() const { return text_; }
71 void AddObserver(SearchBoxModelObserver* observer);
72 void RemoveObserver(SearchBoxModelObserver* observer);
74 private:
75 gfx::ImageSkia icon_;
76 scoped_ptr<SpeechButtonProperty> speech_button_;
77 base::string16 hint_text_;
78 gfx::SelectionModel selection_model_;
79 base::string16 text_;
81 ObserverList<SearchBoxModelObserver> observers_;
83 DISALLOW_COPY_AND_ASSIGN(SearchBoxModel);
86 } // namespace app_list
88 #endif // UI_APP_LIST_SEARCH_BOX_MODEL_H_