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/background/background_application_list_model.h" | 5 #include "chrome/browser/background/background_application_list_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/background/background_contents_service.h" | 13 #include "chrome/browser/background/background_contents_service.h" |
14 #include "chrome/browser/background/background_contents_service_factory.h" | 14 #include "chrome/browser/background/background_contents_service_factory.h" |
15 #include "chrome/browser/background/background_mode_manager.h" | 15 #include "chrome/browser/background/background_mode_manager.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/extensions/extension_prefs.h" | 17 #include "chrome/browser/extensions/extension_prefs.h" |
18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
19 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" |
20 #include "chrome/browser/extensions/image_loader.h" | 20 #include "chrome/browser/extensions/image_loader.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 23 #include "chrome/common/extensions/background_info.h" |
23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
25 #include "chrome/common/extensions/extension_icon_set.h" | 26 #include "chrome/common/extensions/extension_icon_set.h" |
26 #include "chrome/common/extensions/extension_resource.h" | 27 #include "chrome/common/extensions/extension_resource.h" |
27 #include "chrome/common/extensions/permissions/permission_set.h" | 28 #include "chrome/common/extensions/permissions/permission_set.h" |
28 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
29 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
30 #include "ui/base/l10n/l10n_util_collator.h" | 31 #include "ui/base/l10n/l10n_util_collator.h" |
31 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
32 #include "ui/gfx/image/image_skia.h" | 33 #include "ui/gfx/image/image_skia.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 if (!extension.HasAPIPermission(APIPermission::kBackground) && | 280 if (!extension.HasAPIPermission(APIPermission::kBackground) && |
280 !extension.HasAPIPermission(APIPermission::kPushMessaging) ) | 281 !extension.HasAPIPermission(APIPermission::kPushMessaging) ) |
281 return false; | 282 return false; |
282 | 283 |
283 // Extensions and packaged apps with background permission are always treated | 284 // Extensions and packaged apps with background permission are always treated |
284 // as background apps. | 285 // as background apps. |
285 if (!extension.is_hosted_app()) | 286 if (!extension.is_hosted_app()) |
286 return true; | 287 return true; |
287 | 288 |
288 // Hosted apps with manifest-provided background pages are background apps. | 289 // Hosted apps with manifest-provided background pages are background apps. |
289 if (extension.has_background_page()) | 290 if (extensions::BackgroundInfo::HasBackgroundPage(&extension)) |
290 return true; | 291 return true; |
291 | 292 |
292 BackgroundContentsService* service = | 293 BackgroundContentsService* service = |
293 BackgroundContentsServiceFactory::GetForProfile(profile); | 294 BackgroundContentsServiceFactory::GetForProfile(profile); |
294 string16 app_id = ASCIIToUTF16(extension.id()); | 295 string16 app_id = ASCIIToUTF16(extension.id()); |
295 // If we have an active or registered background contents for this app, then | 296 // If we have an active or registered background contents for this app, then |
296 // it's a background app. This covers the cases where the app has created its | 297 // it's a background app. This covers the cases where the app has created its |
297 // background contents, but it hasn't navigated yet, or the background | 298 // background contents, but it hasn't navigated yet, or the background |
298 // contents crashed and hasn't yet been restarted - in both cases we still | 299 // contents crashed and hasn't yet been restarted - in both cases we still |
299 // want to treat the app as a background app. | 300 // want to treat the app as a background app. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 (*old_cursor)->name() == (*new_cursor)->name() && | 409 (*old_cursor)->name() == (*new_cursor)->name() && |
409 (*old_cursor)->id() == (*new_cursor)->id()) { | 410 (*old_cursor)->id() == (*new_cursor)->id()) { |
410 ++old_cursor; | 411 ++old_cursor; |
411 ++new_cursor; | 412 ++new_cursor; |
412 } | 413 } |
413 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 414 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
414 extensions_ = extensions; | 415 extensions_ = extensions; |
415 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 416 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); |
416 } | 417 } |
417 } | 418 } |
OLD | NEW |