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

Side by Side Diff: ash/shelf/shelf_controller.cc

Issue 2918223002: mash: Make ShelfWindowWatcher items for unknown windows. (Closed)
Patch Set: Disable failing mash browser test for now. Created 3 years, 6 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 | « no previous file | ash/shelf/shelf_window_watcher.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "ash/shelf/shelf_controller.h" 5 #include "ash/shelf/shelf_controller.h"
6 6
7 #include "ash/public/cpp/config.h" 7 #include "ash/public/cpp/config.h"
8 #include "ash/public/cpp/remote_shelf_item_delegate.h" 8 #include "ash/public/cpp/remote_shelf_item_delegate.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/session/session_controller.h" 10 #include "ash/session/session_controller.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 int64_t display_id) { 121 int64_t display_id) {
122 Shelf* shelf = GetShelfForDisplay(display_id); 122 Shelf* shelf = GetShelfForDisplay(display_id);
123 // TODO(jamescook): The session state check should not be necessary, but 123 // TODO(jamescook): The session state check should not be necessary, but
124 // otherwise this wrongly tries to set auto-hide state on a secondary display 124 // otherwise this wrongly tries to set auto-hide state on a secondary display
125 // during login. 125 // during login.
126 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted()) 126 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted())
127 shelf->SetAutoHideBehavior(auto_hide); 127 shelf->SetAutoHideBehavior(auto_hide);
128 } 128 }
129 129
130 void ShelfController::AddShelfItem(int32_t index, const ShelfItem& item) { 130 void ShelfController::AddShelfItem(int32_t index, const ShelfItem& item) {
131 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << "Unexpected model sync"; 131 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << " Unexpected model sync";
132 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; 132 DCHECK(!applying_remote_shelf_model_changes_) << " Unexpected model change";
133 index = index < 0 ? model_.item_count() : index; 133 index = index < 0 ? model_.item_count() : index;
134 DCHECK_GT(index, 0) << "Items can not preceed the AppList"; 134 DCHECK_GT(index, 0) << " Items can not preceed the AppList";
135 DCHECK_LE(index, model_.item_count()) << "Index out of bounds"; 135 DCHECK_LE(index, model_.item_count()) << " Index out of bounds";
136 index = std::min(std::max(index, 1), model_.item_count()); 136 index = std::min(std::max(index, 1), model_.item_count());
137 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); 137 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true);
138 model_.AddAt(index, item); 138 model_.AddAt(index, item);
139 } 139 }
140 140
141 void ShelfController::RemoveShelfItem(const ShelfID& id) { 141 void ShelfController::RemoveShelfItem(const ShelfID& id) {
142 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << "Unexpected model sync"; 142 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << " Unexpected model sync";
143 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; 143 DCHECK(!applying_remote_shelf_model_changes_) << " Unexpected model change";
144 const int index = model_.ItemIndexByID(id); 144 const int index = model_.ItemIndexByID(id);
145 DCHECK_GE(index, 0) << "Item not found"; 145 DCHECK_GE(index, 0) << " No item found with the id: " << id;
146 DCHECK_NE(index, 0) << "The AppList shelf item cannot be removed"; 146 DCHECK_NE(index, 0) << " The AppList shelf item cannot be removed";
147 if (index <= 0) 147 if (index <= 0)
148 return; 148 return;
149 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); 149 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true);
150 model_.RemoveItemAt(index); 150 model_.RemoveItemAt(index);
151 } 151 }
152 152
153 void ShelfController::MoveShelfItem(const ShelfID& id, int32_t index) { 153 void ShelfController::MoveShelfItem(const ShelfID& id, int32_t index) {
154 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << "Unexpected model sync"; 154 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << " Unexpected model sync";
155 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; 155 DCHECK(!applying_remote_shelf_model_changes_) << " Unexpected model change";
156 const int current_index = model_.ItemIndexByID(id); 156 const int current_index = model_.ItemIndexByID(id);
157 DCHECK_GE(current_index, 0) << "No item found with the given id"; 157 DCHECK_GE(current_index, 0) << " No item found with the id: " << id;
158 DCHECK_NE(current_index, 0) << "The AppList shelf item cannot be moved"; 158 DCHECK_NE(current_index, 0) << " The AppList shelf item cannot be moved";
159 if (current_index <= 0) 159 if (current_index <= 0)
160 return; 160 return;
161 DCHECK_GT(index, 0) << "Items can not preceed the AppList"; 161 DCHECK_GT(index, 0) << " Items can not preceed the AppList";
162 DCHECK_LT(index, model_.item_count()) << "Index out of bounds"; 162 DCHECK_LT(index, model_.item_count()) << " Index out of bounds";
163 index = std::min(std::max(index, 1), model_.item_count() - 1); 163 index = std::min(std::max(index, 1), model_.item_count() - 1);
164 DCHECK_NE(current_index, index) << "The item is already at the given index"; 164 DCHECK_NE(current_index, index) << " The item is already at the given index";
165 if (current_index == index) 165 if (current_index == index)
166 return; 166 return;
167 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); 167 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true);
168 model_.Move(current_index, index); 168 model_.Move(current_index, index);
169 } 169 }
170 170
171 void ShelfController::UpdateShelfItem(const ShelfItem& item) { 171 void ShelfController::UpdateShelfItem(const ShelfItem& item) {
172 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << "Unexpected model sync"; 172 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << " Unexpected model sync";
173 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; 173 DCHECK(!applying_remote_shelf_model_changes_) << " Unexpected model change";
174 const int index = model_.ItemIndexByID(item.id); 174 const int index = model_.ItemIndexByID(item.id);
175 DCHECK_GE(index, 0) << "No item found with the given id"; 175 DCHECK_GE(index, 0) << " No item found with the id: " << item.id;
176 if (index < 0) 176 if (index < 0)
177 return; 177 return;
178 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); 178 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true);
179 model_.Set(index, item); 179 model_.Set(index, item);
180 } 180 }
181 181
182 void ShelfController::SetShelfItemDelegate( 182 void ShelfController::SetShelfItemDelegate(
183 const ShelfID& id, 183 const ShelfID& id,
184 mojom::ShelfItemDelegatePtr delegate) { 184 mojom::ShelfItemDelegatePtr delegate) {
185 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << "Unexpected model sync"; 185 DCHECK_EQ(Shell::GetAshConfig(), Config::MASH) << " Unexpected model sync";
186 DCHECK(!applying_remote_shelf_model_changes_) << "Unexpected model change"; 186 DCHECK(!applying_remote_shelf_model_changes_) << " Unexpected model change";
187 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true); 187 base::AutoReset<bool> reset(&applying_remote_shelf_model_changes_, true);
188 if (delegate.is_bound()) 188 if (delegate.is_bound())
189 model_.SetShelfItemDelegate( 189 model_.SetShelfItemDelegate(
190 id, base::MakeUnique<RemoteShelfItemDelegate>(id, std::move(delegate))); 190 id, base::MakeUnique<RemoteShelfItemDelegate>(id, std::move(delegate)));
191 else 191 else
192 model_.SetShelfItemDelegate(id, nullptr); 192 model_.SetShelfItemDelegate(id, nullptr);
193 } 193 }
194 194
195 void ShelfController::ShelfItemAdded(int index) { 195 void ShelfController::ShelfItemAdded(int index) {
196 if (applying_remote_shelf_model_changes_ || 196 if (applying_remote_shelf_model_changes_ ||
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 observers_.ForAllPtrs([id, delegate](mojom::ShelfObserver* observer) { 249 observers_.ForAllPtrs([id, delegate](mojom::ShelfObserver* observer) {
250 observer->OnShelfItemDelegateChanged( 250 observer->OnShelfItemDelegateChanged(
251 id, delegate ? delegate->CreateInterfacePtrAndBind() 251 id, delegate ? delegate->CreateInterfacePtrAndBind()
252 : mojom::ShelfItemDelegatePtr()); 252 : mojom::ShelfItemDelegatePtr());
253 }); 253 });
254 } 254 }
255 255
256 } // namespace ash 256 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/shelf/shelf_window_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698