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 "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 "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "chrome/browser/extensions/bookmark_app_helper.h" | 10 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "extensions/common/extension_set.h" | 28 #include "extensions/common/extension_set.h" |
| 29 #include "extensions/common/image_util.h" | 29 #include "extensions/common/image_util.h" |
| 30 #include "sync/api/sync_change.h" | 30 #include "sync/api/sync_change.h" |
| 31 #include "sync/api/sync_error_factory.h" | 31 #include "sync/api/sync_error_factory.h" |
| 32 | 32 |
| 33 using extensions::Extension; | 33 using extensions::Extension; |
| 34 using extensions::ExtensionPrefs; | 34 using extensions::ExtensionPrefs; |
| 35 using extensions::ExtensionRegistry; | 35 using extensions::ExtensionRegistry; |
| 36 using extensions::ExtensionSet; | 36 using extensions::ExtensionSet; |
| 37 using extensions::ExtensionSyncData; | 37 using extensions::ExtensionSyncData; |
| 38 using extensions::PendingEnables; | |
| 39 using extensions::SyncBundle; | 38 using extensions::SyncBundle; |
| 40 | 39 |
| 41 namespace { | 40 namespace { |
| 42 | 41 |
| 43 void OnWebApplicationInfoLoaded( | 42 void OnWebApplicationInfoLoaded( |
| 44 WebApplicationInfo synced_info, | 43 WebApplicationInfo synced_info, |
| 45 base::WeakPtr<ExtensionService> extension_service, | 44 base::WeakPtr<ExtensionService> extension_service, |
| 46 const WebApplicationInfo& loaded_info) { | 45 const WebApplicationInfo& loaded_info) { |
| 47 DCHECK_EQ(synced_info.app_url, loaded_info.app_url); | 46 DCHECK_EQ(synced_info.app_url, loaded_info.app_url); |
| 48 | 47 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 72 // Otherwise, unset. | 71 // Otherwise, unset. |
| 73 return ExtensionSyncData::BOOLEAN_UNSET; | 72 return ExtensionSyncData::BOOLEAN_UNSET; |
| 74 } | 73 } |
| 75 | 74 |
| 76 // Returns true if the sync type of |extension| matches |type|. | 75 // Returns true if the sync type of |extension| matches |type|. |
| 77 bool IsCorrectSyncType(const Extension& extension, syncer::ModelType type) { | 76 bool IsCorrectSyncType(const Extension& extension, syncer::ModelType type) { |
| 78 return (type == syncer::EXTENSIONS && extension.is_extension()) || | 77 return (type == syncer::EXTENSIONS && extension.is_extension()) || |
| 79 (type == syncer::APPS && extension.is_app()); | 78 (type == syncer::APPS && extension.is_app()); |
| 80 } | 79 } |
| 81 | 80 |
| 81 syncer::SyncDataList ToSyncerSyncDataList( | |
| 82 const std::vector<ExtensionSyncData>& data) { | |
| 83 syncer::SyncDataList result; | |
| 84 result.reserve(data.size()); | |
| 85 for (const ExtensionSyncData& item : data) | |
| 86 result.push_back(item.GetSyncData()); | |
| 87 return result; | |
| 88 } | |
| 89 | |
| 82 } // namespace | 90 } // namespace |
| 83 | 91 |
| 84 ExtensionSyncService::ExtensionSyncService(Profile* profile, | 92 ExtensionSyncService::ExtensionSyncService(Profile* profile, |
| 85 ExtensionPrefs* extension_prefs, | 93 ExtensionPrefs* extension_prefs, |
| 86 ExtensionService* extension_service) | 94 ExtensionService* extension_service) |
| 87 : profile_(profile), | 95 : profile_(profile), |
| 88 extension_prefs_(extension_prefs), | 96 extension_prefs_(extension_prefs), |
| 89 extension_service_(extension_service), | 97 extension_service_(extension_service), |
| 90 app_sync_bundle_(this), | 98 app_sync_bundle_(this), |
| 91 extension_sync_bundle_(this), | 99 extension_sync_bundle_(this) { |
| 92 pending_app_enables_(make_scoped_ptr(new sync_driver::SyncPrefs( | |
| 93 extension_prefs_->pref_service())), | |
| 94 &app_sync_bundle_, | |
| 95 syncer::APPS), | |
| 96 pending_extension_enables_(make_scoped_ptr(new sync_driver::SyncPrefs( | |
| 97 extension_prefs_->pref_service())), | |
| 98 &extension_sync_bundle_, | |
| 99 syncer::EXTENSIONS) { | |
| 100 SetSyncStartFlare(sync_start_util::GetFlareForSyncableService( | 100 SetSyncStartFlare(sync_start_util::GetFlareForSyncableService( |
| 101 profile_->GetPath())); | 101 profile_->GetPath())); |
| 102 | 102 |
| 103 extension_service_->set_extension_sync_service(this); | 103 extension_service_->set_extension_sync_service(this); |
| 104 extension_prefs_->app_sorting()->SetExtensionSyncService(this); | 104 extension_prefs_->app_sorting()->SetExtensionSyncService(this); |
| 105 } | 105 } |
| 106 | 106 |
| 107 ExtensionSyncService::~ExtensionSyncService() {} | 107 ExtensionSyncService::~ExtensionSyncService() {} |
| 108 | 108 |
| 109 // static | 109 // static |
| 110 ExtensionSyncService* ExtensionSyncService::Get( | 110 ExtensionSyncService* ExtensionSyncService::Get( |
| 111 content::BrowserContext* context) { | 111 content::BrowserContext* context) { |
| 112 return ExtensionSyncServiceFactory::GetForBrowserContext(context); | 112 return ExtensionSyncServiceFactory::GetForBrowserContext(context); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void ExtensionSyncService::SyncUninstallExtension( | 115 void ExtensionSyncService::SyncUninstallExtension( |
| 116 const extensions::Extension& extension) { | 116 const extensions::Extension& extension) { |
| 117 if (!extensions::util::ShouldSync(&extension, profile_)) | 117 if (!extensions::util::ShouldSync(&extension, profile_)) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 // TODO(tim): If we get here and IsSyncing is false, this will cause | 120 // TODO(tim): If we get here and IsSyncing is false, this will cause |
| 121 // "back from the dead" style bugs, because sync will add-back the extension | 121 // "back from the dead" style bugs, because sync will add-back the extension |
| 122 // that was uninstalled here when MergeDataAndStartSyncing is called. | 122 // that was uninstalled here when MergeDataAndStartSyncing is called. |
| 123 // See crbug.com/256795. | 123 // See crbug.com/256795. |
|
Marc Treib
2015/07/16 13:20:43
I think we could handle this by setting NeedsSync
not at google - send to devlin
2015/07/16 18:25:46
No, but IIRC there is a precedent for tombstone ex
Marc Treib
2015/07/17 10:24:06
I looked into ExtensionPrefs::IsExternalExtensionU
not at google - send to devlin
2015/07/17 15:28:50
Ok maybe a separate pref would be better after all
Marc Treib
2015/07/20 09:28:22
Acknowledged.
| |
| 124 syncer::ModelType type = | 124 syncer::ModelType type = |
| 125 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; | 125 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; |
| 126 SyncBundle* bundle = GetSyncBundle(type); | 126 SyncBundle* bundle = GetSyncBundle(type); |
| 127 if (!bundle->IsSyncing()) { | 127 if (!bundle->IsSyncing()) { |
| 128 if (extension_service_->is_ready() && !flare_.is_null()) | 128 if (extension_service_->is_ready() && !flare_.is_null()) |
| 129 flare_.Run(type); // Tell sync to start ASAP. | 129 flare_.Run(type); // Tell sync to start ASAP. |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 const std::string& id = extension.id(); | 132 bundle->PushSyncDeletion(extension.id(), |
| 133 if (bundle->HasExtensionId(id)) | 133 CreateSyncData(extension).GetSyncData()); |
| 134 bundle->PushSyncDeletion(id, CreateSyncData(extension).GetSyncData()); | |
| 135 } | |
| 136 | |
| 137 void ExtensionSyncService::SyncEnableExtension(const Extension& extension) { | |
| 138 // Syncing may not have started yet, so handle pending enables. | |
| 139 if (extensions::util::ShouldSync(&extension, profile_)) | |
| 140 GetPendingEnables(extension.is_app())->Add(extension.id()); | |
| 141 | |
| 142 SyncExtensionChangeIfNeeded(extension); | |
| 143 } | |
| 144 | |
| 145 void ExtensionSyncService::SyncDisableExtension(const Extension& extension) { | |
| 146 // Syncing may not have started yet, so handle pending enables. | |
| 147 if (extensions::util::ShouldSync(&extension, profile_)) | |
| 148 GetPendingEnables(extension.is_app())->Remove(extension.id()); | |
| 149 | |
| 150 SyncExtensionChangeIfNeeded(extension); | |
| 151 } | 134 } |
| 152 | 135 |
| 153 void ExtensionSyncService::SyncExtensionChangeIfNeeded( | 136 void ExtensionSyncService::SyncExtensionChangeIfNeeded( |
| 154 const Extension& extension) { | 137 const Extension& extension) { |
| 155 if (!extensions::util::ShouldSync(&extension, profile_)) | 138 if (!extensions::util::ShouldSync(&extension, profile_)) |
| 156 return; | 139 return; |
| 157 | 140 |
| 158 syncer::ModelType type = | 141 syncer::ModelType type = |
| 159 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; | 142 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; |
| 160 SyncBundle* bundle = GetSyncBundle(type); | 143 SyncBundle* bundle = GetSyncBundle(type); |
| 161 if (bundle->IsSyncing()) | 144 if (bundle->IsSyncing()) { |
| 162 bundle->PushSyncAddOrUpdate(extension); | 145 bundle->PushSyncAddOrUpdate(extension.id(), |
| 163 else if (extension_service_->is_ready() && !flare_.is_null()) | 146 CreateSyncData(extension).GetSyncData()); |
| 164 flare_.Run(type); | 147 DCHECK(!ExtensionPrefs::Get(profile_)->NeedsSync(extension.id())); |
| 148 } else { | |
| 149 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), true); | |
| 150 if (extension_service_->is_ready() && !flare_.is_null()) | |
| 151 flare_.Run(type); | |
| 152 } | |
| 165 } | 153 } |
| 166 | 154 |
| 167 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( | 155 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( |
| 168 syncer::ModelType type, | 156 syncer::ModelType type, |
| 169 const syncer::SyncDataList& initial_sync_data, | 157 const syncer::SyncDataList& initial_sync_data, |
| 170 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 158 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 171 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { | 159 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
| 172 CHECK(sync_processor.get()); | 160 CHECK(sync_processor.get()); |
| 173 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) | 161 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) |
| 174 << "Got " << type << " ModelType"; | 162 << "Got " << type << " ModelType"; |
| 175 | 163 |
| 176 SyncBundle* bundle = GetSyncBundle(type); | 164 SyncBundle* bundle = GetSyncBundle(type); |
| 177 bool is_apps = (type == syncer::APPS); | 165 bool is_apps = (type == syncer::APPS); |
| 178 | 166 |
| 167 // Forward to the bundle which will apply the initial sync data, filtering | |
| 168 // out any items where we have more recent local changes. | |
| 179 bundle->MergeDataAndStartSyncing(initial_sync_data, sync_processor.Pass()); | 169 bundle->MergeDataAndStartSyncing(initial_sync_data, sync_processor.Pass()); |
| 180 GetPendingEnables(is_apps)->OnSyncStarted(extension_service_); | |
| 181 | 170 |
| 182 // Process local extensions. | 171 // Now push those local changes to sync. |
| 183 // TODO(yoz): Determine whether pending extensions should be considered too. | 172 std::vector<ExtensionSyncData> data_list = GetLocalSyncDataList(type, true); |
| 184 // See crbug.com/104399. | 173 bundle->PushSyncDataList(ToSyncerSyncDataList(data_list)); |
| 185 bundle->PushSyncDataList(GetAllSyncData(type)); | 174 for (const ExtensionSyncData& data : data_list) |
| 175 ExtensionPrefs::Get(profile_)->SetNeedsSync(data.id(), false); | |
| 186 | 176 |
| 187 if (is_apps) | 177 if (is_apps) |
| 188 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); | 178 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); |
| 189 | 179 |
| 190 return syncer::SyncMergeResult(type); | 180 return syncer::SyncMergeResult(type); |
| 191 } | 181 } |
| 192 | 182 |
| 193 void ExtensionSyncService::StopSyncing(syncer::ModelType type) { | 183 void ExtensionSyncService::StopSyncing(syncer::ModelType type) { |
| 194 GetSyncBundle(type)->Reset(); | 184 GetSyncBundle(type)->Reset(); |
| 195 } | 185 } |
| 196 | 186 |
| 197 syncer::SyncDataList ExtensionSyncService::GetAllSyncData( | 187 syncer::SyncDataList ExtensionSyncService::GetAllSyncData( |
| 198 syncer::ModelType type) const { | 188 syncer::ModelType type) const { |
| 199 std::vector<ExtensionSyncData> data = GetSyncDataList(type); | 189 std::vector<extensions::ExtensionSyncData> sync_data_list = |
| 200 syncer::SyncDataList result; | 190 GetLocalSyncDataList(type, false); |
| 201 result.reserve(data.size()); | 191 |
| 202 for (const ExtensionSyncData& item : data) | 192 // Add pending data (where the local extension is either not installed yet or |
| 203 result.push_back(item.GetSyncData()); | 193 // outdated). |
| 204 return result; | 194 std::vector<ExtensionSyncData> pending_extensions = |
| 195 GetSyncBundle(type)->GetPendingData(); | |
| 196 sync_data_list.insert(sync_data_list.begin(), | |
| 197 pending_extensions.begin(), | |
| 198 pending_extensions.end()); | |
| 199 | |
| 200 return ToSyncerSyncDataList(sync_data_list); | |
| 205 } | 201 } |
| 206 | 202 |
| 207 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( | 203 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( |
| 208 const tracked_objects::Location& from_here, | 204 const tracked_objects::Location& from_here, |
| 209 const syncer::SyncChangeList& change_list) { | 205 const syncer::SyncChangeList& change_list) { |
| 210 for (const syncer::SyncChange& sync_change : change_list) { | 206 for (const syncer::SyncChange& sync_change : change_list) { |
| 211 syncer::ModelType type = sync_change.sync_data().GetDataType(); | 207 syncer::ModelType type = sync_change.sync_data().GetDataType(); |
| 212 GetSyncBundle(type)->ApplySyncChange(sync_change); | 208 GetSyncBundle(type)->ApplySyncChange(sync_change); |
| 213 } | 209 } |
| 214 | 210 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 | 269 |
| 274 if (!ApplyExtensionSyncDataHelper(extension_sync_data, type)) { | 270 if (!ApplyExtensionSyncDataHelper(extension_sync_data, type)) { |
| 275 GetSyncBundle(type)->AddPendingExtension(id, extension_sync_data); | 271 GetSyncBundle(type)->AddPendingExtension(id, extension_sync_data); |
| 276 extension_service_->CheckForUpdatesSoon(); | 272 extension_service_->CheckForUpdatesSoon(); |
| 277 return false; | 273 return false; |
| 278 } | 274 } |
| 279 | 275 |
| 280 return true; | 276 return true; |
| 281 } | 277 } |
| 282 | 278 |
| 279 bool ExtensionSyncService::ExtensionNeedsSync( | |
| 280 const std::string& extension_id) const { | |
| 281 return ExtensionPrefs::Get(profile_)->NeedsSync(extension_id); | |
| 282 } | |
| 283 | |
| 283 void ExtensionSyncService::ApplyBookmarkAppSyncData( | 284 void ExtensionSyncService::ApplyBookmarkAppSyncData( |
| 284 const extensions::ExtensionSyncData& extension_sync_data) { | 285 const extensions::ExtensionSyncData& extension_sync_data) { |
| 285 DCHECK(extension_sync_data.is_app()); | 286 DCHECK(extension_sync_data.is_app()); |
| 286 | 287 |
| 287 // Process bookmark app sync if necessary. | 288 // Process bookmark app sync if necessary. |
| 288 GURL bookmark_app_url(extension_sync_data.bookmark_app_url()); | 289 GURL bookmark_app_url(extension_sync_data.bookmark_app_url()); |
| 289 if (!bookmark_app_url.is_valid() || | 290 if (!bookmark_app_url.is_valid() || |
| 290 extension_sync_data.uninstalled()) { | 291 extension_sync_data.uninstalled()) { |
| 291 return; | 292 return; |
| 292 } | 293 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 | 339 |
| 339 if (ext) | 340 if (ext) |
| 340 SyncExtensionChangeIfNeeded(*ext); | 341 SyncExtensionChangeIfNeeded(*ext); |
| 341 } | 342 } |
| 342 | 343 |
| 343 void ExtensionSyncService::SetSyncStartFlare( | 344 void ExtensionSyncService::SetSyncStartFlare( |
| 344 const syncer::SyncableService::StartSyncFlare& flare) { | 345 const syncer::SyncableService::StartSyncFlare& flare) { |
| 345 flare_ = flare; | 346 flare_ = flare; |
| 346 } | 347 } |
| 347 | 348 |
| 348 bool ExtensionSyncService::IsPendingEnable( | |
| 349 const std::string& extension_id) const { | |
| 350 return pending_app_enables_.Contains(extension_id) || | |
| 351 pending_extension_enables_.Contains(extension_id); | |
| 352 } | |
| 353 | |
| 354 SyncBundle* ExtensionSyncService::GetSyncBundle(syncer::ModelType type) { | 349 SyncBundle* ExtensionSyncService::GetSyncBundle(syncer::ModelType type) { |
| 355 return const_cast<SyncBundle*>( | 350 return const_cast<SyncBundle*>( |
| 356 const_cast<const ExtensionSyncService&>(*this).GetSyncBundle(type)); | 351 const_cast<const ExtensionSyncService&>(*this).GetSyncBundle(type)); |
| 357 } | 352 } |
| 358 | 353 |
| 359 const SyncBundle* ExtensionSyncService::GetSyncBundle( | 354 const SyncBundle* ExtensionSyncService::GetSyncBundle( |
| 360 syncer::ModelType type) const { | 355 syncer::ModelType type) const { |
| 361 return (type == syncer::APPS) ? &app_sync_bundle_ : &extension_sync_bundle_; | 356 return (type == syncer::APPS) ? &app_sync_bundle_ : &extension_sync_bundle_; |
| 362 } | 357 } |
| 363 | 358 |
| 364 extensions::PendingEnables* ExtensionSyncService::GetPendingEnables( | 359 std::vector<ExtensionSyncData> ExtensionSyncService::GetLocalSyncDataList( |
| 365 bool is_apps) { | 360 syncer::ModelType type, |
| 366 return is_apps ? &pending_app_enables_ : &pending_extension_enables_; | 361 bool only_with_needs_sync) const { |
|
not at google - send to devlin
2015/07/16 18:25:47
Sorry for nit but could we reverse this boolean? M
Marc Treib
2015/07/17 10:24:06
Sure, done. Agreed that this makes it easier to re
| |
| 367 } | 362 // Collect the local state. FillSyncDataList will filter out extensions for |
| 368 | 363 // which we have pending data that should be used instead. |
| 369 std::vector<ExtensionSyncData> ExtensionSyncService::GetSyncDataList( | |
| 370 syncer::ModelType type) const { | |
| 371 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 364 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
| 372 std::vector<ExtensionSyncData> extension_sync_list; | 365 std::vector<ExtensionSyncData> data; |
| 373 FillSyncDataList(registry->enabled_extensions(), type, &extension_sync_list); | |
| 374 FillSyncDataList(registry->disabled_extensions(), type, &extension_sync_list); | |
| 375 FillSyncDataList( | 366 FillSyncDataList( |
| 376 registry->terminated_extensions(), type, &extension_sync_list); | 367 registry->enabled_extensions(), type, only_with_needs_sync, &data); |
| 377 | 368 FillSyncDataList( |
| 378 std::vector<ExtensionSyncData> pending_extensions = | 369 registry->disabled_extensions(), type, only_with_needs_sync, &data); |
| 379 GetSyncBundle(type)->GetPendingData(); | 370 FillSyncDataList( |
| 380 extension_sync_list.insert(extension_sync_list.begin(), | 371 registry->terminated_extensions(), type, only_with_needs_sync, &data); |
| 381 pending_extensions.begin(), | 372 return data; |
| 382 pending_extensions.end()); | |
| 383 | |
| 384 return extension_sync_list; | |
| 385 } | 373 } |
| 386 | 374 |
| 387 void ExtensionSyncService::FillSyncDataList( | 375 void ExtensionSyncService::FillSyncDataList( |
| 388 const ExtensionSet& extensions, | 376 const ExtensionSet& extensions, |
| 389 syncer::ModelType type, | 377 syncer::ModelType type, |
| 378 bool only_with_needs_sync, | |
| 390 std::vector<ExtensionSyncData>* sync_data_list) const { | 379 std::vector<ExtensionSyncData>* sync_data_list) const { |
| 391 const SyncBundle* bundle = GetSyncBundle(type); | 380 const SyncBundle* bundle = GetSyncBundle(type); |
| 381 // TODO(treib,kalman): This seems weird. Remove the IsSyncing check? | |
| 382 if (!bundle->IsSyncing()) | |
| 383 return; | |
| 392 for (const scoped_refptr<const Extension>& extension : extensions) { | 384 for (const scoped_refptr<const Extension>& extension : extensions) { |
| 393 if (IsCorrectSyncType(*extension, type) && | 385 if (IsCorrectSyncType(*extension, type) && |
| 394 extensions::util::ShouldSync(extension.get(), profile_) && | 386 extensions::util::ShouldSync(extension.get(), profile_) && |
| 395 bundle->ShouldIncludeInLocalSyncDataList(*extension)) { | 387 !bundle->HasPendingExtensionId(extension->id()) && |
| 388 (!only_with_needs_sync || ExtensionNeedsSync(extension->id()))) { | |
| 396 sync_data_list->push_back(CreateSyncData(*extension)); | 389 sync_data_list->push_back(CreateSyncData(*extension)); |
| 397 } | 390 } |
| 398 } | 391 } |
| 399 } | 392 } |
| 400 | 393 |
| 401 bool ExtensionSyncService::ApplyExtensionSyncDataHelper( | 394 bool ExtensionSyncService::ApplyExtensionSyncDataHelper( |
| 402 const ExtensionSyncData& extension_sync_data, | 395 const ExtensionSyncData& extension_sync_data, |
| 403 syncer::ModelType type) { | 396 syncer::ModelType type) { |
| 404 const std::string& id = extension_sync_data.id(); | 397 const std::string& id = extension_sync_data.id(); |
| 405 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 398 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 // local one. Otherwise we just enable it without granting permissions. If | 434 // local one. Otherwise we just enable it without granting permissions. If |
| 442 // any permissions are missing, CheckPermissionsIncrease will soon disable | 435 // any permissions are missing, CheckPermissionsIncrease will soon disable |
| 443 // it again. | 436 // it again. |
| 444 bool grant_permissions = | 437 bool grant_permissions = |
| 445 extension_sync_data.supports_disable_reasons() && | 438 extension_sync_data.supports_disable_reasons() && |
| 446 extension && (version_compare_result == 0); | 439 extension && (version_compare_result == 0); |
| 447 if (grant_permissions) | 440 if (grant_permissions) |
| 448 extension_service_->GrantPermissionsAndEnableExtension(extension); | 441 extension_service_->GrantPermissionsAndEnableExtension(extension); |
| 449 else | 442 else |
| 450 extension_service_->EnableExtension(id); | 443 extension_service_->EnableExtension(id); |
| 451 } else if (!IsPendingEnable(id)) { | 444 } else { |
| 452 int disable_reasons = extension_sync_data.disable_reasons(); | 445 int disable_reasons = extension_sync_data.disable_reasons(); |
| 453 if (extension_sync_data.remote_install()) { | 446 if (extension_sync_data.remote_install()) { |
| 454 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { | 447 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { |
| 455 // In the non-legacy case (>=M45) where disable reasons are synced at | 448 // In the non-legacy case (>=M45) where disable reasons are synced at |
| 456 // all, DISABLE_REMOTE_INSTALL should be among them already. | 449 // all, DISABLE_REMOTE_INSTALL should be among them already. |
| 457 DCHECK(!extension_sync_data.supports_disable_reasons()); | 450 DCHECK(!extension_sync_data.supports_disable_reasons()); |
| 458 disable_reasons |= Extension::DISABLE_REMOTE_INSTALL; | 451 disable_reasons |= Extension::DISABLE_REMOTE_INSTALL; |
| 459 } | 452 } |
| 460 } else if (!extension_sync_data.supports_disable_reasons()) { | 453 } else if (!extension_sync_data.supports_disable_reasons()) { |
| 461 // Legacy case (<M45), from before we synced disable reasons (see | 454 // Legacy case (<M45), from before we synced disable reasons (see |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 // non-INTERNAL location. Add to pending_sync_data, even though it will | 506 // non-INTERNAL location. Add to pending_sync_data, even though it will |
| 514 // never be removed (we'll never install a syncable version of the | 507 // never be removed (we'll never install a syncable version of the |
| 515 // extension), so that GetAllSyncData() continues to send it. | 508 // extension), so that GetAllSyncData() continues to send it. |
| 516 } | 509 } |
| 517 // Track pending extensions so that we can return them in GetAllSyncData(). | 510 // Track pending extensions so that we can return them in GetAllSyncData(). |
| 518 return false; | 511 return false; |
| 519 } | 512 } |
| 520 | 513 |
| 521 return true; | 514 return true; |
| 522 } | 515 } |
| OLD | NEW |