Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: ui/app_list/app_list_item_list.h

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/app_list/app_list_folder_item.h ('k') | ui/app_list/app_list_item_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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_ITEM_LIST_H_ 5 #ifndef UI_APP_LIST_APP_LIST_ITEM_LIST_H_
6 #define UI_APP_LIST_APP_LIST_ITEM_LIST_H_ 6 #define UI_APP_LIST_APP_LIST_ITEM_LIST_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
10 #include <string> 11 #include <string>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "sync/api/string_ordinal.h" 16 #include "sync/api/string_ordinal.h"
17 #include "ui/app_list/app_list_export.h" 17 #include "ui/app_list/app_list_export.h"
18 #include "ui/app_list/app_list_item_list_observer.h" 18 #include "ui/app_list/app_list_item_list_observer.h"
19 19
20 namespace app_list { 20 namespace app_list {
21 21
22 class AppListItem; 22 class AppListItem;
23 23
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 friend class AppListModel; 70 friend class AppListModel;
71 71
72 // Returns a unique, valid StringOrdinal immediately before |position| or at 72 // Returns a unique, valid StringOrdinal immediately before |position| or at
73 // the end of the list if |position| is invalid. 73 // the end of the list if |position| is invalid.
74 syncer::StringOrdinal CreatePositionBefore( 74 syncer::StringOrdinal CreatePositionBefore(
75 const syncer::StringOrdinal& position); 75 const syncer::StringOrdinal& position);
76 76
77 // Adds |item| to the end of |app_list_items_|. Takes ownership of |item|. 77 // Adds |item| to the end of |app_list_items_|. Takes ownership of |item|.
78 // Triggers observers_.OnListItemAdded(). Returns a pointer to the added item 78 // Triggers observers_.OnListItemAdded(). Returns a pointer to the added item
79 // that is safe to use (e.g. after releasing a scoped ptr). 79 // that is safe to use (e.g. after releasing a scoped ptr).
80 AppListItem* AddItem(scoped_ptr<AppListItem> item_ptr); 80 AppListItem* AddItem(std::unique_ptr<AppListItem> item_ptr);
81 81
82 // Finds item matching |id| in |app_list_items_| (linear search) and deletes 82 // Finds item matching |id| in |app_list_items_| (linear search) and deletes
83 // it. Triggers observers_.OnListItemRemoved() after removing the item from 83 // it. Triggers observers_.OnListItemRemoved() after removing the item from
84 // the list and before deleting it. 84 // the list and before deleting it.
85 void DeleteItem(const std::string& id); 85 void DeleteItem(const std::string& id);
86 86
87 // Removes the item with matching |id| in |app_list_items_| without deleting 87 // Removes the item with matching |id| in |app_list_items_| without deleting
88 // it. Returns a scoped pointer containing the removed item. 88 // it. Returns a scoped pointer containing the removed item.
89 scoped_ptr<AppListItem> RemoveItem(const std::string& id); 89 std::unique_ptr<AppListItem> RemoveItem(const std::string& id);
90 90
91 // Removes the item at |index| from |app_list_items_| without deleting it. 91 // Removes the item at |index| from |app_list_items_| without deleting it.
92 // Returns a scoped pointer containing the removed item. 92 // Returns a scoped pointer containing the removed item.
93 scoped_ptr<AppListItem> RemoveItemAt(size_t index); 93 std::unique_ptr<AppListItem> RemoveItemAt(size_t index);
94 94
95 // Deletes item at |index| and signals observers. 95 // Deletes item at |index| and signals observers.
96 void DeleteItemAt(size_t index); 96 void DeleteItemAt(size_t index);
97 97
98 // If |item|->position() is not a valid ordinal, sets |item|->position() 98 // If |item|->position() is not a valid ordinal, sets |item|->position()
99 // to a valid ordinal after the last item in the list. 99 // to a valid ordinal after the last item in the list.
100 void EnsureValidItemPosition(AppListItem* item); 100 void EnsureValidItemPosition(AppListItem* item);
101 101
102 // Returns the index at which to insert an item in |app_list_items_| based on 102 // Returns the index at which to insert an item in |app_list_items_| based on
103 // |position| (which must be valid) and |id| (if the positions are equal). 103 // |position| (which must be valid) and |id| (if the positions are equal).
104 size_t GetItemSortOrderIndex(const syncer::StringOrdinal& position, 104 size_t GetItemSortOrderIndex(const syncer::StringOrdinal& position,
105 const std::string& id); 105 const std::string& id);
106 106
107 // Fixes the position of the item at |index| when the position matches the 107 // Fixes the position of the item at |index| when the position matches the
108 // previous item's position. |index| must be > 0. 108 // previous item's position. |index| must be > 0.
109 void FixItemPosition(size_t index); 109 void FixItemPosition(size_t index);
110 110
111 ScopedVector<AppListItem> app_list_items_; 111 ScopedVector<AppListItem> app_list_items_;
112 base::ObserverList<AppListItemListObserver, true> observers_; 112 base::ObserverList<AppListItemListObserver, true> observers_;
113 std::string highlighted_id_; 113 std::string highlighted_id_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(AppListItemList); 115 DISALLOW_COPY_AND_ASSIGN(AppListItemList);
116 }; 116 };
117 117
118 } // namespace app_list 118 } // namespace app_list
119 119
120 #endif // UI_APP_LIST_APP_LIST_ITEM_LIST_H_ 120 #endif // UI_APP_LIST_APP_LIST_ITEM_LIST_H_
OLDNEW
« no previous file with comments | « ui/app_list/app_list_folder_item.h ('k') | ui/app_list/app_list_item_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698