Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(833)

Unified Diff: chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc

Issue 2289163003: arc: Add arc enable sync pref initial set up. (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc
diff --git a/chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc b/chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc
index 0efa35fa35e1cff7ba746552468dee7e80390cae..e4d462826d918013b88bb284bc71bd516e998c7b 100644
--- a/chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc
+++ b/chrome/browser/ui/app_list/arc/arc_package_syncable_service.cc
@@ -15,6 +15,7 @@
#include "components/sync/api/sync_change_processor.h"
#include "components/sync/api/sync_data.h"
#include "components/sync/api/sync_merge_result.h"
+#include "components/sync/driver/pref_names.h"
#include "components/sync/driver/sync_prefs.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/protocol/sync.pb.h"
@@ -72,6 +73,26 @@ std::unique_ptr<ArcSyncItem> CreateSyncItemFromPrefs(
package_info->last_backup_android_id, package_info->last_backup_time);
}
+bool ValidateEnableArcPackageSyncPref(Profile* profile) {
+ PrefService* pref_service = profile->GetPrefs();
+ // If device is set to sync everything, Arc package should be synced.
+ if (pref_service->GetBoolean(sync_driver::prefs::kSyncKeepEverythingSynced))
+ return true;
+
+ bool apps_sync_enable = pref_service->GetBoolean(
+ sync_driver::SyncPrefs::GetPrefNameForDataType(syncer::APPS));
+ // ArcPackage sync service is controlled by apps checkbox in sync settings.
+ // Update ArcPackage sync setting pref if it is different from apps sync
+ // setting pref.
+ const char* arc_sync_path =
+ sync_driver::SyncPrefs::GetPrefNameForDataType(syncer::ARC_PACKAGE);
+ if (apps_sync_enable != pref_service->GetBoolean(arc_sync_path)) {
+ pref_service->SetBoolean(arc_sync_path, apps_sync_enable);
+ }
+
+ return apps_sync_enable;
+}
+
} // namespace
// ArcPackageSyncableService::SyncItem
@@ -231,8 +252,8 @@ bool ArcPackageSyncableService::SyncStarted() {
sync_driver::SyncService* sync_service =
ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_);
// ArcPackage sync service is controlled by apps checkbox in sync settings.
- bool arc_package_sync_should_enable = profile_->GetPrefs()->GetBoolean(
- sync_driver::SyncPrefs::GetPrefNameForDataType(syncer::ARC_PACKAGE));
+ bool arc_package_sync_should_enable =
+ ValidateEnableArcPackageSyncPref(profile_);
if (!sync_service || !arc_package_sync_should_enable)
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698