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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 | 98 |
| 99 syncer::SyncDataList ToSyncerSyncDataList( | 99 syncer::SyncDataList ToSyncerSyncDataList( |
| 100 const std::vector<ExtensionSyncData>& data) { | 100 const std::vector<ExtensionSyncData>& data) { |
| 101 syncer::SyncDataList result; | 101 syncer::SyncDataList result; |
| 102 result.reserve(data.size()); | 102 result.reserve(data.size()); |
| 103 for (const ExtensionSyncData& item : data) | 103 for (const ExtensionSyncData& item : data) |
| 104 result.push_back(item.GetSyncData()); | 104 result.push_back(item.GetSyncData()); |
| 105 return result; | 105 return result; |
| 106 } | 106 } |
| 107 | 107 |
| 108 static_assert(Extension::DISABLE_REASON_LAST == (1 << 15), | 108 static_assert(Extension::DISABLE_REASON_LAST == (1 << 16), |
| 109 "Please consider whether your new disable reason should be" | 109 "Please consider whether your new disable reason should be" |
| 110 " syncable, and if so update this bitmask accordingly!"); | 110 " syncable, and if so update this bitmask accordingly!"); |
| 111 const int kKnownSyncableDisableReasons = | 111 const int kKnownSyncableDisableReasons = |
| 112 Extension::DISABLE_USER_ACTION | | 112 Extension::DISABLE_USER_ACTION | |
| 113 Extension::DISABLE_PERMISSIONS_INCREASE | | 113 Extension::DISABLE_PERMISSIONS_INCREASE | |
| 114 Extension::DISABLE_SIDELOAD_WIPEOUT | | 114 Extension::DISABLE_SIDELOAD_WIPEOUT | |
| 115 Extension::DISABLE_GREYLIST | | 115 Extension::DISABLE_GREYLIST | |
| 116 Extension::DISABLE_REMOTE_INSTALL; | 116 Extension::DISABLE_REMOTE_INSTALL; |
| 117 const int kAllKnownDisableReasons = Extension::DISABLE_REASON_LAST - 1; | 117 const int kAllKnownDisableReasons = Extension::DISABLE_REASON_LAST - 1; |
| 118 // We also include any future bits for newer clients that added another disable | 118 // We also include any future bits for newer clients that added another disable |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 enabled = enabled && | 275 enabled = enabled && |
| 276 extension_prefs->GetExtensionBlacklistState(extension.id()) == | 276 extension_prefs->GetExtensionBlacklistState(extension.id()) == |
| 277 extensions::NOT_BLACKLISTED; | 277 extensions::NOT_BLACKLISTED; |
| 278 bool incognito_enabled = extensions::util::IsIncognitoEnabled(id, profile_); | 278 bool incognito_enabled = extensions::util::IsIncognitoEnabled(id, profile_); |
| 279 bool remote_install = | 279 bool remote_install = |
| 280 extension_prefs->HasDisableReason(id, Extension::DISABLE_REMOTE_INSTALL); | 280 extension_prefs->HasDisableReason(id, Extension::DISABLE_REMOTE_INSTALL); |
| 281 ExtensionSyncData::OptionalBoolean allowed_on_all_url = | 281 ExtensionSyncData::OptionalBoolean allowed_on_all_url = |
| 282 GetAllowedOnAllUrlsOptionalBoolean(id, profile_); | 282 GetAllowedOnAllUrlsOptionalBoolean(id, profile_); |
| 283 AppSorting* app_sorting = ExtensionSystem::Get(profile_)->app_sorting(); | 283 AppSorting* app_sorting = ExtensionSystem::Get(profile_)->app_sorting(); |
| 284 | 284 |
| 285 ExtensionSyncData result = extension.is_app() | 285 ExtensionSyncData result = |
| 286 ? ExtensionSyncData( | 286 extension.is_app() |
|
Marc Treib
2016/05/23 15:32:42
Also here: Please avoid unrelated formatting chang
mamir
2016/05/23 19:35:14
I got confused while moving between different bran
| |
| 287 extension, enabled, disable_reasons, incognito_enabled, | 287 ? ExtensionSyncData( |
| 288 remote_install, allowed_on_all_url, | 288 extension, enabled, disable_reasons, incognito_enabled, |
| 289 app_sorting->GetAppLaunchOrdinal(id), | 289 remote_install, allowed_on_all_url, |
| 290 app_sorting->GetPageOrdinal(id), | 290 app_sorting->GetAppLaunchOrdinal(id), |
| 291 extensions::GetLaunchTypePrefValue(extension_prefs, id)) | 291 app_sorting->GetPageOrdinal(id), |
| 292 : ExtensionSyncData( | 292 extensions::GetLaunchTypePrefValue(extension_prefs, id)) |
| 293 extension, enabled, disable_reasons, incognito_enabled, | 293 : ExtensionSyncData(extension, enabled, disable_reasons, |
| 294 remote_install, allowed_on_all_url); | 294 incognito_enabled, remote_install, |
| 295 allowed_on_all_url); | |
| 295 | 296 |
| 296 // If there's a pending update, send the new version to sync instead of the | 297 // If there's a pending update, send the new version to sync instead of the |
| 297 // installed one. | 298 // installed one. |
| 298 auto it = pending_updates_.find(id); | 299 auto it = pending_updates_.find(id); |
| 299 if (it != pending_updates_.end()) { | 300 if (it != pending_updates_.end()) { |
| 300 const base::Version& version = it->second.version; | 301 const base::Version& version = it->second.version; |
| 301 // If we have a pending version, it should be newer than the installed one. | 302 // If we have a pending version, it should be newer than the installed one. |
| 302 DCHECK_EQ(-1, extension.version()->CompareTo(version)); | 303 DCHECK_EQ(-1, extension.version()->CompareTo(version)); |
| 303 result.set_version(version); | 304 result.set_version(version); |
| 304 // If we'll re-enable the extension once it's updated, also send that back | 305 // If we'll re-enable the extension once it's updated, also send that back |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 sync_data_list->push_back(CreateSyncData(*extension)); | 704 sync_data_list->push_back(CreateSyncData(*extension)); |
| 704 } | 705 } |
| 705 } | 706 } |
| 706 } | 707 } |
| 707 | 708 |
| 708 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { | 709 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { |
| 709 // Themes are handled by the ThemeSyncableService. | 710 // Themes are handled by the ThemeSyncableService. |
| 710 return extensions::util::ShouldSync(&extension, profile_) && | 711 return extensions::util::ShouldSync(&extension, profile_) && |
| 711 !extension.is_theme(); | 712 !extension.is_theme(); |
| 712 } | 713 } |
| OLD | NEW |