Correct blacklist entry message
[chromium-blink-merge.git] / ui / app_list / views / search_box_view.h
blobc06990262a57c9fb93d8f992647d5aba7ab6c224
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_VIEWS_SEARCH_BOX_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_
8 #include <string>
10 #include "ui/app_list/search_box_model_observer.h"
11 #include "ui/views/controls/button/menu_button_listener.h"
12 #include "ui/views/controls/textfield/textfield_controller.h"
13 #include "ui/views/view.h"
15 namespace views {
16 class ImageView;
17 class MenuButton;
18 class Textfield;
19 } // namespace views
21 namespace app_list {
23 class AppListMenuViews;
24 class AppListModel;
25 class AppListViewDelegate;
26 class SearchBoxModel;
27 class SearchBoxViewDelegate;
29 // SearchBoxView consists of an icon and a Textfield. SearchBoxModel is its data
30 // model that controls what icon to display, what placeholder text to use for
31 // Textfield. The text and selection model part could be set to change the
32 // contents and selection model of the Textfield.
33 class SearchBoxView : public views::View,
34 public views::TextfieldController,
35 public views::MenuButtonListener,
36 public SearchBoxModelObserver {
37 public:
38 SearchBoxView(SearchBoxViewDelegate* delegate,
39 AppListViewDelegate* view_delegate,
40 AppListModel* model);
41 virtual ~SearchBoxView();
43 bool HasSearch() const;
44 void ClearSearch();
45 void InvalidateMenu();
47 views::Textfield* search_box() { return search_box_; }
49 void set_contents_view(View* contents_view) {
50 contents_view_ = contents_view;
53 // Overridden from views::View:
54 virtual gfx::Size GetPreferredSize() OVERRIDE;
55 virtual void Layout() OVERRIDE;
56 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
58 private:
59 // Updates model text and selection model with current Textfield info.
60 void UpdateModel();
62 // Fires query change notification.
63 void NotifyQueryChanged();
65 // Overridden from views::TextfieldController:
66 virtual void ContentsChanged(views::Textfield* sender,
67 const base::string16& new_contents) OVERRIDE;
68 virtual bool HandleKeyEvent(views::Textfield* sender,
69 const ui::KeyEvent& key_event) OVERRIDE;
71 // Overridden from views::MenuButtonListener:
72 virtual void OnMenuButtonClicked(View* source,
73 const gfx::Point& point) OVERRIDE;
75 // Overridden from SearchBoxModelObserver:
76 virtual void IconChanged() OVERRIDE;
77 virtual void HintTextChanged() OVERRIDE;
78 virtual void SelectionModelChanged() OVERRIDE;
79 virtual void TextChanged() OVERRIDE;
81 SearchBoxViewDelegate* delegate_; // Not owned.
82 AppListViewDelegate* view_delegate_; // Not owned.
83 AppListModel* model_; // Owned by AppListView.
85 scoped_ptr<AppListMenuViews> menu_;
87 views::ImageView* icon_view_; // Owned by views hierarchy.
88 views::MenuButton* menu_button_; // Owned by views hierarchy.
89 views::Textfield* search_box_; // Owned by views hierarchy.
90 views::View* contents_view_; // Owned by views hierarchy.
92 DISALLOW_COPY_AND_ASSIGN(SearchBoxView);
95 } // namespace app_list
97 #endif // UI_APP_LIST_VIEWS_SEARCH_BOX_VIEW_H_