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()); | |
|
not at google - send to devlin
2015/07/15 20:27:57
You should be able to do this in the constructor;
Marc Treib
2015/07/16 09:22:34
Actually no, that would do something different: It
| |
| 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 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 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 const std::string& id = extension.id(); |
| 133 if (bundle->HasExtensionId(id)) | 133 if (bundle->HasExtensionId(id)) |
| 134 bundle->PushSyncDeletion(id, CreateSyncData(extension).GetSyncData()); | 134 bundle->PushSyncDeletion(id, CreateSyncData(extension).GetSyncData()); |
| 135 } | 135 } |
| 136 | 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 } | |
| 152 | |
| 153 void ExtensionSyncService::SyncExtensionChangeIfNeeded( | 137 void ExtensionSyncService::SyncExtensionChangeIfNeeded( |
| 154 const Extension& extension) { | 138 const Extension& extension) { |
| 155 if (!extensions::util::ShouldSync(&extension, profile_)) | 139 if (!extensions::util::ShouldSync(&extension, profile_)) |
| 156 return; | 140 return; |
| 157 | 141 |
| 158 syncer::ModelType type = | 142 syncer::ModelType type = |
| 159 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; | 143 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; |
| 160 SyncBundle* bundle = GetSyncBundle(type); | 144 SyncBundle* bundle = GetSyncBundle(type); |
| 161 if (bundle->IsSyncing()) | 145 if (bundle->IsSyncing()) { |
| 162 bundle->PushSyncChangeIfNeeded(extension); | 146 bundle->PushSyncChange(extension.id(), |
| 163 else if (extension_service_->is_ready() && !flare_.is_null()) | 147 CreateSyncData(extension).GetSyncData()); |
| 148 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), false); | |
|
not at google - send to devlin
2015/07/15 20:27:57
I think this only needs to go at the point when th
Marc Treib
2015/07/16 09:22:34
I think you're right. By the time we get here, the
| |
| 149 } else if (extension_service_->is_ready() && !flare_.is_null()) { | |
|
not at google - send to devlin
2015/07/15 20:27:57
It seems like these 2 cases should be separated.
Marc Treib
2015/07/16 09:22:34
Done.
not at google - send to devlin
2015/07/16 18:25:46
Ok good point. I still think it shouldn't be in an
Marc Treib
2015/07/17 10:24:06
Hm, turns out there's a test (ExtensionServiceTest
| |
| 150 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), true); | |
| 164 flare_.Run(type); | 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 |
| 179 bundle->MergeDataAndStartSyncing(initial_sync_data, sync_processor.Pass()); | 167 bundle->MergeDataAndStartSyncing(initial_sync_data, sync_processor.Pass()); |
| 180 GetPendingEnables(is_apps)->OnSyncStarted(extension_service_); | |
| 181 | 168 |
| 182 // Process local extensions. | 169 // Process local extensions. |
| 183 // TODO(yoz): Determine whether pending extensions should be considered too. | 170 // TODO(yoz): Determine whether pending extensions should be considered too. |
| 184 // See crbug.com/104399. | 171 // See crbug.com/104399. |
| 185 bundle->PushSyncDataList(GetAllSyncData(type)); | 172 std::vector<ExtensionSyncData> data_list = GetSyncDataList(type); |
| 173 bundle->PushSyncDataList(ToSyncerSyncDataList(data_list)); | |
| 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 return ToSyncerSyncDataList(GetSyncDataList(type)); |
| 200 syncer::SyncDataList result; | |
| 201 result.reserve(data.size()); | |
| 202 for (const ExtensionSyncData& item : data) | |
| 203 result.push_back(item.GetSyncData()); | |
| 204 return result; | |
| 205 } | 190 } |
| 206 | 191 |
| 207 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( | 192 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( |
| 208 const tracked_objects::Location& from_here, | 193 const tracked_objects::Location& from_here, |
| 209 const syncer::SyncChangeList& change_list) { | 194 const syncer::SyncChangeList& change_list) { |
| 210 for (const syncer::SyncChange& sync_change : change_list) { | 195 for (const syncer::SyncChange& sync_change : change_list) { |
| 211 syncer::ModelType type = sync_change.sync_data().GetDataType(); | 196 syncer::ModelType type = sync_change.sync_data().GetDataType(); |
| 212 GetSyncBundle(type)->ApplySyncChange(sync_change); | 197 GetSyncBundle(type)->ApplySyncChange(sync_change); |
| 213 } | 198 } |
| 214 | 199 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 238 } | 223 } |
| 239 return ExtensionSyncData( | 224 return ExtensionSyncData( |
| 240 extension, enabled, disable_reasons, incognito_enabled, remote_install, | 225 extension, enabled, disable_reasons, incognito_enabled, remote_install, |
| 241 allowed_on_all_url); | 226 allowed_on_all_url); |
| 242 } | 227 } |
| 243 | 228 |
| 244 bool ExtensionSyncService::ApplySyncData( | 229 bool ExtensionSyncService::ApplySyncData( |
| 245 const ExtensionSyncData& extension_sync_data) { | 230 const ExtensionSyncData& extension_sync_data) { |
| 246 const std::string& id = extension_sync_data.id(); | 231 const std::string& id = extension_sync_data.id(); |
| 247 | 232 |
| 233 // If the extension has local state that needs to be synced, ignore this | |
| 234 // change (we assume the local state is more recent). This should only ever | |
| 235 // happen during MergeDataAndStartSyncing. | |
| 236 if (ExtensionPrefs::Get(profile_)->NeedsSync(id)) | |
|
not at google - send to devlin
2015/07/15 20:27:57
I don't think this is the right place for this. In
Marc Treib
2015/07/16 09:22:34
That's two different things. What MergeDataAndStar
not at google - send to devlin
2015/07/16 18:25:46
In a way it's an optimisation, but only because co
Marc Treib
2015/07/17 10:24:06
Still "just" an optimization ;P
Anyway, done in PS
| |
| 237 return true; | |
| 238 | |
| 248 if (extension_sync_data.is_app()) { | 239 if (extension_sync_data.is_app()) { |
| 249 if (extension_sync_data.app_launch_ordinal().IsValid() && | 240 if (extension_sync_data.app_launch_ordinal().IsValid() && |
| 250 extension_sync_data.page_ordinal().IsValid()) { | 241 extension_sync_data.page_ordinal().IsValid()) { |
| 251 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( | 242 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( |
| 252 id, | 243 id, |
| 253 extension_sync_data.app_launch_ordinal()); | 244 extension_sync_data.app_launch_ordinal()); |
| 254 extension_prefs_->app_sorting()->SetPageOrdinal( | 245 extension_prefs_->app_sorting()->SetPageOrdinal( |
| 255 id, | 246 id, |
| 256 extension_sync_data.page_ordinal()); | 247 extension_sync_data.page_ordinal()); |
| 257 } | 248 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 | 329 |
| 339 if (ext) | 330 if (ext) |
| 340 SyncExtensionChangeIfNeeded(*ext); | 331 SyncExtensionChangeIfNeeded(*ext); |
| 341 } | 332 } |
| 342 | 333 |
| 343 void ExtensionSyncService::SetSyncStartFlare( | 334 void ExtensionSyncService::SetSyncStartFlare( |
| 344 const syncer::SyncableService::StartSyncFlare& flare) { | 335 const syncer::SyncableService::StartSyncFlare& flare) { |
| 345 flare_ = flare; | 336 flare_ = flare; |
| 346 } | 337 } |
| 347 | 338 |
| 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) { | 339 SyncBundle* ExtensionSyncService::GetSyncBundle(syncer::ModelType type) { |
| 355 return const_cast<SyncBundle*>( | 340 return const_cast<SyncBundle*>( |
| 356 const_cast<const ExtensionSyncService&>(*this).GetSyncBundle(type)); | 341 const_cast<const ExtensionSyncService&>(*this).GetSyncBundle(type)); |
| 357 } | 342 } |
| 358 | 343 |
| 359 const SyncBundle* ExtensionSyncService::GetSyncBundle( | 344 const SyncBundle* ExtensionSyncService::GetSyncBundle( |
| 360 syncer::ModelType type) const { | 345 syncer::ModelType type) const { |
| 361 return (type == syncer::APPS) ? &app_sync_bundle_ : &extension_sync_bundle_; | 346 return (type == syncer::APPS) ? &app_sync_bundle_ : &extension_sync_bundle_; |
| 362 } | 347 } |
| 363 | 348 |
| 364 extensions::PendingEnables* ExtensionSyncService::GetPendingEnables( | |
| 365 bool is_apps) { | |
| 366 return is_apps ? &pending_app_enables_ : &pending_extension_enables_; | |
| 367 } | |
| 368 | |
| 369 std::vector<ExtensionSyncData> ExtensionSyncService::GetSyncDataList( | 349 std::vector<ExtensionSyncData> ExtensionSyncService::GetSyncDataList( |
| 370 syncer::ModelType type) const { | 350 syncer::ModelType type) const { |
| 351 // Collect the local state. FillSyncDataList will filter out extensions for | |
| 352 // which we have pending data that should be used instead. | |
| 371 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 353 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
| 372 std::vector<ExtensionSyncData> extension_sync_list; | 354 std::vector<ExtensionSyncData> extension_sync_list; |
| 373 FillSyncDataList(registry->enabled_extensions(), type, &extension_sync_list); | 355 FillSyncDataList(registry->enabled_extensions(), type, &extension_sync_list); |
| 374 FillSyncDataList(registry->disabled_extensions(), type, &extension_sync_list); | 356 FillSyncDataList(registry->disabled_extensions(), type, &extension_sync_list); |
| 375 FillSyncDataList( | 357 FillSyncDataList( |
| 376 registry->terminated_extensions(), type, &extension_sync_list); | 358 registry->terminated_extensions(), type, &extension_sync_list); |
| 377 | 359 |
| 360 // Add pending data (where the local extension is either not installed yet or | |
| 361 // outdated). | |
| 378 std::vector<ExtensionSyncData> pending_extensions = | 362 std::vector<ExtensionSyncData> pending_extensions = |
| 379 GetSyncBundle(type)->GetPendingData(); | 363 GetSyncBundle(type)->GetPendingData(); |
| 380 extension_sync_list.insert(extension_sync_list.begin(), | 364 extension_sync_list.insert(extension_sync_list.begin(), |
| 381 pending_extensions.begin(), | 365 pending_extensions.begin(), |
| 382 pending_extensions.end()); | 366 pending_extensions.end()); |
| 383 | 367 |
| 384 return extension_sync_list; | 368 return extension_sync_list; |
| 385 } | 369 } |
| 386 | 370 |
| 387 void ExtensionSyncService::FillSyncDataList( | 371 void ExtensionSyncService::FillSyncDataList( |
| 388 const ExtensionSet& extensions, | 372 const ExtensionSet& extensions, |
| 389 syncer::ModelType type, | 373 syncer::ModelType type, |
| 390 std::vector<ExtensionSyncData>* sync_data_list) const { | 374 std::vector<ExtensionSyncData>* sync_data_list) const { |
| 391 const SyncBundle* bundle = GetSyncBundle(type); | 375 const SyncBundle* bundle = GetSyncBundle(type); |
| 392 for (const scoped_refptr<const Extension>& extension : extensions) { | 376 for (const scoped_refptr<const Extension>& extension : extensions) { |
| 393 if (IsCorrectSyncType(*extension, type) && | 377 if (IsCorrectSyncType(*extension, type) && |
| 394 extensions::util::ShouldSync(extension.get(), profile_) && | 378 extensions::util::ShouldSync(extension.get(), profile_) && |
| 395 bundle->ShouldIncludeInLocalSyncDataList(*extension)) { | 379 bundle->IsSyncing() && |
|
not at google - send to devlin
2015/07/15 20:27:57
Should this be a (D)CHECK?
Marc Treib
2015/07/16 09:22:34
Not sure - can GetAllSyncData (from syncer::Syncab
not at google - send to devlin
2015/07/16 18:25:46
Removing SGTM.
Marc Treib
2015/07/17 10:24:06
Done.
| |
| 380 !bundle->HasPendingExtensionId(extension->id())) { | |
| 396 sync_data_list->push_back(CreateSyncData(*extension)); | 381 sync_data_list->push_back(CreateSyncData(*extension)); |
| 397 } | 382 } |
| 398 } | 383 } |
| 399 } | 384 } |
| 400 | 385 |
| 401 bool ExtensionSyncService::ApplyExtensionSyncDataHelper( | 386 bool ExtensionSyncService::ApplyExtensionSyncDataHelper( |
| 402 const ExtensionSyncData& extension_sync_data, | 387 const ExtensionSyncData& extension_sync_data, |
| 403 syncer::ModelType type) { | 388 syncer::ModelType type) { |
| 404 const std::string& id = extension_sync_data.id(); | 389 const std::string& id = extension_sync_data.id(); |
| 405 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 390 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 | 426 // local one. Otherwise we just enable it without granting permissions. If |
| 442 // any permissions are missing, CheckPermissionsIncrease will soon disable | 427 // any permissions are missing, CheckPermissionsIncrease will soon disable |
| 443 // it again. | 428 // it again. |
| 444 bool grant_permissions = | 429 bool grant_permissions = |
| 445 extension_sync_data.supports_disable_reasons() && | 430 extension_sync_data.supports_disable_reasons() && |
| 446 extension && (version_compare_result == 0); | 431 extension && (version_compare_result == 0); |
| 447 if (grant_permissions) | 432 if (grant_permissions) |
| 448 extension_service_->GrantPermissionsAndEnableExtension(extension); | 433 extension_service_->GrantPermissionsAndEnableExtension(extension); |
| 449 else | 434 else |
| 450 extension_service_->EnableExtension(id); | 435 extension_service_->EnableExtension(id); |
| 451 } else if (!IsPendingEnable(id)) { | 436 } else { |
| 452 int disable_reasons = extension_sync_data.disable_reasons(); | 437 int disable_reasons = extension_sync_data.disable_reasons(); |
| 453 if (extension_sync_data.remote_install()) { | 438 if (extension_sync_data.remote_install()) { |
| 454 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { | 439 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { |
| 455 // In the non-legacy case (>=M45) where disable reasons are synced at | 440 // In the non-legacy case (>=M45) where disable reasons are synced at |
| 456 // all, DISABLE_REMOTE_INSTALL should be among them already. | 441 // all, DISABLE_REMOTE_INSTALL should be among them already. |
| 457 DCHECK(!extension_sync_data.supports_disable_reasons()); | 442 DCHECK(!extension_sync_data.supports_disable_reasons()); |
| 458 disable_reasons |= Extension::DISABLE_REMOTE_INSTALL; | 443 disable_reasons |= Extension::DISABLE_REMOTE_INSTALL; |
| 459 } | 444 } |
| 460 } else if (!extension_sync_data.supports_disable_reasons()) { | 445 } else if (!extension_sync_data.supports_disable_reasons()) { |
| 461 // Legacy case (<M45), from before we synced disable reasons (see | 446 // 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 | 498 // 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 | 499 // never be removed (we'll never install a syncable version of the |
| 515 // extension), so that GetAllSyncData() continues to send it. | 500 // extension), so that GetAllSyncData() continues to send it. |
| 516 } | 501 } |
| 517 // Track pending extensions so that we can return them in GetAllSyncData(). | 502 // Track pending extensions so that we can return them in GetAllSyncData(). |
| 518 return false; | 503 return false; |
| 519 } | 504 } |
| 520 | 505 |
| 521 return true; | 506 return true; |
| 522 } | 507 } |
| OLD | NEW |