Chromium Code Reviews| 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" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "extensions/browser/uninstall_reason.h" | 27 #include "extensions/browser/uninstall_reason.h" |
| 28 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 29 #include "extensions/common/extension_set.h" | 29 #include "extensions/common/extension_set.h" |
| 30 #include "extensions/common/image_util.h" | 30 #include "extensions/common/image_util.h" |
| 31 #include "extensions/common/permissions/permission_message_provider.h" | 31 #include "extensions/common/permissions/permission_message_provider.h" |
| 32 #include "extensions/common/permissions/permissions_data.h" | 32 #include "extensions/common/permissions/permissions_data.h" |
| 33 #include "sync/api/sync_change.h" | 33 #include "sync/api/sync_change.h" |
| 34 #include "sync/api/sync_error_factory.h" | 34 #include "sync/api/sync_error_factory.h" |
| 35 | 35 |
| 36 #if defined(ENABLE_SUPERVISED_USERS) | 36 #if defined(ENABLE_SUPERVISED_USERS) |
| 37 #include "chrome/browser/extensions/extension_util.h" | |
| 37 #include "chrome/browser/supervised_user/supervised_user_service.h" | 38 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 38 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 39 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 using extensions::AppSorting; | 42 using extensions::AppSorting; |
| 42 using extensions::Extension; | 43 using extensions::Extension; |
| 43 using extensions::ExtensionPrefs; | 44 using extensions::ExtensionPrefs; |
| 44 using extensions::ExtensionRegistry; | 45 using extensions::ExtensionRegistry; |
| 45 using extensions::ExtensionSet; | 46 using extensions::ExtensionSet; |
| 46 using extensions::ExtensionSyncData; | 47 using extensions::ExtensionSyncData; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 } | 309 } |
| 309 return result; | 310 return result; |
| 310 } | 311 } |
| 311 | 312 |
| 312 void ExtensionSyncService::ApplySyncData( | 313 void ExtensionSyncService::ApplySyncData( |
| 313 const ExtensionSyncData& extension_sync_data) { | 314 const ExtensionSyncData& extension_sync_data) { |
| 314 // Ignore any pref change notifications etc. while we're applying incoming | 315 // Ignore any pref change notifications etc. while we're applying incoming |
| 315 // sync data, so that we don't end up notifying ourselves. | 316 // sync data, so that we don't end up notifying ourselves. |
| 316 base::AutoReset<bool> ignore_updates(&ignore_updates_, true); | 317 base::AutoReset<bool> ignore_updates(&ignore_updates_, true); |
| 317 | 318 |
| 319 if (extension_sync_data.installed_by_custodian()) { | |
| 320 extensions::util::SetWasInstalledByCustodian(extension_sync_data.id(), | |
| 321 profile_, true); | |
|
Devlin
2016/06/13 14:36:58
nit: indentation
mamir
2016/06/13 15:25:31
Done.
| |
| 322 } | |
| 323 | |
| 318 syncer::ModelType type = extension_sync_data.is_app() ? syncer::APPS | 324 syncer::ModelType type = extension_sync_data.is_app() ? syncer::APPS |
| 319 : syncer::EXTENSIONS; | 325 : syncer::EXTENSIONS; |
| 320 const std::string& id = extension_sync_data.id(); | 326 const std::string& id = extension_sync_data.id(); |
| 321 SyncBundle* bundle = GetSyncBundle(type); | 327 SyncBundle* bundle = GetSyncBundle(type); |
| 322 DCHECK(bundle->IsSyncing()); | 328 DCHECK(bundle->IsSyncing()); |
| 323 // Note: |extension| may be null if it hasn't been installed yet. | 329 // Note: |extension| may be null if it hasn't been installed yet. |
| 324 const Extension* extension = | 330 const Extension* extension = |
| 325 ExtensionRegistry::Get(profile_)->GetInstalledExtension(id); | 331 ExtensionRegistry::Get(profile_)->GetInstalledExtension(id); |
| 326 if (extension && !IsCorrectSyncType(*extension, type)) { | 332 if (extension && !IsCorrectSyncType(*extension, type)) { |
| 327 // The installed item isn't the same type as the sync data item, so we need | 333 // The installed item isn't the same type as the sync data item, so we need |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 // If the extension is installed but outdated, store the new version. | 502 // If the extension is installed but outdated, store the new version. |
| 497 pending_updates_[id] = | 503 pending_updates_[id] = |
| 498 PendingUpdate(extension_sync_data.version(), reenable_after_update); | 504 PendingUpdate(extension_sync_data.version(), reenable_after_update); |
| 499 check_for_updates = true; | 505 check_for_updates = true; |
| 500 } else if (state == NOT_INSTALLED) { | 506 } else if (state == NOT_INSTALLED) { |
| 501 if (!extension_service()->pending_extension_manager()->AddFromSync( | 507 if (!extension_service()->pending_extension_manager()->AddFromSync( |
| 502 id, | 508 id, |
| 503 extension_sync_data.update_url(), | 509 extension_sync_data.update_url(), |
| 504 extension_sync_data.version(), | 510 extension_sync_data.version(), |
| 505 ShouldAllowInstall, | 511 ShouldAllowInstall, |
| 506 extension_sync_data.remote_install(), | 512 extension_sync_data.remote_install())) { |
| 507 extension_sync_data.installed_by_custodian())) { | |
| 508 LOG(WARNING) << "Could not add pending extension for " << id; | 513 LOG(WARNING) << "Could not add pending extension for " << id; |
| 509 // This means that the extension is already pending installation, with a | 514 // This means that the extension is already pending installation, with a |
| 510 // non-INTERNAL location. Add to pending_sync_data, even though it will | 515 // non-INTERNAL location. Add to pending_sync_data, even though it will |
| 511 // never be removed (we'll never install a syncable version of the | 516 // never be removed (we'll never install a syncable version of the |
| 512 // extension), so that GetAllSyncData() continues to send it. | 517 // extension), so that GetAllSyncData() continues to send it. |
| 513 } | 518 } |
| 514 // Track pending extensions so that we can return them in GetAllSyncData(). | 519 // Track pending extensions so that we can return them in GetAllSyncData(). |
| 515 bundle->AddPendingExtensionData(extension_sync_data); | 520 bundle->AddPendingExtensionData(extension_sync_data); |
| 516 check_for_updates = true; | 521 check_for_updates = true; |
| 517 } | 522 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 sync_data_list->push_back(CreateSyncData(*extension)); | 708 sync_data_list->push_back(CreateSyncData(*extension)); |
| 704 } | 709 } |
| 705 } | 710 } |
| 706 } | 711 } |
| 707 | 712 |
| 708 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { | 713 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { |
| 709 // Themes are handled by the ThemeSyncableService. | 714 // Themes are handled by the ThemeSyncableService. |
| 710 return extensions::util::ShouldSync(&extension, profile_) && | 715 return extensions::util::ShouldSync(&extension, profile_) && |
| 711 !extension.is_theme(); | 716 !extension.is_theme(); |
| 712 } | 717 } |
| OLD | NEW |