1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_UTIL_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_UTIL_H_ 7 8 #include "sync/api/sync_change.h" 9 #include "sync/api/sync_data.h" 10 11 namespace base { 12 class Value; 13 } 14 15 namespace content { 16 class BrowserContext; 17 } 18 19 namespace syncer { 20 class SyncableService; 21 } 22 23 namespace extensions { 24 25 namespace settings_sync_util { 26 27 // Creates a syncer::SyncData object for an extension or app setting. 28 syncer::SyncData CreateData( 29 const std::string& extension_id, 30 const std::string& key, 31 const base::Value& value, 32 syncer::ModelType type); 33 34 // Creates an "add" sync change for an extension or app setting. 35 syncer::SyncChange CreateAdd( 36 const std::string& extension_id, 37 const std::string& key, 38 const base::Value& value, 39 syncer::ModelType type); 40 41 // Creates an "update" sync change for an extension or app setting. 42 syncer::SyncChange CreateUpdate( 43 const std::string& extension_id, 44 const std::string& key, 45 const base::Value& value, 46 syncer::ModelType type); 47 48 // Creates a "delete" sync change for an extension or app setting. 49 syncer::SyncChange CreateDelete( 50 const std::string& extension_id, 51 const std::string& key, 52 syncer::ModelType type); 53 54 // Returns the sync service for settings. Must be called on the FILE thread. 55 // |type| must be either APP_SETTINGS or EXTENSION_SETTINGS. 56 syncer::SyncableService* GetSyncableService(content::BrowserContext* context, 57 syncer::ModelType type); 58 59 } // namespace settings_sync_util 60 61 } // namespace extensions 62 63 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTINGS_SYNC_UTIL_H_ 64