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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 // 2) It is a hosted app, and has a background contents registered or in the | 308 // 2) It is a hosted app, and has a background contents registered or in the |
308 // manifest. | 309 // manifest. |
309 | 310 |
310 // Not a background app if we don't have the background permission or | 311 // Not a background app if we don't have the background permission or |
311 // the push messaging permission | 312 // the push messaging permission |
312 if (!extension.permissions_data()->HasAPIPermission( | 313 if (!extension.permissions_data()->HasAPIPermission( |
313 APIPermission::kBackground) && | 314 APIPermission::kBackground) && |
314 !RequiresBackgroundModeForPushMessaging(extension)) | 315 !RequiresBackgroundModeForPushMessaging(extension)) |
315 return false; | 316 return false; |
316 | 317 |
318 // By design, ephemeral apps cannot have background activity. This point can | |
319 // be reached for platforms apps with the push messaging permission, so | |
Dmitry Titov
2014/07/14 03:26:35
Also this can be reached by apps with "background'
tmdiep
2014/07/14 04:25:36
Thanks for the suggestion. I've moved the check up
| |
320 // disallow if the app is ephemeral. | |
321 if (extensions::util::IsEphemeralApp(extension.id(), profile)) | |
322 return false; | |
323 | |
317 // Extensions and packaged apps with background permission are always treated | 324 // Extensions and packaged apps with background permission are always treated |
318 // as background apps. | 325 // as background apps. |
319 if (!extension.is_hosted_app()) | 326 if (!extension.is_hosted_app()) |
320 return true; | 327 return true; |
321 | 328 |
322 // Hosted apps with manifest-provided background pages are background apps. | 329 // Hosted apps with manifest-provided background pages are background apps. |
323 if (extensions::BackgroundInfo::HasBackgroundPage(&extension)) | 330 if (extensions::BackgroundInfo::HasBackgroundPage(&extension)) |
324 return true; | 331 return true; |
325 | 332 |
326 BackgroundContentsService* service = | 333 BackgroundContentsService* service = |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 (*old_cursor)->name() == (*new_cursor)->name() && | 449 (*old_cursor)->name() == (*new_cursor)->name() && |
443 (*old_cursor)->id() == (*new_cursor)->id()) { | 450 (*old_cursor)->id() == (*new_cursor)->id()) { |
444 ++old_cursor; | 451 ++old_cursor; |
445 ++new_cursor; | 452 ++new_cursor; |
446 } | 453 } |
447 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 454 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
448 extensions_ = extensions; | 455 extensions_ = extensions; |
449 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 456 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); |
450 } | 457 } |
451 } | 458 } |
OLD | NEW |