Chromium Code Reviews| Index: ui/app_list/search_box_view.h |
| diff --git a/ui/app_list/search_box_view.h b/ui/app_list/search_box_view.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bf1e4e9441d410d18da4f69842ea8b87e4379411 |
| --- /dev/null |
| +++ b/ui/app_list/search_box_view.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_APP_LIST_SEARCH_BOX_VIEW_H_ |
| +#define UI_APP_LIST_SEARCH_BOX_VIEW_H_ |
| +#pragma once |
| + |
| +#include <string> |
| + |
| +#include "base/timer.h" |
| +#include "ui/app_list/search_box_model_observer.h" |
| +#include "ui/views/view.h" |
| +#include "ui/views/controls/textfield/textfield_controller.h" |
| + |
| +namespace views { |
| +class ImageView; |
| +class Textfield; |
| +} // namespace views |
| + |
| +namespace app_list { |
| + |
| +class SearchBoxModel; |
| +class SearchBoxViewDelegate; |
| + |
| +class SearchBoxView : public views::View, |
|
sky
2012/05/22 22:16:06
Add a description.
xiyuan
2012/05/23 21:25:22
Done.
|
| + public views::TextfieldController, |
| + public SearchBoxModelObserver { |
| + public: |
| + explicit SearchBoxView(SearchBoxViewDelegate* delegate); |
| + virtual ~SearchBoxView(); |
| + |
| + void SetModel(SearchBoxModel* model); |
| + |
| + views::Textfield* search_box() { |
| + return search_box_; |
| + } |
| + |
| + private: |
| + // Updates model text and selection model with current Textfield info. |
| + void UpdateModel(); |
| + |
| + // Fires query change notification. |
| + void NotifyQueryChanged(); |
| + |
| + // Overridden from views::View: |
| + virtual gfx::Size GetPreferredSize() OVERRIDE; |
| + virtual void Layout() OVERRIDE; |
| + |
| + // Overridden from views::TextfieldController: |
| + virtual void ContentsChanged(views::Textfield* sender, |
| + const string16& new_contents) OVERRIDE; |
| + virtual bool HandleKeyEvent(views::Textfield* sender, |
| + const views::KeyEvent& key_event) OVERRIDE; |
| + |
| + // Overridden from SearchBoxModelObserver: |
| + virtual void IconChanged() OVERRIDE; |
| + virtual void HintTextChanged() OVERRIDE; |
| + virtual void SelectionModelChanged() OVERRIDE; |
| + virtual void TextChanged() OVERRIDE; |
| + |
| + SearchBoxViewDelegate* delegate_; // Not owned. |
| + SearchBoxModel* model_; // Owned by AppListModel |
| + |
| + views::ImageView* icon_view_; // Owned by views hierarchy |
| + views::Textfield* search_box_; // Owned by views hierarchy |
| + |
| + // Query text change coalescing timer. |
| + base::OneShotTimer<SearchBoxView> query_timer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SearchBoxView); |
| +}; |
| + |
| +} // namespace app_list |
| + |
| +#endif // UI_APP_LIST_SEARCH_BOX_VIEW_H_ |
| + |