Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / views / folder_header_view.h
blob81c998af2493cf8a26f3356d8d2094df44153a19
1 // Copyright (c) 2013 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_FOLDER_HEADER_VIEW_H_
6 #define UI_APP_LIST_VIEWS_FOLDER_HEADER_VIEW_H_
8 #include <string>
10 #include "ui/app_list/app_list_export.h"
11 #include "ui/app_list/app_list_item_observer.h"
12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/textfield/textfield_controller.h"
14 #include "ui/views/view.h"
16 namespace views {
17 class ImageButton;
18 } // namespace views
20 namespace app_list {
22 class AppListFolderItem;
23 class AppListFolderView;
24 class FolderHeaderViewDelegate;
26 namespace test {
27 class FolderHeaderViewTest;
30 // FolderHeaderView contains a back button and an editable folder name field.
31 class APP_LIST_EXPORT FolderHeaderView : public views::View,
32 public views::TextfieldController,
33 public views::ButtonListener,
34 public AppListItemObserver {
35 public:
36 explicit FolderHeaderView(FolderHeaderViewDelegate* delegate);
37 ~FolderHeaderView() override;
39 void SetFolderItem(AppListFolderItem* folder_item);
40 void UpdateFolderNameVisibility(bool visible);
41 void OnFolderItemRemoved();
42 bool HasTextFocus() const;
43 void SetTextFocus();
45 // Overridden from views::View:
46 gfx::Size GetPreferredSize() const override;
48 private:
49 class FolderNameView;
50 friend class test::FolderHeaderViewTest;
52 // Updates UI.
53 void Update();
55 // Updates the accessible name of the folder name control.
56 void UpdateFolderNameAccessibleName();
58 // Gets and sets the folder name for test.
59 const base::string16& GetFolderNameForTest();
60 void SetFolderNameForTest(const base::string16& name);
62 // Returns true if folder name is enabled, only for testing use.
63 bool IsFolderNameEnabledForTest() const;
65 // views::View overrides:
66 void Layout() override;
67 bool OnKeyPressed(const ui::KeyEvent& event) override;
68 void OnPaint(gfx::Canvas* canvas) override;
70 // views::TextfieldController overrides:
71 void ContentsChanged(views::Textfield* sender,
72 const base::string16& new_contents) override;
74 // views::ButtonListener overrides:
75 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
77 // AppListItemObserver overrides:
78 void ItemNameChanged() override;
80 AppListFolderItem* folder_item_; // Not owned.
82 views::ImageButton* back_button_; // Owned by views hierarchy.
83 FolderNameView* folder_name_view_; // Owned by views hierarchy.
85 const base::string16 folder_name_placeholder_text_;
87 FolderHeaderViewDelegate* delegate_;
89 bool folder_name_visible_;
91 DISALLOW_COPY_AND_ASSIGN(FolderHeaderView);
94 } // namespace app_list
96 #endif // UI_APP_LIST_VIEWS_FOLDER_HEADER_VIEW_H_