| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/api/preferences_private/preferences_private_
api.h" | 5 #include "chrome/browser/extensions/api/preferences_private/preferences_private_
api.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/sync/profile_sync_service.h" | 8 #include "chrome/browser/sync/profile_sync_service.h" |
| 9 #include "chrome/browser/sync/profile_sync_service_factory.h" | 9 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 10 #include "chrome/browser/sync/sync_prefs.h" | |
| 11 #include "chrome/common/extensions/api/preferences_private.h" | 10 #include "chrome/common/extensions/api/preferences_private.h" |
| 11 #include "components/sync_driver/sync_prefs.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 namespace GetSyncCategoriesWithoutPassphrase = | 15 namespace GetSyncCategoriesWithoutPassphrase = |
| 16 api::preferences_private::GetSyncCategoriesWithoutPassphrase; | 16 api::preferences_private::GetSyncCategoriesWithoutPassphrase; |
| 17 | 17 |
| 18 PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction:: | 18 PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction:: |
| 19 PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction() {} | 19 PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction() {} |
| 20 | 20 |
| 21 PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction:: | 21 PreferencesPrivateGetSyncCategoriesWithoutPassphraseFunction:: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 return false; | 39 return false; |
| 40 if (!sync_service->sync_initialized()) { | 40 if (!sync_service->sync_initialized()) { |
| 41 AddRef(); // Balanced in OnStateChanged(). | 41 AddRef(); // Balanced in OnStateChanged(). |
| 42 sync_service->AddObserver(this); | 42 sync_service->AddObserver(this); |
| 43 return true; | 43 return true; |
| 44 } | 44 } |
| 45 | 45 |
| 46 syncer::ModelTypeSet result_set = syncer::UserSelectableTypes(); | 46 syncer::ModelTypeSet result_set = syncer::UserSelectableTypes(); |
| 47 | 47 |
| 48 // Only include categories that are synced. | 48 // Only include categories that are synced. |
| 49 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); | 49 sync_driver::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); |
| 50 if (!sync_prefs.HasKeepEverythingSynced()) { | 50 if (!sync_prefs.HasKeepEverythingSynced()) { |
| 51 result_set = syncer::Intersection(result_set, | 51 result_set = syncer::Intersection(result_set, |
| 52 sync_service->GetPreferredDataTypes()); | 52 sync_service->GetPreferredDataTypes()); |
| 53 } | 53 } |
| 54 // Don't include encrypted categories. | 54 // Don't include encrypted categories. |
| 55 result_set = syncer::Difference(result_set, | 55 result_set = syncer::Difference(result_set, |
| 56 sync_service->GetEncryptedDataTypes()); | 56 sync_service->GetEncryptedDataTypes()); |
| 57 | 57 |
| 58 std::vector<std::string> categories; | 58 std::vector<std::string> categories; |
| 59 for (syncer::ModelTypeSet::Iterator it = result_set.First(); it.Good(); | 59 for (syncer::ModelTypeSet::Iterator it = result_set.First(); it.Good(); |
| 60 it.Inc()) { | 60 it.Inc()) { |
| 61 categories.push_back(syncer::ModelTypeToString(it.Get())); | 61 categories.push_back(syncer::ModelTypeToString(it.Get())); |
| 62 } | 62 } |
| 63 | 63 |
| 64 results_ = GetSyncCategoriesWithoutPassphrase::Results::Create(categories); | 64 results_ = GetSyncCategoriesWithoutPassphrase::Results::Create(categories); |
| 65 SendResponse(true); | 65 SendResponse(true); |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace extensions | 69 } // namespace extensions |
| OLD | NEW |