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), | |
91 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( | 98 SetSyncStartFlare(sync_start_util::GetFlareForSyncableService( |
101 profile_->GetPath())); | 99 profile_->GetPath())); |
102 | 100 |
103 extension_service_->set_extension_sync_service(this); | 101 extension_service_->set_extension_sync_service(this); |
104 extension_prefs_->app_sorting()->SetExtensionSyncService(this); | 102 extension_prefs_->app_sorting()->SetExtensionSyncService(this); |
105 } | 103 } |
106 | 104 |
107 ExtensionSyncService::~ExtensionSyncService() {} | 105 ExtensionSyncService::~ExtensionSyncService() {} |
108 | 106 |
109 // static | 107 // static |
110 ExtensionSyncService* ExtensionSyncService::Get( | 108 ExtensionSyncService* ExtensionSyncService::Get( |
111 content::BrowserContext* context) { | 109 content::BrowserContext* context) { |
112 return ExtensionSyncServiceFactory::GetForBrowserContext(context); | 110 return ExtensionSyncServiceFactory::GetForBrowserContext(context); |
113 } | 111 } |
114 | 112 |
115 void ExtensionSyncService::SyncUninstallExtension( | 113 void ExtensionSyncService::SyncUninstallExtension( |
116 const extensions::Extension& extension) { | 114 const extensions::Extension& extension) { |
117 if (!extensions::util::ShouldSync(&extension, profile_)) | 115 if (!extensions::util::ShouldSync(&extension, profile_)) |
118 return; | 116 return; |
119 | 117 |
120 // TODO(tim): If we get here and IsSyncing is false, this will cause | 118 // 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 | 119 // "back from the dead" style bugs, because sync will add-back the extension |
122 // that was uninstalled here when MergeDataAndStartSyncing is called. | 120 // that was uninstalled here when MergeDataAndStartSyncing is called. |
123 // See crbug.com/256795. | 121 // See crbug.com/256795. |
124 syncer::ModelType type = | 122 syncer::ModelType type = |
125 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; | 123 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; |
126 SyncBundle* bundle = GetSyncBundle(type); | 124 SyncBundle* bundle = GetSyncBundle(type); |
127 if (!bundle->IsSyncing()) { | 125 if (bundle->IsSyncing()) { |
128 if (extension_service_->is_ready() && !flare_.is_null()) | 126 bundle->PushSyncDeletion(extension.id(), |
129 flare_.Run(type); // Tell sync to start ASAP. | 127 CreateSyncData(extension).GetSyncData()); |
130 return; | 128 } else if (extension_service_->is_ready() && !flare_.is_null()) { |
129 flare_.Run(type); // Tell sync to start ASAP. | |
131 } | 130 } |
132 const std::string& id = extension.id(); | |
133 if (bundle->HasExtensionId(id)) | |
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 } | 131 } |
152 | 132 |
153 void ExtensionSyncService::SyncExtensionChangeIfNeeded( | 133 void ExtensionSyncService::SyncExtensionChangeIfNeeded( |
154 const Extension& extension) { | 134 const Extension& extension) { |
155 if (!extensions::util::ShouldSync(&extension, profile_)) | 135 if (!extensions::util::ShouldSync(&extension, profile_)) |
156 return; | 136 return; |
157 | 137 |
158 syncer::ModelType type = | 138 syncer::ModelType type = |
159 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; | 139 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; |
160 SyncBundle* bundle = GetSyncBundle(type); | 140 SyncBundle* bundle = GetSyncBundle(type); |
161 if (bundle->IsSyncing()) | 141 if (bundle->IsSyncing()) { |
162 bundle->PushSyncAddOrUpdate(extension); | 142 bundle->PushSyncAddOrUpdate(extension.id(), |
163 else if (extension_service_->is_ready() && !flare_.is_null()) | 143 CreateSyncData(extension).GetSyncData()); |
164 flare_.Run(type); | 144 DCHECK(!ExtensionPrefs::Get(profile_)->NeedsSync(extension.id())); |
145 } else { | |
146 ExtensionPrefs::Get(profile_)->SetNeedsSync(extension.id(), true); | |
147 if (extension_service_->is_ready() && !flare_.is_null()) | |
148 flare_.Run(type); // Tell sync to start ASAP. | |
149 } | |
165 } | 150 } |
166 | 151 |
167 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( | 152 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( |
168 syncer::ModelType type, | 153 syncer::ModelType type, |
169 const syncer::SyncDataList& initial_sync_data, | 154 const syncer::SyncDataList& initial_sync_data, |
170 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 155 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
171 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { | 156 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
172 CHECK(sync_processor.get()); | 157 CHECK(sync_processor.get()); |
173 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) | 158 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) |
174 << "Got " << type << " ModelType"; | 159 << "Got " << type << " ModelType"; |
175 | 160 |
176 SyncBundle* bundle = GetSyncBundle(type); | 161 SyncBundle* bundle = GetSyncBundle(type); |
177 bool is_apps = (type == syncer::APPS); | 162 bundle->Init(sync_processor.Pass()); |
not at google - send to devlin
2015/07/17 15:28:50
(See "Init" --> "StartSyncing" comment - it's more
| |
178 | 163 |
179 bundle->MergeDataAndStartSyncing(initial_sync_data, sync_processor.Pass()); | 164 // Apply the initial sync data, filtering out any items where we have more |
180 GetPendingEnables(is_apps)->OnSyncStarted(extension_service_); | 165 // recent local changes. Also tell the SyncBundle the extension IDs. |
166 for (const syncer::SyncData& sync_data : initial_sync_data) { | |
167 scoped_ptr<ExtensionSyncData> extension_sync_data( | |
168 ExtensionSyncData::CreateFromSyncData(sync_data)); | |
169 if (extension_sync_data.get()) { | |
not at google - send to devlin
2015/07/17 15:28:50
(incidentally you don't need the .get() calls for
Marc Treib
2015/07/20 09:28:22
Done.
| |
170 bundle->ApplySyncData(*extension_sync_data); | |
not at google - send to devlin
2015/07/17 15:28:50
Why isn't this guarded behind the ExtensionNeedsSy
Marc Treib
2015/07/20 09:28:22
Yeah, that makes sense. Done.
| |
181 | 171 |
182 // Process local extensions. | 172 // If the extension has local state that needs to be synced, ignore this |
183 // TODO(yoz): Determine whether pending extensions should be considered too. | 173 // change (we assume the local state is more recent). |
184 // See crbug.com/104399. | 174 if (!ExtensionNeedsSync(extension_sync_data->id())) |
185 bundle->PushSyncDataList(GetAllSyncData(type)); | 175 ApplySyncData(*extension_sync_data); |
176 } | |
177 } | |
186 | 178 |
187 if (is_apps) | 179 // Now push those local changes to sync. |
180 std::vector<ExtensionSyncData> data_list = GetLocalSyncDataList(type, false); | |
181 bundle->PushSyncDataList(ToSyncerSyncDataList(data_list)); | |
182 for (const ExtensionSyncData& data : data_list) | |
183 ExtensionPrefs::Get(profile_)->SetNeedsSync(data.id(), false); | |
not at google - send to devlin
2015/07/17 15:28:50
I find it a little bit weird that querying this bi
Marc Treib
2015/07/20 09:28:22
Ah, that's from a previous patch set where SyncBun
| |
184 | |
185 if (type == syncer::APPS) | |
188 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); | 186 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); |
189 | 187 |
190 return syncer::SyncMergeResult(type); | 188 return syncer::SyncMergeResult(type); |
191 } | 189 } |
192 | 190 |
193 void ExtensionSyncService::StopSyncing(syncer::ModelType type) { | 191 void ExtensionSyncService::StopSyncing(syncer::ModelType type) { |
194 GetSyncBundle(type)->Reset(); | 192 GetSyncBundle(type)->Reset(); |
195 } | 193 } |
196 | 194 |
197 syncer::SyncDataList ExtensionSyncService::GetAllSyncData( | 195 syncer::SyncDataList ExtensionSyncService::GetAllSyncData( |
198 syncer::ModelType type) const { | 196 syncer::ModelType type) const { |
199 std::vector<ExtensionSyncData> data = GetSyncDataList(type); | 197 const SyncBundle* bundle = GetSyncBundle(type); |
200 syncer::SyncDataList result; | 198 if (!bundle->IsSyncing()) |
201 result.reserve(data.size()); | 199 return syncer::SyncDataList(); |
202 for (const ExtensionSyncData& item : data) | 200 |
203 result.push_back(item.GetSyncData()); | 201 std::vector<extensions::ExtensionSyncData> sync_data_list = |
204 return result; | 202 GetLocalSyncDataList(type, true); |
203 | |
204 // Add pending data (where the local extension is either not installed yet or | |
205 // outdated). | |
206 std::vector<ExtensionSyncData> pending_extensions = bundle->GetPendingData(); | |
207 sync_data_list.insert(sync_data_list.begin(), | |
208 pending_extensions.begin(), | |
209 pending_extensions.end()); | |
210 | |
211 return ToSyncerSyncDataList(sync_data_list); | |
205 } | 212 } |
206 | 213 |
207 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( | 214 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( |
208 const tracked_objects::Location& from_here, | 215 const tracked_objects::Location& from_here, |
209 const syncer::SyncChangeList& change_list) { | 216 const syncer::SyncChangeList& change_list) { |
210 for (const syncer::SyncChange& sync_change : change_list) { | 217 for (const syncer::SyncChange& sync_change : change_list) { |
211 syncer::ModelType type = sync_change.sync_data().GetDataType(); | 218 scoped_ptr<ExtensionSyncData> extension_sync_data( |
212 GetSyncBundle(type)->ApplySyncChange(sync_change); | 219 ExtensionSyncData::CreateFromSyncChange(sync_change)); |
220 if (extension_sync_data.get()) { | |
221 syncer::ModelType type = sync_change.sync_data().GetDataType(); | |
222 GetSyncBundle(type)->ApplySyncData(*extension_sync_data); | |
223 ApplySyncData(*extension_sync_data); | |
224 } | |
213 } | 225 } |
214 | 226 |
215 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); | 227 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); |
216 | 228 |
217 return syncer::SyncError(); | 229 return syncer::SyncError(); |
218 } | 230 } |
219 | 231 |
220 ExtensionSyncData ExtensionSyncService::CreateSyncData( | 232 ExtensionSyncData ExtensionSyncService::CreateSyncData( |
221 const extensions::Extension& extension) const { | 233 const extensions::Extension& extension) const { |
222 bool enabled = extension_service_->IsExtensionEnabled(extension.id()); | 234 bool enabled = extension_service_->IsExtensionEnabled(extension.id()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 285 |
274 if (!ApplyExtensionSyncDataHelper(extension_sync_data, type)) { | 286 if (!ApplyExtensionSyncDataHelper(extension_sync_data, type)) { |
275 GetSyncBundle(type)->AddPendingExtension(id, extension_sync_data); | 287 GetSyncBundle(type)->AddPendingExtension(id, extension_sync_data); |
276 extension_service_->CheckForUpdatesSoon(); | 288 extension_service_->CheckForUpdatesSoon(); |
277 return false; | 289 return false; |
278 } | 290 } |
279 | 291 |
280 return true; | 292 return true; |
281 } | 293 } |
282 | 294 |
295 bool ExtensionSyncService::ExtensionNeedsSync( | |
296 const std::string& extension_id) const { | |
297 return ExtensionPrefs::Get(profile_)->NeedsSync(extension_id); | |
298 } | |
299 | |
283 void ExtensionSyncService::ApplyBookmarkAppSyncData( | 300 void ExtensionSyncService::ApplyBookmarkAppSyncData( |
284 const extensions::ExtensionSyncData& extension_sync_data) { | 301 const extensions::ExtensionSyncData& extension_sync_data) { |
285 DCHECK(extension_sync_data.is_app()); | 302 DCHECK(extension_sync_data.is_app()); |
286 | 303 |
287 // Process bookmark app sync if necessary. | 304 // Process bookmark app sync if necessary. |
288 GURL bookmark_app_url(extension_sync_data.bookmark_app_url()); | 305 GURL bookmark_app_url(extension_sync_data.bookmark_app_url()); |
289 if (!bookmark_app_url.is_valid() || | 306 if (!bookmark_app_url.is_valid() || |
290 extension_sync_data.uninstalled()) { | 307 extension_sync_data.uninstalled()) { |
291 return; | 308 return; |
292 } | 309 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 | 355 |
339 if (ext) | 356 if (ext) |
340 SyncExtensionChangeIfNeeded(*ext); | 357 SyncExtensionChangeIfNeeded(*ext); |
341 } | 358 } |
342 | 359 |
343 void ExtensionSyncService::SetSyncStartFlare( | 360 void ExtensionSyncService::SetSyncStartFlare( |
344 const syncer::SyncableService::StartSyncFlare& flare) { | 361 const syncer::SyncableService::StartSyncFlare& flare) { |
345 flare_ = flare; | 362 flare_ = flare; |
346 } | 363 } |
347 | 364 |
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) { | 365 SyncBundle* ExtensionSyncService::GetSyncBundle(syncer::ModelType type) { |
355 return const_cast<SyncBundle*>( | 366 return const_cast<SyncBundle*>( |
356 const_cast<const ExtensionSyncService&>(*this).GetSyncBundle(type)); | 367 const_cast<const ExtensionSyncService&>(*this).GetSyncBundle(type)); |
357 } | 368 } |
358 | 369 |
359 const SyncBundle* ExtensionSyncService::GetSyncBundle( | 370 const SyncBundle* ExtensionSyncService::GetSyncBundle( |
360 syncer::ModelType type) const { | 371 syncer::ModelType type) const { |
361 return (type == syncer::APPS) ? &app_sync_bundle_ : &extension_sync_bundle_; | 372 return (type == syncer::APPS) ? &app_sync_bundle_ : &extension_sync_bundle_; |
362 } | 373 } |
363 | 374 |
364 extensions::PendingEnables* ExtensionSyncService::GetPendingEnables( | 375 std::vector<ExtensionSyncData> ExtensionSyncService::GetLocalSyncDataList( |
365 bool is_apps) { | 376 syncer::ModelType type, |
366 return is_apps ? &pending_app_enables_ : &pending_extension_enables_; | 377 bool include_everything) const { |
367 } | 378 // Collect the local state. FillSyncDataList will filter out extensions for |
368 | 379 // 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_); | 380 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
372 std::vector<ExtensionSyncData> extension_sync_list; | 381 std::vector<ExtensionSyncData> data; |
373 FillSyncDataList(registry->enabled_extensions(), type, &extension_sync_list); | |
374 FillSyncDataList(registry->disabled_extensions(), type, &extension_sync_list); | |
375 FillSyncDataList( | 382 FillSyncDataList( |
not at google - send to devlin
2015/07/17 15:28:50
Could you add:
// TODO(trieb): Should we be inclu
Marc Treib
2015/07/20 09:28:22
Sure, done. I've also added your name in the TODO(
| |
376 registry->terminated_extensions(), type, &extension_sync_list); | 383 registry->enabled_extensions(), type, include_everything, &data); |
377 | 384 FillSyncDataList( |
378 std::vector<ExtensionSyncData> pending_extensions = | 385 registry->disabled_extensions(), type, include_everything, &data); |
379 GetSyncBundle(type)->GetPendingData(); | 386 FillSyncDataList( |
380 extension_sync_list.insert(extension_sync_list.begin(), | 387 registry->terminated_extensions(), type, include_everything, &data); |
381 pending_extensions.begin(), | 388 return data; |
382 pending_extensions.end()); | |
383 | |
384 return extension_sync_list; | |
385 } | 389 } |
386 | 390 |
387 void ExtensionSyncService::FillSyncDataList( | 391 void ExtensionSyncService::FillSyncDataList( |
388 const ExtensionSet& extensions, | 392 const ExtensionSet& extensions, |
389 syncer::ModelType type, | 393 syncer::ModelType type, |
394 bool include_everything, | |
390 std::vector<ExtensionSyncData>* sync_data_list) const { | 395 std::vector<ExtensionSyncData>* sync_data_list) const { |
391 const SyncBundle* bundle = GetSyncBundle(type); | 396 const SyncBundle* bundle = GetSyncBundle(type); |
392 for (const scoped_refptr<const Extension>& extension : extensions) { | 397 for (const scoped_refptr<const Extension>& extension : extensions) { |
393 if (IsCorrectSyncType(*extension, type) && | 398 if (IsCorrectSyncType(*extension, type) && |
394 extensions::util::ShouldSync(extension.get(), profile_) && | 399 extensions::util::ShouldSync(extension.get(), profile_) && |
395 bundle->ShouldIncludeInLocalSyncDataList(*extension)) { | 400 !bundle->HasPendingExtensionId(extension->id()) && |
401 (include_everything || ExtensionNeedsSync(extension->id()))) { | |
396 sync_data_list->push_back(CreateSyncData(*extension)); | 402 sync_data_list->push_back(CreateSyncData(*extension)); |
397 } | 403 } |
398 } | 404 } |
399 } | 405 } |
400 | 406 |
401 bool ExtensionSyncService::ApplyExtensionSyncDataHelper( | 407 bool ExtensionSyncService::ApplyExtensionSyncDataHelper( |
402 const ExtensionSyncData& extension_sync_data, | 408 const ExtensionSyncData& extension_sync_data, |
403 syncer::ModelType type) { | 409 syncer::ModelType type) { |
404 const std::string& id = extension_sync_data.id(); | 410 const std::string& id = extension_sync_data.id(); |
405 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 411 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 | 447 // local one. Otherwise we just enable it without granting permissions. If |
442 // any permissions are missing, CheckPermissionsIncrease will soon disable | 448 // any permissions are missing, CheckPermissionsIncrease will soon disable |
443 // it again. | 449 // it again. |
444 bool grant_permissions = | 450 bool grant_permissions = |
445 extension_sync_data.supports_disable_reasons() && | 451 extension_sync_data.supports_disable_reasons() && |
446 extension && (version_compare_result == 0); | 452 extension && (version_compare_result == 0); |
447 if (grant_permissions) | 453 if (grant_permissions) |
448 extension_service_->GrantPermissionsAndEnableExtension(extension); | 454 extension_service_->GrantPermissionsAndEnableExtension(extension); |
449 else | 455 else |
450 extension_service_->EnableExtension(id); | 456 extension_service_->EnableExtension(id); |
451 } else if (!IsPendingEnable(id)) { | 457 } else { |
452 int disable_reasons = extension_sync_data.disable_reasons(); | 458 int disable_reasons = extension_sync_data.disable_reasons(); |
453 if (extension_sync_data.remote_install()) { | 459 if (extension_sync_data.remote_install()) { |
454 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { | 460 if (!(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { |
455 // In the non-legacy case (>=M45) where disable reasons are synced at | 461 // In the non-legacy case (>=M45) where disable reasons are synced at |
456 // all, DISABLE_REMOTE_INSTALL should be among them already. | 462 // all, DISABLE_REMOTE_INSTALL should be among them already. |
457 DCHECK(!extension_sync_data.supports_disable_reasons()); | 463 DCHECK(!extension_sync_data.supports_disable_reasons()); |
458 disable_reasons |= Extension::DISABLE_REMOTE_INSTALL; | 464 disable_reasons |= Extension::DISABLE_REMOTE_INSTALL; |
459 } | 465 } |
460 } else if (!extension_sync_data.supports_disable_reasons()) { | 466 } else if (!extension_sync_data.supports_disable_reasons()) { |
461 // Legacy case (<M45), from before we synced disable reasons (see | 467 // 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 | 519 // 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 | 520 // never be removed (we'll never install a syncable version of the |
515 // extension), so that GetAllSyncData() continues to send it. | 521 // extension), so that GetAllSyncData() continues to send it. |
516 } | 522 } |
517 // Track pending extensions so that we can return them in GetAllSyncData(). | 523 // Track pending extensions so that we can return them in GetAllSyncData(). |
518 return false; | 524 return false; |
519 } | 525 } |
520 | 526 |
521 return true; | 527 return true; |
522 } | 528 } |
OLD | NEW |