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

Side by Side Diff: chrome/browser/background_application_list_model.cc

Issue 5730004: Rename ExtensionsService to ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 10 years 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 | Annotate | Revision Log
OLDNEW
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 8
9 #include "app/l10n_util_collator.h" 9 #include "app/l10n_util_collator.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/background_mode_manager.h" 12 #include "chrome/browser/background_mode_manager.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/extension_prefs.h" 14 #include "chrome/browser/extensions/extension_prefs.h"
15 #include "chrome/browser/extensions/extensions_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/image_loading_tracker.h" 16 #include "chrome/browser/extensions/image_loading_tracker.h"
17 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_resource.h" 20 #include "chrome/common/extensions/extension_resource.h"
21 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 23
24 class ExtensionNameComparator { 24 class ExtensionNameComparator {
25 public: 25 public:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // appropriately. 60 // appropriately.
61 void RequestIcon(Extension::Icons size); 61 void RequestIcon(Extension::Icons size);
62 62
63 const Extension* extension_; 63 const Extension* extension_;
64 scoped_ptr<SkBitmap> icon_; 64 scoped_ptr<SkBitmap> icon_;
65 BackgroundApplicationListModel* model_; 65 BackgroundApplicationListModel* model_;
66 ImageLoadingTracker tracker_; 66 ImageLoadingTracker tracker_;
67 }; 67 };
68 68
69 namespace { 69 namespace {
70 void GetServiceApplications(ExtensionsService* service, 70 void GetServiceApplications(ExtensionService* service,
71 ExtensionList* applications_result) { 71 ExtensionList* applications_result) {
72 const ExtensionList* extensions = service->extensions(); 72 const ExtensionList* extensions = service->extensions();
73 73
74 for (ExtensionList::const_iterator cursor = extensions->begin(); 74 for (ExtensionList::const_iterator cursor = extensions->begin();
75 cursor != extensions->end(); 75 cursor != extensions->end();
76 ++cursor) { 76 ++cursor) {
77 const Extension* extension = *cursor; 77 const Extension* extension = *cursor;
78 if (BackgroundApplicationListModel::IsBackgroundApp(*extension)) 78 if (BackgroundApplicationListModel::IsBackgroundApp(*extension))
79 applications_result->push_back(extension); 79 applications_result->push_back(extension);
80 } 80 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 void BackgroundApplicationListModel::Observe( 234 void BackgroundApplicationListModel::Observe(
235 NotificationType type, 235 NotificationType type,
236 const NotificationSource& source, 236 const NotificationSource& source,
237 const NotificationDetails& details) { 237 const NotificationDetails& details) {
238 if (type == NotificationType::EXTENSIONS_READY) { 238 if (type == NotificationType::EXTENSIONS_READY) {
239 Update(); 239 Update();
240 return; 240 return;
241 } 241 }
242 ExtensionsService* service = profile_->GetExtensionsService(); 242 ExtensionService* service = profile_->GetExtensionService();
243 if (!service || !service->is_ready()) 243 if (!service || !service->is_ready())
244 return; 244 return;
245 245
246 switch (type.value) { 246 switch (type.value) {
247 case NotificationType::EXTENSION_LOADED: 247 case NotificationType::EXTENSION_LOADED:
248 OnExtensionLoaded(Details<Extension>(details).ptr()); 248 OnExtensionLoaded(Details<Extension>(details).ptr());
249 break; 249 break;
250 case NotificationType::EXTENSION_UNLOADED: 250 case NotificationType::EXTENSION_UNLOADED:
251 // Handle extension unload uniformly, falling through to next case. 251 // Handle extension unload uniformly, falling through to next case.
252 case NotificationType::EXTENSION_UNLOADED_DISABLED: 252 case NotificationType::EXTENSION_UNLOADED_DISABLED:
(...skipping 26 matching lines...) Expand all
279 279
280 void BackgroundApplicationListModel::RemoveObserver(Observer* observer) { 280 void BackgroundApplicationListModel::RemoveObserver(Observer* observer) {
281 observers_.RemoveObserver(observer); 281 observers_.RemoveObserver(observer);
282 } 282 }
283 283
284 // Update queries the extensions service of the profile with which the model was 284 // Update queries the extensions service of the profile with which the model was
285 // initialized to determine the current set of background applications. If that 285 // initialized to determine the current set of background applications. If that
286 // differs from the old list, it generates OnApplicationListChanged events for 286 // differs from the old list, it generates OnApplicationListChanged events for
287 // each observer. 287 // each observer.
288 void BackgroundApplicationListModel::Update() { 288 void BackgroundApplicationListModel::Update() {
289 ExtensionsService* service = profile_->GetExtensionsService(); 289 ExtensionService* service = profile_->GetExtensionService();
290 290
291 // Discover current background applications, compare with previous list, which 291 // Discover current background applications, compare with previous list, which
292 // is consistently sorted, and notify observers if they differ. 292 // is consistently sorted, and notify observers if they differ.
293 ExtensionList extensions; 293 ExtensionList extensions;
294 GetServiceApplications(service, &extensions); 294 GetServiceApplications(service, &extensions);
295 ExtensionList::const_iterator old_cursor = extensions_.begin(); 295 ExtensionList::const_iterator old_cursor = extensions_.begin();
296 ExtensionList::const_iterator new_cursor = extensions.begin(); 296 ExtensionList::const_iterator new_cursor = extensions.begin();
297 while (old_cursor != extensions_.end() && 297 while (old_cursor != extensions_.end() &&
298 new_cursor != extensions.end() && 298 new_cursor != extensions.end() &&
299 (*old_cursor)->name() == (*new_cursor)->name() && 299 (*old_cursor)->name() == (*new_cursor)->name() &&
300 (*old_cursor)->id() == (*new_cursor)->id()) { 300 (*old_cursor)->id() == (*new_cursor)->id()) {
301 ++old_cursor; 301 ++old_cursor;
302 ++new_cursor; 302 ++new_cursor;
303 } 303 }
304 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { 304 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) {
305 extensions_ = extensions; 305 extensions_ = extensions;
306 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged()); 306 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged());
307 } 307 }
308 } 308 }
OLDNEW
« no previous file with comments | « chrome/browser/background_application_list_model.h ('k') | chrome/browser/background_contents_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698