OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/background_application_list_model.h" | 5 #include "chrome/browser/background_application_list_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "app/l10n_util_collator.h" | 10 #include "app/l10n_util_collator.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 BackgroundApplicationListModel::BackgroundApplicationListModel(Profile* profile) | 146 BackgroundApplicationListModel::BackgroundApplicationListModel(Profile* profile) |
147 : profile_(profile) { | 147 : profile_(profile) { |
148 DCHECK(profile_); | 148 DCHECK(profile_); |
149 registrar_.Add(this, | 149 registrar_.Add(this, |
150 NotificationType::EXTENSION_LOADED, | 150 NotificationType::EXTENSION_LOADED, |
151 Source<Profile>(profile)); | 151 Source<Profile>(profile)); |
152 registrar_.Add(this, | 152 registrar_.Add(this, |
153 NotificationType::EXTENSION_UNLOADED, | 153 NotificationType::EXTENSION_UNLOADED, |
154 Source<Profile>(profile)); | 154 Source<Profile>(profile)); |
155 registrar_.Add(this, | 155 registrar_.Add(this, |
156 NotificationType::EXTENSION_UNLOADED_DISABLED, | |
157 Source<Profile>(profile)); | |
158 registrar_.Add(this, | |
159 NotificationType::EXTENSIONS_READY, | 156 NotificationType::EXTENSIONS_READY, |
160 Source<Profile>(profile)); | 157 Source<Profile>(profile)); |
161 ExtensionService* service = profile->GetExtensionService(); | 158 ExtensionService* service = profile->GetExtensionService(); |
162 if (service && service->is_ready()) | 159 if (service && service->is_ready()) |
163 Update(); | 160 Update(); |
164 } | 161 } |
165 | 162 |
166 void BackgroundApplicationListModel::AddObserver(Observer* observer) { | 163 void BackgroundApplicationListModel::AddObserver(Observer* observer) { |
167 observers_.AddObserver(observer); | 164 observers_.AddObserver(observer); |
168 } | 165 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 251 } |
255 ExtensionService* service = profile_->GetExtensionService(); | 252 ExtensionService* service = profile_->GetExtensionService(); |
256 if (!service || !service->is_ready()) | 253 if (!service || !service->is_ready()) |
257 return; | 254 return; |
258 | 255 |
259 switch (type.value) { | 256 switch (type.value) { |
260 case NotificationType::EXTENSION_LOADED: | 257 case NotificationType::EXTENSION_LOADED: |
261 OnExtensionLoaded(Details<Extension>(details).ptr()); | 258 OnExtensionLoaded(Details<Extension>(details).ptr()); |
262 break; | 259 break; |
263 case NotificationType::EXTENSION_UNLOADED: | 260 case NotificationType::EXTENSION_UNLOADED: |
264 // Handle extension unload uniformly, falling through to next case. | 261 OnExtensionUnloaded(Details<UnloadedExtensionInfo>(details)->extension); |
265 case NotificationType::EXTENSION_UNLOADED_DISABLED: | |
266 OnExtensionUnloaded(Details<Extension>(details).ptr()); | |
267 break; | 262 break; |
268 default: | 263 default: |
269 NOTREACHED() << "Received unexpected notification"; | 264 NOTREACHED() << "Received unexpected notification"; |
270 } | 265 } |
271 } | 266 } |
272 | 267 |
273 void BackgroundApplicationListModel::OnApplicationDataChanged( | 268 void BackgroundApplicationListModel::OnApplicationDataChanged( |
274 const Extension* extension) { | 269 const Extension* extension) { |
275 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension)); | 270 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationDataChanged(extension)); |
276 } | 271 } |
277 | 272 |
278 void BackgroundApplicationListModel::OnExtensionLoaded(Extension* extension) { | 273 void BackgroundApplicationListModel::OnExtensionLoaded(Extension* extension) { |
279 // We only care about extensions that are background applications | 274 // We only care about extensions that are background applications |
280 if (!IsBackgroundApp(*extension)) | 275 if (!IsBackgroundApp(*extension)) |
281 return; | 276 return; |
282 AssociateApplicationData(extension); | 277 AssociateApplicationData(extension); |
283 Update(); | 278 Update(); |
284 } | 279 } |
285 | 280 |
286 void BackgroundApplicationListModel::OnExtensionUnloaded(Extension* extension) { | 281 void BackgroundApplicationListModel::OnExtensionUnloaded( |
| 282 const Extension* extension) { |
287 if (!IsBackgroundApp(*extension)) | 283 if (!IsBackgroundApp(*extension)) |
288 return; | 284 return; |
289 Update(); | 285 Update(); |
290 DissociateApplicationData(extension); | 286 DissociateApplicationData(extension); |
291 } | 287 } |
292 | 288 |
293 void BackgroundApplicationListModel::RemoveObserver(Observer* observer) { | 289 void BackgroundApplicationListModel::RemoveObserver(Observer* observer) { |
294 observers_.RemoveObserver(observer); | 290 observers_.RemoveObserver(observer); |
295 } | 291 } |
296 | 292 |
(...skipping 15 matching lines...) Expand all Loading... |
312 (*old_cursor)->name() == (*new_cursor)->name() && | 308 (*old_cursor)->name() == (*new_cursor)->name() && |
313 (*old_cursor)->id() == (*new_cursor)->id()) { | 309 (*old_cursor)->id() == (*new_cursor)->id()) { |
314 ++old_cursor; | 310 ++old_cursor; |
315 ++new_cursor; | 311 ++new_cursor; |
316 } | 312 } |
317 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 313 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
318 extensions_ = extensions; | 314 extensions_ = extensions; |
319 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged()); | 315 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged()); |
320 } | 316 } |
321 } | 317 } |
OLD | NEW |