Index: chrome/browser/extensions/extension_sync_service.cc |
diff --git a/chrome/browser/extensions/extension_sync_service.cc b/chrome/browser/extensions/extension_sync_service.cc |
index 90f679f66343d434af13c17359b6d2c6eb5381db..494af8188d1a7380a9b524c27011979631aa6db5 100644 |
--- a/chrome/browser/extensions/extension_sync_service.cc |
+++ b/chrome/browser/extensions/extension_sync_service.cc |
@@ -39,6 +39,11 @@ |
#include "sync/api/sync_error_factory.h" |
#include "ui/gfx/image/image_family.h" |
+#if defined(ENABLE_SUPERVISED_USERS) |
+#include "chrome/browser/supervised_user/supervised_user_service.h" |
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
+#endif |
+ |
using extensions::AppSyncData; |
using extensions::Extension; |
using extensions::ExtensionPrefs; |
@@ -81,6 +86,13 @@ ExtensionSyncData::OptionalBoolean GetAllowedOnAllUrlsOptionalBoolean( |
return ExtensionSyncData::BOOLEAN_UNSET; |
} |
+#if defined(ENABLE_SUPERVISED_USERS) |
+// Callback for SupervisedUserService::AddExtensionUpdateRequest. |
+void ExtensionUpdateRequestSent(const std::string& id, bool success) { |
+ LOG_IF(WARNING, !success) << "Failed sending update request for " << id; |
+} |
+#endif |
+ |
} // namespace |
ExtensionSyncService::ExtensionSyncService(Profile* profile, |
@@ -505,19 +517,46 @@ bool ExtensionSyncService::ProcessExtensionSyncDataHelper( |
return true; |
} |
+ int version_compare_result = extension ? |
+ extension->version()->CompareTo(extension_sync_data.version()) : 0; |
+ |
// Set user settings. |
if (extension_sync_data.enabled()) { |
+ DCHECK(!extension_sync_data.disable_reasons()); |
+ |
+#if defined(ENABLE_SUPERVISED_USERS) |
+ if (extension && |
+ extensions::util::IsExtensionSupervised(extension, profile_) && |
+ !ExtensionRegistry::Get(profile_)->enabled_extensions().Contains(id)) { |
+ if (version_compare_result < 0) { |
+ // The installed version is outdated. Defer applying the change until |
+ // it's up-to-date. |
+ return false; |
Marc Treib
2015/06/22 15:35:18
Actually, I think the same behavior should apply t
not at google - send to devlin
2015/06/22 21:03:10
I agree this isn't necessarily supervised-user spe
Marc Treib
2015/06/23 10:22:25
But the extension update could have arrived first,
not at google - send to devlin
2015/06/24 00:25:11
Ok, right. I think it only makes sense for supervi
Marc Treib
2015/06/24 11:50:57
I still think the same thing can happen for regula
not at google - send to devlin
2015/06/24 20:47:38
Nit: it's omaha not the webstore.
Also the situat
|
+ } |
+ if (version_compare_result > 0) { |
+ // The installed version is newer than what Sync tells us to re-enable. |
+ // This means another update has happened since the custodian approved |
+ // the re-enable. We can't be sure if there are new permissions that the |
+ // custodian hasn't seen, so ignore the re-enable. Instead send another |
+ // re-enable request to the custodian. |
not at google - send to devlin
2015/06/24 00:25:10
Is this actually necessary? I would have expected
Marc Treib
2015/06/24 11:50:57
Hm, I'd need to remove the "don't send duplicate p
not at google - send to devlin
2015/06/24 20:47:38
Mm I don't understand why you'd need to remove tha
Marc Treib
2015/06/29 09:52:49
Wait, rolling back extensions isn't possible anywa
not at google - send to devlin
2015/06/29 22:59:04
Yes, I just meant the case when an update from syn
Marc Treib
2015/06/30 08:32:37
I'm totally happy to do this for all users, and ha
|
+ SupervisedUserService* supervised_user_service = |
+ SupervisedUserServiceFactory::GetForProfile(profile_); |
+ supervised_user_service->AddExtensionUpdateRequest( |
+ id, *extension->version(), |
+ base::Bind(ExtensionUpdateRequestSent, id)); |
+ return true; |
+ } |
+ } |
+#endif |
// Only grant permissions if the sync data explicitly sets the disable |
// reasons to Extension::DISABLE_NONE (as opposed to the legacy (<M45) case |
// where they're not set at all), and if the version from sync matches our |
// local one. Otherwise we just enable it without granting permissions. If |
// any permissions are missing, CheckPermissionsIncrease will soon disable |
// it again. |
- DCHECK(!extension_sync_data.disable_reasons()); |
bool grant_permissions = |
extension_sync_data.supports_disable_reasons() && |
- extension && |
- extension->version()->Equals(extension_sync_data.version()); |
+ extension && (version_compare_result == 0); |
if (grant_permissions) |
extension_service_->GrantPermissionsAndEnableExtension(extension); |
else |
@@ -545,12 +584,9 @@ bool ExtensionSyncService::ProcessExtensionSyncDataHelper( |
extension_service_->DisableExtension(id, disable_reasons); |
} |
- // We need to cache some version information here because setting the |
- // incognito flag invalidates the |extension| pointer (it reloads the |
- // extension). |
+ // We need to cache some information here because setting the incognito flag |
+ // invalidates the |extension| pointer (it reloads the extension). |
bool extension_installed = (extension != NULL); |
- int version_compare_result = extension ? |
- extension->version()->CompareTo(extension_sync_data.version()) : 0; |
// If the target extension has already been installed ephemerally, it can |
// be promoted to a regular installed extension and downloading from the Web |