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