OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/extension_sync_service.h" | 5 #include "chrome/browser/extensions/extension_sync_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/extensions/bookmark_app_helper.h" | 11 #include "chrome/browser/extensions/bookmark_app_helper.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_sync_data.h" | 13 #include "chrome/browser/extensions/extension_sync_data.h" |
14 #include "chrome/browser/extensions/extension_sync_service_factory.h" | 14 #include "chrome/browser/extensions/extension_sync_service_factory.h" |
15 #include "chrome/browser/extensions/extension_util.h" | 15 #include "chrome/browser/extensions/extension_util.h" |
16 #include "chrome/browser/extensions/launch_util.h" | 16 #include "chrome/browser/extensions/launch_util.h" |
17 #include "chrome/browser/extensions/scripting_permissions_modifier.h" | 17 #include "chrome/browser/extensions/scripting_permissions_modifier.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/sync/glue/sync_start_util.h" | 19 #include "chrome/browser/sync/glue/sync_start_util.h" |
20 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
21 #include "chrome/common/extensions/sync_helper.h" | 21 #include "chrome/common/extensions/sync_helper.h" |
| 22 #include "chrome/common/features.h" |
22 #include "chrome/common/web_application_info.h" | 23 #include "chrome/common/web_application_info.h" |
23 #include "components/sync/model/sync_change.h" | 24 #include "components/sync/model/sync_change.h" |
24 #include "components/sync/model/sync_error_factory.h" | 25 #include "components/sync/model/sync_error_factory.h" |
25 #include "extensions/browser/app_sorting.h" | 26 #include "extensions/browser/app_sorting.h" |
26 #include "extensions/browser/extension_prefs.h" | 27 #include "extensions/browser/extension_prefs.h" |
27 #include "extensions/browser/extension_registry.h" | 28 #include "extensions/browser/extension_registry.h" |
28 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
29 #include "extensions/browser/extension_util.h" | 30 #include "extensions/browser/extension_util.h" |
30 #include "extensions/browser/uninstall_reason.h" | 31 #include "extensions/browser/uninstall_reason.h" |
31 #include "extensions/common/extension.h" | 32 #include "extensions/common/extension.h" |
32 #include "extensions/common/extension_set.h" | 33 #include "extensions/common/extension_set.h" |
33 #include "extensions/common/image_util.h" | 34 #include "extensions/common/image_util.h" |
34 #include "extensions/common/permissions/permission_message_provider.h" | 35 #include "extensions/common/permissions/permission_message_provider.h" |
35 #include "extensions/common/permissions/permissions_data.h" | 36 #include "extensions/common/permissions/permissions_data.h" |
36 | 37 |
37 #if defined(ENABLE_SUPERVISED_USERS) | 38 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
38 #include "chrome/browser/supervised_user/supervised_user_service.h" | 39 #include "chrome/browser/supervised_user/supervised_user_service.h" |
39 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 40 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
40 #endif | 41 #endif |
41 | 42 |
42 using extensions::AppSorting; | 43 using extensions::AppSorting; |
43 using extensions::Extension; | 44 using extensions::Extension; |
44 using extensions::ExtensionPrefs; | 45 using extensions::ExtensionPrefs; |
45 using extensions::ExtensionRegistry; | 46 using extensions::ExtensionRegistry; |
46 using extensions::ExtensionSet; | 47 using extensions::ExtensionSet; |
47 using extensions::ExtensionSyncData; | 48 using extensions::ExtensionSyncData; |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 grant_permissions || | 436 grant_permissions || |
436 !extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease( | 437 !extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease( |
437 *extension_prefs->GetGrantedPermissions(id), | 438 *extension_prefs->GetGrantedPermissions(id), |
438 extension->permissions_data()->active_permissions(), | 439 extension->permissions_data()->active_permissions(), |
439 extension->GetType()); | 440 extension->GetType()); |
440 if (has_all_permissions) | 441 if (has_all_permissions) |
441 extension_service()->EnableExtension(id); | 442 extension_service()->EnableExtension(id); |
442 else if (extension_sync_data.supports_disable_reasons()) | 443 else if (extension_sync_data.supports_disable_reasons()) |
443 reenable_after_update = true; | 444 reenable_after_update = true; |
444 | 445 |
445 #if defined(ENABLE_SUPERVISED_USERS) | 446 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
446 if (!has_all_permissions && (state == INSTALLED_NEWER) && | 447 if (!has_all_permissions && (state == INSTALLED_NEWER) && |
447 extensions::util::IsExtensionSupervised(extension, profile_)) { | 448 extensions::util::IsExtensionSupervised(extension, profile_)) { |
448 SupervisedUserServiceFactory::GetForProfile(profile_) | 449 SupervisedUserServiceFactory::GetForProfile(profile_) |
449 ->AddExtensionUpdateRequest(id, *extension->version()); | 450 ->AddExtensionUpdateRequest(id, *extension->version()); |
450 } | 451 } |
451 #endif | 452 #endif |
452 } else { | 453 } else { |
453 // The extension is not installed yet. Set it to enabled; we'll check for | 454 // The extension is not installed yet. Set it to enabled; we'll check for |
454 // permission increase (more accurately, for a version change) when it's | 455 // permission increase (more accurately, for a version change) when it's |
455 // actually installed. | 456 // actually installed. |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 sync_data_list->push_back(CreateSyncData(*extension)); | 714 sync_data_list->push_back(CreateSyncData(*extension)); |
714 } | 715 } |
715 } | 716 } |
716 } | 717 } |
717 | 718 |
718 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { | 719 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { |
719 // Themes are handled by the ThemeSyncableService. | 720 // Themes are handled by the ThemeSyncableService. |
720 return extensions::util::ShouldSync(&extension, profile_) && | 721 return extensions::util::ShouldSync(&extension, profile_) && |
721 !extension.is_theme(); | 722 !extension.is_theme(); |
722 } | 723 } |
OLD | NEW |