Move VISUAL_STATE promise to activation
[chromium-blink-merge.git] / ui / app_list / app_list_folder_item.h
blob7989e702b910569d6320c9ba9a3b3bd3f3783b86
1 // Copyright 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_APP_LIST_FOLDER_ITEM_H_
6 #define UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_
8 #include <string>
9 #include <vector>
11 #include "ui/app_list/app_list_export.h"
12 #include "ui/app_list/app_list_item.h"
13 #include "ui/app_list/app_list_item_list_observer.h"
14 #include "ui/app_list/app_list_item_observer.h"
15 #include "ui/app_list/folder_image.h"
17 namespace gfx {
18 class ImageSkia;
19 class Rect;
22 namespace app_list {
24 class AppListItemList;
26 // AppListFolderItem implements the model/controller for folders.
27 class APP_LIST_EXPORT AppListFolderItem : public AppListItem,
28 public FolderImageObserver {
29 public:
30 // The folder type affects folder behavior.
31 enum FolderType {
32 // Default folder type.
33 FOLDER_TYPE_NORMAL,
34 // Items can not be moved to/from OEM folders in the UI.
35 FOLDER_TYPE_OEM
38 static const char kItemType[];
40 AppListFolderItem(const std::string& id, FolderType folder_type);
41 ~AppListFolderItem() override;
43 // Returns the icon of one of the top items with |item_index|.
44 const gfx::ImageSkia& GetTopIcon(size_t item_index);
46 // Returns the target icon bounds for |item| to fly back to its parent folder
47 // icon in animation UI. If |item| is one of the top item icon, this will
48 // match its corresponding top item icon in the folder icon. Otherwise,
49 // the target icon bounds is centered at the |folder_icon_bounds| with
50 // the same size of the top item icon.
51 // The Rect returned is in the same coordinates of |folder_icon_bounds|.
52 gfx::Rect GetTargetIconRectInFolderForItem(
53 AppListItem* item, const gfx::Rect& folder_icon_bounds);
55 AppListItemList* item_list() { return item_list_.get(); }
56 const AppListItemList* item_list() const { return item_list_.get(); }
58 // For tests.
59 const FolderImage& folder_image() const { return folder_image_; }
61 FolderType folder_type() const { return folder_type_; }
63 // AppListItem overrides:
64 void Activate(int event_flags) override;
65 const char* GetItemType() const override;
66 ui::MenuModel* GetContextMenuModel() override;
67 AppListItem* FindChildItem(const std::string& id) override;
68 size_t ChildItemCount() const override;
69 void OnExtensionPreferenceChanged() override;
70 bool CompareForTest(const AppListItem* other) const override;
72 // Returns an id for a new folder.
73 static std::string GenerateId();
75 // FolderImageObserver overrides:
76 void OnFolderImageUpdated() override;
78 private:
79 // The type of folder; may affect behavior of folder views.
80 const FolderType folder_type_;
82 // List of items in the folder.
83 scoped_ptr<AppListItemList> item_list_;
85 FolderImage folder_image_;
87 DISALLOW_COPY_AND_ASSIGN(AppListFolderItem);
90 } // namespace app_list
92 #endif // UI_APP_LIST_APP_LIST_FOLDER_ITEM_H_