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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/bookmark_app_helper.h" | 9 #include "chrome/browser/extensions/bookmark_app_helper.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "extensions/browser/extension_util.h" | 24 #include "extensions/browser/extension_util.h" |
25 #include "extensions/browser/uninstall_reason.h" | 25 #include "extensions/browser/uninstall_reason.h" |
26 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
27 #include "extensions/common/extension_set.h" | 27 #include "extensions/common/extension_set.h" |
28 #include "extensions/common/image_util.h" | 28 #include "extensions/common/image_util.h" |
29 #include "extensions/common/permissions/permission_message_provider.h" | 29 #include "extensions/common/permissions/permission_message_provider.h" |
30 #include "extensions/common/permissions/permissions_data.h" | 30 #include "extensions/common/permissions/permissions_data.h" |
31 #include "sync/api/sync_change.h" | 31 #include "sync/api/sync_change.h" |
32 #include "sync/api/sync_error_factory.h" | 32 #include "sync/api/sync_error_factory.h" |
33 | 33 |
34 #if defined(ENABLE_SUPERVISED_USERS) | |
35 #include "chrome/browser/supervised_user/supervised_user_service.h" | |
36 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | |
37 #endif | |
38 | |
34 using extensions::AppSorting; | 39 using extensions::AppSorting; |
35 using extensions::Extension; | 40 using extensions::Extension; |
36 using extensions::ExtensionPrefs; | 41 using extensions::ExtensionPrefs; |
37 using extensions::ExtensionRegistry; | 42 using extensions::ExtensionRegistry; |
38 using extensions::ExtensionSet; | 43 using extensions::ExtensionSet; |
39 using extensions::ExtensionSyncData; | 44 using extensions::ExtensionSyncData; |
40 using extensions::ExtensionSystem; | 45 using extensions::ExtensionSystem; |
41 using extensions::SyncBundle; | 46 using extensions::SyncBundle; |
42 | 47 |
43 namespace { | 48 namespace { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 bundle->PushSyncAddOrUpdate(extension.id(), | 138 bundle->PushSyncAddOrUpdate(extension.id(), |
134 CreateSyncData(extension).GetSyncData()); | 139 CreateSyncData(extension).GetSyncData()); |
135 DCHECK(!ExtensionPrefs::Get(profile_)->NeedsSync(extension.id())); | 140 DCHECK(!ExtensionPrefs::Get(profile_)->NeedsSync(extension.id())); |
136 } else { | 141 } else { |
137 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), true); | 142 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), true); |
138 if (extension_service()->is_ready() && !flare_.is_null()) | 143 if (extension_service()->is_ready() && !flare_.is_null()) |
139 flare_.Run(type); // Tell sync to start ASAP. | 144 flare_.Run(type); // Tell sync to start ASAP. |
140 } | 145 } |
141 } | 146 } |
142 | 147 |
148 bool ExtensionSyncService::HasPendingReenable( | |
149 const std::string& id, | |
150 const base::Version& version) const { | |
151 auto it = pending_updates_.find(id); | |
152 if (it == pending_updates_.end()) | |
153 return false; | |
154 const PendingUpdate& up = it->second; | |
155 return up.version.Equals(version) && up.grant_permissions_and_reenable; | |
Devlin
2015/10/16 02:40:24
Nit: up? Do you pu? Either way, I prefer short, f
Marc Treib
2015/10/16 09:22:20
Done.
| |
156 } | |
157 | |
143 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( | 158 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( |
144 syncer::ModelType type, | 159 syncer::ModelType type, |
145 const syncer::SyncDataList& initial_sync_data, | 160 const syncer::SyncDataList& initial_sync_data, |
146 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 161 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
147 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { | 162 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
148 CHECK(sync_processor.get()); | 163 CHECK(sync_processor.get()); |
149 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) | 164 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) |
150 << "Got " << type << " ModelType"; | 165 << "Got " << type << " ModelType"; |
151 | 166 |
152 SyncBundle* bundle = GetSyncBundle(type); | 167 SyncBundle* bundle = GetSyncBundle(type); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 DCHECK(granted_permissions.get()); | 347 DCHECK(granted_permissions.get()); |
333 bool is_privilege_increase = | 348 bool is_privilege_increase = |
334 extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease( | 349 extensions::PermissionMessageProvider::Get()->IsPrivilegeIncrease( |
335 *granted_permissions, | 350 *granted_permissions, |
336 extension->permissions_data()->active_permissions(), | 351 extension->permissions_data()->active_permissions(), |
337 extension->GetType()); | 352 extension->GetType()); |
338 if (!is_privilege_increase) | 353 if (!is_privilege_increase) |
339 extension_service()->EnableExtension(id); | 354 extension_service()->EnableExtension(id); |
340 else if (extension_sync_data.supports_disable_reasons()) | 355 else if (extension_sync_data.supports_disable_reasons()) |
341 reenable_after_update = true; | 356 reenable_after_update = true; |
357 | |
358 #if defined(ENABLE_SUPERVISED_USERS) | |
359 if (is_privilege_increase && version_compare_result < 0 && | |
360 extensions::util::IsExtensionSupervised(extension, profile_)) { | |
361 SupervisedUserServiceFactory::GetForProfile(profile_) | |
362 ->AddExtensionUpdateRequest(id, *extension->version()); | |
363 } | |
364 #endif | |
342 } | 365 } |
343 } else { | 366 } else { |
344 // The extension is not installed yet. Set it to enabled; we'll check for | 367 // The extension is not installed yet. Set it to enabled; we'll check for |
345 // permission increase when it's actually installed. | 368 // permission increase when it's actually installed. |
346 extension_service()->EnableExtension(id); | 369 extension_service()->EnableExtension(id); |
347 } | 370 } |
348 } else { | 371 } else { |
349 int disable_reasons = extension_sync_data.disable_reasons(); | 372 int disable_reasons = extension_sync_data.disable_reasons(); |
350 if (extension_sync_data.remote_install()) { | 373 if (extension_sync_data.remote_install()) { |
351 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { | 374 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 if (IsCorrectSyncType(*extension, type) && | 641 if (IsCorrectSyncType(*extension, type) && |
619 extensions::util::ShouldSync(extension.get(), profile_) && | 642 extensions::util::ShouldSync(extension.get(), profile_) && |
620 (include_everything || | 643 (include_everything || |
621 ExtensionPrefs::Get(profile_)->NeedsSync(extension->id()))) { | 644 ExtensionPrefs::Get(profile_)->NeedsSync(extension->id()))) { |
622 // We should never have pending data for an installed extension. | 645 // We should never have pending data for an installed extension. |
623 DCHECK(!GetSyncBundle(type)->HasPendingExtensionData(extension->id())); | 646 DCHECK(!GetSyncBundle(type)->HasPendingExtensionData(extension->id())); |
624 sync_data_list->push_back(CreateSyncData(*extension)); | 647 sync_data_list->push_back(CreateSyncData(*extension)); |
625 } | 648 } |
626 } | 649 } |
627 } | 650 } |
OLD | NEW |