| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_APP_LIST_APP_LIST_MODEL_H_ | 5 #ifndef UI_APP_LIST_APP_LIST_MODEL_H_ |
| 6 #define UI_APP_LIST_APP_LIST_MODEL_H_ | 6 #define UI_APP_LIST_APP_LIST_MODEL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "ui/app_list/app_list_export.h" | 16 #include "ui/app_list/app_list_export.h" |
| 17 #include "ui/app_list/app_list_item_list.h" | 17 #include "ui/app_list/app_list_item_list.h" |
| 18 #include "ui/app_list/app_list_item_list_observer.h" | 18 #include "ui/app_list/app_list_item_list_observer.h" |
| 19 #include "ui/app_list/search_result.h" | 19 #include "ui/app_list/search_result.h" |
| 20 #include "ui/base/models/list_model.h" | 20 #include "ui/base/models/list_model.h" |
| 21 | 21 |
| 22 namespace app_list { | 22 namespace app_list { |
| 23 | 23 |
| 24 class AppListFolderItem; | 24 class AppListFolderItem; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 State state() { return state_; } | 67 State state() { return state_; } |
| 68 | 68 |
| 69 // Finds the item matching |id|. | 69 // Finds the item matching |id|. |
| 70 AppListItem* FindItem(const std::string& id); | 70 AppListItem* FindItem(const std::string& id); |
| 71 | 71 |
| 72 // Find a folder item matching |id|. | 72 // Find a folder item matching |id|. |
| 73 AppListFolderItem* FindFolderItem(const std::string& id); | 73 AppListFolderItem* FindFolderItem(const std::string& id); |
| 74 | 74 |
| 75 // Adds |item| to the model. The model takes ownership of |item|. Returns a | 75 // Adds |item| to the model. The model takes ownership of |item|. Returns a |
| 76 // pointer to the item that is safe to use (e.g. after passing ownership). | 76 // pointer to the item that is safe to use (e.g. after passing ownership). |
| 77 AppListItem* AddItem(scoped_ptr<AppListItem> item); | 77 AppListItem* AddItem(std::unique_ptr<AppListItem> item); |
| 78 | 78 |
| 79 // Adds |item| to an existing folder or creates a new folder. If |folder_id| | 79 // Adds |item| to an existing folder or creates a new folder. If |folder_id| |
| 80 // is empty, adds the item to the top level model instead. The model takes | 80 // is empty, adds the item to the top level model instead. The model takes |
| 81 // ownership of |item|. Returns a pointer to the item that is safe to use. | 81 // ownership of |item|. Returns a pointer to the item that is safe to use. |
| 82 AppListItem* AddItemToFolder(scoped_ptr<AppListItem> item, | 82 AppListItem* AddItemToFolder(std::unique_ptr<AppListItem> item, |
| 83 const std::string& folder_id); | 83 const std::string& folder_id); |
| 84 | 84 |
| 85 // Merges two items. If the target item is a folder, the source item is added | 85 // Merges two items. If the target item is a folder, the source item is added |
| 86 // to the end of the target folder. Otherwise a new folder is created in the | 86 // to the end of the target folder. Otherwise a new folder is created in the |
| 87 // same position as the target item with the target item as the first item in | 87 // same position as the target item with the target item as the first item in |
| 88 // the new folder and the source item as the second item. Returns the id of | 88 // the new folder and the source item as the second item. Returns the id of |
| 89 // the target folder, or an empty string if the merge failed. The source item | 89 // the target folder, or an empty string if the merge failed. The source item |
| 90 // may already be in a folder. See also the comment for RemoveItemFromFolder. | 90 // may already be in a folder. See also the comment for RemoveItemFromFolder. |
| 91 // NOTE: This should only be called by the View code (not the sync code); it | 91 // NOTE: This should only be called by the View code (not the sync code); it |
| 92 // enforces folder restrictions (e.g. the target can not be an OEM folder). | 92 // enforces folder restrictions (e.g. the target can not be an OEM folder). |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // AppListItemListObserver | 187 // AppListItemListObserver |
| 188 void OnListItemMoved(size_t from_index, | 188 void OnListItemMoved(size_t from_index, |
| 189 size_t to_index, | 189 size_t to_index, |
| 190 AppListItem* item) override; | 190 AppListItem* item) override; |
| 191 | 191 |
| 192 // Returns an existing folder matching |folder_id| or creates a new folder. | 192 // Returns an existing folder matching |folder_id| or creates a new folder. |
| 193 AppListFolderItem* FindOrCreateFolderItem(const std::string& folder_id); | 193 AppListFolderItem* FindOrCreateFolderItem(const std::string& folder_id); |
| 194 | 194 |
| 195 // Adds |item_ptr| to |top_level_item_list_| and notifies observers. | 195 // Adds |item_ptr| to |top_level_item_list_| and notifies observers. |
| 196 AppListItem* AddItemToItemListAndNotify( | 196 AppListItem* AddItemToItemListAndNotify( |
| 197 scoped_ptr<AppListItem> item_ptr); | 197 std::unique_ptr<AppListItem> item_ptr); |
| 198 | 198 |
| 199 // Adds |item_ptr| to |top_level_item_list_| and notifies observers that an | 199 // Adds |item_ptr| to |top_level_item_list_| and notifies observers that an |
| 200 // Update occured (e.g. item moved from a folder). | 200 // Update occured (e.g. item moved from a folder). |
| 201 AppListItem* AddItemToItemListAndNotifyUpdate( | 201 AppListItem* AddItemToItemListAndNotifyUpdate( |
| 202 scoped_ptr<AppListItem> item_ptr); | 202 std::unique_ptr<AppListItem> item_ptr); |
| 203 | 203 |
| 204 // Adds |item_ptr| to |folder| and notifies observers. | 204 // Adds |item_ptr| to |folder| and notifies observers. |
| 205 AppListItem* AddItemToFolderItemAndNotify(AppListFolderItem* folder, | 205 AppListItem* AddItemToFolderItemAndNotify( |
| 206 scoped_ptr<AppListItem> item_ptr); | 206 AppListFolderItem* folder, |
| 207 std::unique_ptr<AppListItem> item_ptr); |
| 207 | 208 |
| 208 // Removes |item| from |top_level_item_list_| or calls RemoveItemFromFolder if | 209 // Removes |item| from |top_level_item_list_| or calls RemoveItemFromFolder if |
| 209 // |item|->folder_id is set. | 210 // |item|->folder_id is set. |
| 210 scoped_ptr<AppListItem> RemoveItem(AppListItem* item); | 211 std::unique_ptr<AppListItem> RemoveItem(AppListItem* item); |
| 211 | 212 |
| 212 // Removes |item| from |folder|. If |folder| becomes empty, deletes |folder| | 213 // Removes |item| from |folder|. If |folder| becomes empty, deletes |folder| |
| 213 // from |top_level_item_list_|. Does NOT trigger observers, calling function | 214 // from |top_level_item_list_|. Does NOT trigger observers, calling function |
| 214 // must do so. | 215 // must do so. |
| 215 scoped_ptr<AppListItem> RemoveItemFromFolder(AppListFolderItem* folder, | 216 std::unique_ptr<AppListItem> RemoveItemFromFolder(AppListFolderItem* folder, |
| 216 AppListItem* item); | 217 AppListItem* item); |
| 217 | 218 |
| 218 scoped_ptr<AppListItemList> top_level_item_list_; | 219 std::unique_ptr<AppListItemList> top_level_item_list_; |
| 219 | 220 |
| 220 scoped_ptr<SearchBoxModel> search_box_; | 221 std::unique_ptr<SearchBoxModel> search_box_; |
| 221 scoped_ptr<SearchResults> results_; | 222 std::unique_ptr<SearchResults> results_; |
| 222 | 223 |
| 223 Status status_; | 224 Status status_; |
| 224 State state_; | 225 State state_; |
| 225 base::ObserverList<AppListModelObserver, true> observers_; | 226 base::ObserverList<AppListModelObserver, true> observers_; |
| 226 bool folders_enabled_; | 227 bool folders_enabled_; |
| 227 bool custom_launcher_page_enabled_; | 228 bool custom_launcher_page_enabled_; |
| 228 std::string custom_launcher_page_name_; | 229 std::string custom_launcher_page_name_; |
| 229 bool search_engine_is_google_; | 230 bool search_engine_is_google_; |
| 230 | 231 |
| 231 // The current number of subpages the custom launcher page has pushed. | 232 // The current number of subpages the custom launcher page has pushed. |
| 232 int custom_launcher_page_subpage_depth_; | 233 int custom_launcher_page_subpage_depth_; |
| 233 | 234 |
| 234 DISALLOW_COPY_AND_ASSIGN(AppListModel); | 235 DISALLOW_COPY_AND_ASSIGN(AppListModel); |
| 235 }; | 236 }; |
| 236 | 237 |
| 237 } // namespace app_list | 238 } // namespace app_list |
| 238 | 239 |
| 239 #endif // UI_APP_LIST_APP_LIST_MODEL_H_ | 240 #endif // UI_APP_LIST_APP_LIST_MODEL_H_ |
| OLD | NEW |