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/sha1.h" | 10 #include "base/sha1.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/background/background_contents_service.h" | 15 #include "chrome/browser/background/background_contents_service.h" |
16 #include "chrome/browser/background/background_contents_service_factory.h" | 16 #include "chrome/browser/background/background_contents_service_factory.h" |
17 #include "chrome/browser/background/background_mode_manager.h" | 17 #include "chrome/browser/background/background_mode_manager.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
25 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
26 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
27 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
| 28 #include "extensions/browser/extension_util.h" |
28 #include "extensions/browser/image_loader.h" | 29 #include "extensions/browser/image_loader.h" |
29 #include "extensions/common/extension.h" | 30 #include "extensions/common/extension.h" |
30 #include "extensions/common/extension_icon_set.h" | 31 #include "extensions/common/extension_icon_set.h" |
31 #include "extensions/common/extension_resource.h" | 32 #include "extensions/common/extension_resource.h" |
32 #include "extensions/common/extension_set.h" | 33 #include "extensions/common/extension_set.h" |
33 #include "extensions/common/manifest_handlers/background_info.h" | 34 #include "extensions/common/manifest_handlers/background_info.h" |
34 #include "extensions/common/manifest_handlers/icons_handler.h" | 35 #include "extensions/common/manifest_handlers/icons_handler.h" |
35 #include "extensions/common/permissions/permission_set.h" | 36 #include "extensions/common/permissions/permission_set.h" |
36 #include "extensions/common/permissions/permissions_data.h" | 37 #include "extensions/common/permissions/permissions_data.h" |
37 #include "ui/base/l10n/l10n_util_collator.h" | 38 #include "ui/base/l10n/l10n_util_collator.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 304 |
304 // static | 305 // static |
305 bool BackgroundApplicationListModel::IsBackgroundApp( | 306 bool BackgroundApplicationListModel::IsBackgroundApp( |
306 const Extension& extension, Profile* profile) { | 307 const Extension& extension, Profile* profile) { |
307 // An extension is a "background app" if it has the "background API" | 308 // An extension is a "background app" if it has the "background API" |
308 // permission, and meets one of the following criteria: | 309 // permission, and meets one of the following criteria: |
309 // 1) It is an extension (not a hosted app). | 310 // 1) It is an extension (not a hosted app). |
310 // 2) It is a hosted app, and has a background contents registered or in the | 311 // 2) It is a hosted app, and has a background contents registered or in the |
311 // manifest. | 312 // manifest. |
312 | 313 |
| 314 // Ephemeral apps are denied any background activity after their event page |
| 315 // has been destroyed, thus they cannot be background apps. |
| 316 if (extensions::util::IsEphemeralApp(extension.id(), profile)) |
| 317 return false; |
| 318 |
313 // Not a background app if we don't have the background permission or | 319 // Not a background app if we don't have the background permission or |
314 // the push messaging permission | 320 // the push messaging permission |
315 if (!extension.permissions_data()->HasAPIPermission( | 321 if (!extension.permissions_data()->HasAPIPermission( |
316 APIPermission::kBackground) && | 322 APIPermission::kBackground) && |
317 !RequiresBackgroundModeForPushMessaging(extension)) | 323 !RequiresBackgroundModeForPushMessaging(extension)) |
318 return false; | 324 return false; |
319 | 325 |
320 // Extensions and packaged apps with background permission are always treated | 326 // Extensions and packaged apps with background permission are always treated |
321 // as background apps. | 327 // as background apps. |
322 if (!extension.is_hosted_app()) | 328 if (!extension.is_hosted_app()) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 (*old_cursor)->name() == (*new_cursor)->name() && | 452 (*old_cursor)->name() == (*new_cursor)->name() && |
447 (*old_cursor)->id() == (*new_cursor)->id()) { | 453 (*old_cursor)->id() == (*new_cursor)->id()) { |
448 ++old_cursor; | 454 ++old_cursor; |
449 ++new_cursor; | 455 ++new_cursor; |
450 } | 456 } |
451 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 457 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
452 extensions_ = extensions; | 458 extensions_ = extensions; |
453 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 459 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); |
454 } | 460 } |
455 } | 461 } |
OLD | NEW |