| 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/sync/test/integration/profile_sync_service_harness.h" | 5 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 + std::string(syncer::ModelTypeToString(datatype)) + ")"); | 322 + std::string(syncer::ModelTypeToString(datatype)) + ")"); |
| 323 | 323 |
| 324 if (IsSyncDisabled()) | 324 if (IsSyncDisabled()) |
| 325 return SetupSync(syncer::ModelTypeSet(datatype)); | 325 return SetupSync(syncer::ModelTypeSet(datatype)); |
| 326 | 326 |
| 327 if (service() == nullptr) { | 327 if (service() == nullptr) { |
| 328 LOG(ERROR) << "EnableSyncForDatatype(): service() is null."; | 328 LOG(ERROR) << "EnableSyncForDatatype(): service() is null."; |
| 329 return false; | 329 return false; |
| 330 } | 330 } |
| 331 | 331 |
| 332 if (!syncer::UserSelectableTypes().Has(datatype)) { |
| 333 LOG(ERROR) << "Can only enable user selectable types, requested " |
| 334 << syncer::ModelTypeToString(datatype); |
| 335 return false; |
| 336 } |
| 337 |
| 332 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes(); | 338 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes(); |
| 333 if (synced_datatypes.Has(datatype)) { | 339 if (synced_datatypes.Has(datatype)) { |
| 334 DVLOG(1) << "EnableSyncForDatatype(): Sync already enabled for datatype " | 340 DVLOG(1) << "EnableSyncForDatatype(): Sync already enabled for datatype " |
| 335 << syncer::ModelTypeToString(datatype) | 341 << syncer::ModelTypeToString(datatype) |
| 336 << " on " << profile_debug_name_ << "."; | 342 << " on " << profile_debug_name_ << "."; |
| 337 return true; | 343 return true; |
| 338 } | 344 } |
| 339 | 345 |
| 340 synced_datatypes.Put(syncer::ModelTypeFromInt(datatype)); | 346 synced_datatypes.Put(syncer::ModelTypeFromInt(datatype)); |
| 341 synced_datatypes.RetainAll(syncer::UserSelectableTypes()); | 347 synced_datatypes.RetainAll(syncer::UserSelectableTypes()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 355 syncer::ModelType datatype) { | 361 syncer::ModelType datatype) { |
| 356 DVLOG(1) << GetClientInfoString( | 362 DVLOG(1) << GetClientInfoString( |
| 357 "DisableSyncForDatatype(" | 363 "DisableSyncForDatatype(" |
| 358 + std::string(syncer::ModelTypeToString(datatype)) + ")"); | 364 + std::string(syncer::ModelTypeToString(datatype)) + ")"); |
| 359 | 365 |
| 360 if (service() == nullptr) { | 366 if (service() == nullptr) { |
| 361 LOG(ERROR) << "DisableSyncForDatatype(): service() is null."; | 367 LOG(ERROR) << "DisableSyncForDatatype(): service() is null."; |
| 362 return false; | 368 return false; |
| 363 } | 369 } |
| 364 | 370 |
| 371 if (!syncer::UserSelectableTypes().Has(datatype)) { |
| 372 LOG(ERROR) << "Can only disable user selectable types, requested " |
| 373 << syncer::ModelTypeToString(datatype); |
| 374 return false; |
| 375 } |
| 376 |
| 365 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes(); | 377 syncer::ModelTypeSet synced_datatypes = service()->GetPreferredDataTypes(); |
| 366 if (!synced_datatypes.Has(datatype)) { | 378 if (!synced_datatypes.Has(datatype)) { |
| 367 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype " | 379 DVLOG(1) << "DisableSyncForDatatype(): Sync already disabled for datatype " |
| 368 << syncer::ModelTypeToString(datatype) | 380 << syncer::ModelTypeToString(datatype) |
| 369 << " on " << profile_debug_name_ << "."; | 381 << " on " << profile_debug_name_ << "."; |
| 370 return true; | 382 return true; |
| 371 } | 383 } |
| 372 | 384 |
| 373 synced_datatypes.RetainAll(syncer::UserSelectableTypes()); | 385 synced_datatypes.RetainAll(syncer::UserSelectableTypes()); |
| 374 synced_datatypes.Remove(datatype); | 386 synced_datatypes.Remove(datatype); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 476 |
| 465 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 477 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
| 466 std::unique_ptr<base::DictionaryValue> value( | 478 std::unique_ptr<base::DictionaryValue> value( |
| 467 syncer::sync_ui_util::ConstructAboutInformation( | 479 syncer::sync_ui_util::ConstructAboutInformation( |
| 468 service(), service()->signin(), chrome::GetChannel())); | 480 service(), service()->signin(), chrome::GetChannel())); |
| 469 std::string service_status; | 481 std::string service_status; |
| 470 base::JSONWriter::WriteWithOptions( | 482 base::JSONWriter::WriteWithOptions( |
| 471 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); | 483 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); |
| 472 return service_status; | 484 return service_status; |
| 473 } | 485 } |
| OLD | NEW |