| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "components/sync/syncable/nigori_util.h" | 5 #include "components/sync/syncable/nigori_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 DVLOG(1) << "Overwriting specifics of type " << ModelTypeToString(type) | 239 DVLOG(1) << "Overwriting specifics of type " << ModelTypeToString(type) |
| 240 << " and marking for syncing."; | 240 << " and marking for syncing."; |
| 241 syncable::MarkForSyncing(entry); | 241 syncable::MarkForSyncing(entry); |
| 242 return true; | 242 return true; |
| 243 } | 243 } |
| 244 | 244 |
| 245 void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, | 245 void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types, |
| 246 bool encrypt_everything, | 246 bool encrypt_everything, |
| 247 sync_pb::NigoriSpecifics* nigori) { | 247 sync_pb::NigoriSpecifics* nigori) { |
| 248 nigori->set_encrypt_everything(encrypt_everything); | 248 nigori->set_encrypt_everything(encrypt_everything); |
| 249 static_assert(39 == MODEL_TYPE_COUNT, "update encrypted types"); | 249 static_assert(39 == MODEL_TYPE_COUNT, |
| 250 "If adding an encryptable type, update handling below."); |
| 250 nigori->set_encrypt_bookmarks(encrypted_types.Has(BOOKMARKS)); | 251 nigori->set_encrypt_bookmarks(encrypted_types.Has(BOOKMARKS)); |
| 251 nigori->set_encrypt_preferences(encrypted_types.Has(PREFERENCES)); | 252 nigori->set_encrypt_preferences(encrypted_types.Has(PREFERENCES)); |
| 252 nigori->set_encrypt_autofill_profile(encrypted_types.Has(AUTOFILL_PROFILE)); | 253 nigori->set_encrypt_autofill_profile(encrypted_types.Has(AUTOFILL_PROFILE)); |
| 253 nigori->set_encrypt_autofill(encrypted_types.Has(AUTOFILL)); | 254 nigori->set_encrypt_autofill(encrypted_types.Has(AUTOFILL)); |
| 254 nigori->set_encrypt_autofill_wallet_metadata( | 255 nigori->set_encrypt_autofill_wallet_metadata( |
| 255 encrypted_types.Has(AUTOFILL_WALLET_METADATA)); | 256 encrypted_types.Has(AUTOFILL_WALLET_METADATA)); |
| 256 nigori->set_encrypt_themes(encrypted_types.Has(THEMES)); | 257 nigori->set_encrypt_themes(encrypted_types.Has(THEMES)); |
| 257 nigori->set_encrypt_typed_urls(encrypted_types.Has(TYPED_URLS)); | 258 nigori->set_encrypt_typed_urls(encrypted_types.Has(TYPED_URLS)); |
| 258 nigori->set_encrypt_extension_settings( | |
| 259 encrypted_types.Has(EXTENSION_SETTINGS)); | |
| 260 nigori->set_encrypt_extensions(encrypted_types.Has(EXTENSIONS)); | 259 nigori->set_encrypt_extensions(encrypted_types.Has(EXTENSIONS)); |
| 261 nigori->set_encrypt_search_engines(encrypted_types.Has(SEARCH_ENGINES)); | 260 nigori->set_encrypt_search_engines(encrypted_types.Has(SEARCH_ENGINES)); |
| 262 nigori->set_encrypt_sessions(encrypted_types.Has(SESSIONS)); | 261 nigori->set_encrypt_sessions(encrypted_types.Has(SESSIONS)); |
| 262 nigori->set_encrypt_apps(encrypted_types.Has(APPS)); |
| 263 nigori->set_encrypt_app_settings(encrypted_types.Has(APP_SETTINGS)); | 263 nigori->set_encrypt_app_settings(encrypted_types.Has(APP_SETTINGS)); |
| 264 nigori->set_encrypt_apps(encrypted_types.Has(APPS)); | 264 nigori->set_encrypt_extension_settings( |
| 265 encrypted_types.Has(EXTENSION_SETTINGS)); |
| 265 nigori->set_encrypt_app_notifications(encrypted_types.Has(APP_NOTIFICATIONS)); | 266 nigori->set_encrypt_app_notifications(encrypted_types.Has(APP_NOTIFICATIONS)); |
| 266 nigori->set_encrypt_dictionary(encrypted_types.Has(DICTIONARY)); | 267 nigori->set_encrypt_dictionary(encrypted_types.Has(DICTIONARY)); |
| 267 nigori->set_encrypt_favicon_images(encrypted_types.Has(FAVICON_IMAGES)); | 268 nigori->set_encrypt_favicon_images(encrypted_types.Has(FAVICON_IMAGES)); |
| 268 nigori->set_encrypt_favicon_tracking(encrypted_types.Has(FAVICON_TRACKING)); | 269 nigori->set_encrypt_favicon_tracking(encrypted_types.Has(FAVICON_TRACKING)); |
| 269 nigori->set_encrypt_articles(encrypted_types.Has(ARTICLES)); | 270 nigori->set_encrypt_articles(encrypted_types.Has(ARTICLES)); |
| 270 nigori->set_encrypt_app_list(encrypted_types.Has(APP_LIST)); | 271 nigori->set_encrypt_app_list(encrypted_types.Has(APP_LIST)); |
| 271 nigori->set_encrypt_arc_package(encrypted_types.Has(ARC_PACKAGE)); | 272 nigori->set_encrypt_arc_package(encrypted_types.Has(ARC_PACKAGE)); |
| 272 nigori->set_encrypt_printers(encrypted_types.Has(PRINTERS)); | 273 nigori->set_encrypt_printers(encrypted_types.Has(PRINTERS)); |
| 273 nigori->set_encrypt_reading_list(encrypted_types.Has(READING_LIST)); | 274 nigori->set_encrypt_reading_list(encrypted_types.Has(READING_LIST)); |
| 274 } | 275 } |
| 275 | 276 |
| 276 ModelTypeSet GetEncryptedTypesFromNigori( | 277 ModelTypeSet GetEncryptedTypesFromNigori( |
| 277 const sync_pb::NigoriSpecifics& nigori) { | 278 const sync_pb::NigoriSpecifics& nigori) { |
| 278 if (nigori.encrypt_everything()) | 279 if (nigori.encrypt_everything()) |
| 279 return ModelTypeSet::All(); | 280 return ModelTypeSet::All(); |
| 280 | 281 |
| 281 ModelTypeSet encrypted_types; | 282 ModelTypeSet encrypted_types; |
| 282 static_assert(39 == MODEL_TYPE_COUNT, "update encrypted types"); | 283 static_assert(39 == MODEL_TYPE_COUNT, |
| 284 "If adding an encryptable type, update handling below."); |
| 283 if (nigori.encrypt_bookmarks()) | 285 if (nigori.encrypt_bookmarks()) |
| 284 encrypted_types.Put(BOOKMARKS); | 286 encrypted_types.Put(BOOKMARKS); |
| 285 if (nigori.encrypt_preferences()) | 287 if (nigori.encrypt_preferences()) |
| 286 encrypted_types.Put(PREFERENCES); | 288 encrypted_types.Put(PREFERENCES); |
| 287 if (nigori.encrypt_autofill_profile()) | 289 if (nigori.encrypt_autofill_profile()) |
| 288 encrypted_types.Put(AUTOFILL_PROFILE); | 290 encrypted_types.Put(AUTOFILL_PROFILE); |
| 289 if (nigori.encrypt_autofill()) | 291 if (nigori.encrypt_autofill()) |
| 290 encrypted_types.Put(AUTOFILL); | 292 encrypted_types.Put(AUTOFILL); |
| 291 if (nigori.encrypt_autofill_wallet_metadata()) | 293 if (nigori.encrypt_autofill_wallet_metadata()) |
| 292 encrypted_types.Put(AUTOFILL_WALLET_METADATA); | 294 encrypted_types.Put(AUTOFILL_WALLET_METADATA); |
| 293 if (nigori.encrypt_themes()) | 295 if (nigori.encrypt_themes()) |
| 294 encrypted_types.Put(THEMES); | 296 encrypted_types.Put(THEMES); |
| 295 if (nigori.encrypt_typed_urls()) | 297 if (nigori.encrypt_typed_urls()) |
| 296 encrypted_types.Put(TYPED_URLS); | 298 encrypted_types.Put(TYPED_URLS); |
| 297 if (nigori.encrypt_extension_settings()) | |
| 298 encrypted_types.Put(EXTENSION_SETTINGS); | |
| 299 if (nigori.encrypt_extensions()) | 299 if (nigori.encrypt_extensions()) |
| 300 encrypted_types.Put(EXTENSIONS); | 300 encrypted_types.Put(EXTENSIONS); |
| 301 if (nigori.encrypt_search_engines()) | 301 if (nigori.encrypt_search_engines()) |
| 302 encrypted_types.Put(SEARCH_ENGINES); | 302 encrypted_types.Put(SEARCH_ENGINES); |
| 303 if (nigori.encrypt_sessions()) | 303 if (nigori.encrypt_sessions()) |
| 304 encrypted_types.Put(SESSIONS); | 304 encrypted_types.Put(SESSIONS); |
| 305 if (nigori.encrypt_apps()) |
| 306 encrypted_types.Put(APPS); |
| 305 if (nigori.encrypt_app_settings()) | 307 if (nigori.encrypt_app_settings()) |
| 306 encrypted_types.Put(APP_SETTINGS); | 308 encrypted_types.Put(APP_SETTINGS); |
| 307 if (nigori.encrypt_apps()) | 309 if (nigori.encrypt_extension_settings()) |
| 308 encrypted_types.Put(APPS); | 310 encrypted_types.Put(EXTENSION_SETTINGS); |
| 309 if (nigori.encrypt_app_notifications()) | 311 if (nigori.encrypt_app_notifications()) |
| 310 encrypted_types.Put(APP_NOTIFICATIONS); | 312 encrypted_types.Put(APP_NOTIFICATIONS); |
| 311 if (nigori.encrypt_dictionary()) | 313 if (nigori.encrypt_dictionary()) |
| 312 encrypted_types.Put(DICTIONARY); | 314 encrypted_types.Put(DICTIONARY); |
| 313 if (nigori.encrypt_favicon_images()) | 315 if (nigori.encrypt_favicon_images()) |
| 314 encrypted_types.Put(FAVICON_IMAGES); | 316 encrypted_types.Put(FAVICON_IMAGES); |
| 315 if (nigori.encrypt_favicon_tracking()) | 317 if (nigori.encrypt_favicon_tracking()) |
| 316 encrypted_types.Put(FAVICON_TRACKING); | 318 encrypted_types.Put(FAVICON_TRACKING); |
| 317 if (nigori.encrypt_articles()) | 319 if (nigori.encrypt_articles()) |
| 318 encrypted_types.Put(ARTICLES); | 320 encrypted_types.Put(ARTICLES); |
| 319 if (nigori.encrypt_app_list()) | 321 if (nigori.encrypt_app_list()) |
| 320 encrypted_types.Put(APP_LIST); | 322 encrypted_types.Put(APP_LIST); |
| 321 if (nigori.encrypt_arc_package()) | 323 if (nigori.encrypt_arc_package()) |
| 322 encrypted_types.Put(ARC_PACKAGE); | 324 encrypted_types.Put(ARC_PACKAGE); |
| 323 if (nigori.encrypt_printers()) | 325 if (nigori.encrypt_printers()) |
| 324 encrypted_types.Put(PRINTERS); | 326 encrypted_types.Put(PRINTERS); |
| 325 if (nigori.encrypt_reading_list()) | 327 if (nigori.encrypt_reading_list()) |
| 326 encrypted_types.Put(READING_LIST); | 328 encrypted_types.Put(READING_LIST); |
| 327 return encrypted_types; | 329 return encrypted_types; |
| 328 } | 330 } |
| 329 | 331 |
| 330 } // namespace syncable | 332 } // namespace syncable |
| 331 } // namespace syncer | 333 } // namespace syncer |
| OLD | NEW |