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 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" | 5 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 (*app)->is_platform_app())); | 153 (*app)->is_platform_app())); |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 void ExtensionAppModelBuilder::SwitchProfile(Profile* profile) { | 157 void ExtensionAppModelBuilder::SwitchProfile(Profile* profile) { |
158 if (profile_ == profile) | 158 if (profile_ == profile) |
159 return; | 159 return; |
160 profile_ = profile; | 160 profile_ = profile; |
161 | 161 |
162 // Delete any extension apps. | 162 // Delete any extension apps. |
163 app_list::AppListModel::Apps* app_list = model_->apps(); | 163 for (int p = static_cast<int>(model_->GetNumAppPages()) - 1; p >= 0; --p) { |
164 for (int i = static_cast<int>(app_list->item_count()) - 1; i >= 0; --i) { | 164 const app_list::AppListModel::AppItems& app_list = |
165 app_list::AppListItemModel* item = app_list->GetItemAt(i); | 165 model_->GetAppItemsForPage(p); |
166 if (item->GetAppType() == ExtensionAppItem::kAppType) | 166 for (int i = static_cast<int>(app_list.item_count()) - 1; i >= 0; --i) { |
167 app_list->DeleteAt(i); | 167 const app_list::AppListItemModel* item = app_list.GetItemAt(i); |
| 168 if (item->GetAppType() == ExtensionAppItem::kAppType) |
| 169 model_->DeleteItemAt(p, i); |
| 170 } |
168 } | 171 } |
169 | 172 |
170 if (tracker_) | 173 if (tracker_) |
171 tracker_->RemoveObserver(this); | 174 tracker_->RemoveObserver(this); |
172 | 175 |
173 if (extensions::ExtensionSystem::Get(profile_)->extension_service()) | 176 if (extensions::ExtensionSystem::Get(profile_)->extension_service()) |
174 tracker_ = extensions::InstallTrackerFactory::GetForProfile(profile_); | 177 tracker_ = extensions::InstallTrackerFactory::GetForProfile(profile_); |
175 else | 178 else |
176 tracker_ = NULL; | 179 tracker_ = NULL; |
177 | 180 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 void ExtensionAppModelBuilder::UpdateHighlight() { | 235 void ExtensionAppModelBuilder::UpdateHighlight() { |
233 DCHECK(model_); | 236 DCHECK(model_); |
234 if (!highlighted_app_pending_ || highlight_app_id_.empty()) | 237 if (!highlighted_app_pending_ || highlight_app_id_.empty()) |
235 return; | 238 return; |
236 ExtensionAppItem* item = GetExtensionAppItem(highlight_app_id_); | 239 ExtensionAppItem* item = GetExtensionAppItem(highlight_app_id_); |
237 if (!item) | 240 if (!item) |
238 return; | 241 return; |
239 item->SetHighlighted(true); | 242 item->SetHighlighted(true); |
240 highlighted_app_pending_ = false; | 243 highlighted_app_pending_ = false; |
241 } | 244 } |
OLD | NEW |