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_APP_SYNC_DATA_H_ 6 #define CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ 7 8 #include "chrome/browser/extensions/extension_sync_data.h" 9 #include "sync/api/string_ordinal.h" 10 #include "sync/api/sync_change.h" 11 12 namespace syncer { 13 class SyncData; 14 } 15 16 namespace sync_pb { 17 class AppSpecifics; 18 } 19 20 namespace extensions { 21 22 class Extension; 23 class ExtensionSyncData; 24 25 // A class that encapsulates the synced properties of an Application. 26 class AppSyncData { 27 public: 28 AppSyncData(); 29 explicit AppSyncData(const syncer::SyncData& sync_data); 30 explicit AppSyncData(const syncer::SyncChange& sync_change); 31 AppSyncData(const Extension& extension, 32 bool enabled, 33 bool incognito_enabled, 34 const syncer::StringOrdinal& app_launch_ordinal, 35 const syncer::StringOrdinal& page_ordinal); 36 ~AppSyncData(); 37 38 // Retrive sync data from this class. 39 syncer::SyncData GetSyncData() const; 40 syncer::SyncChange GetSyncChange( 41 syncer::SyncChange::SyncChangeType change_type) const; 42 43 const std::string& id() const { return extension_sync_data_.id(); } 44 45 bool uninstalled() const { return extension_sync_data_.uninstalled(); } 46 47 // These ordinals aren't necessarily valid. Some applications don't have 48 // valid ordinals because they don't appear on the new tab page. 49 const syncer::StringOrdinal& app_launch_ordinal() const { 50 return app_launch_ordinal_; 51 } 52 const syncer::StringOrdinal& page_ordinal() const { return page_ordinal_; } 53 54 const ExtensionSyncData& extension_sync_data() const { 55 return extension_sync_data_; 56 } 57 58 private: 59 // Convert an AppSyncData back out to a sync structure. 60 void PopulateAppSpecifics(sync_pb::AppSpecifics* specifics) const; 61 62 // Populate this class from sync inputs. 63 void PopulateFromAppSpecifics( 64 const sync_pb::AppSpecifics& specifics); 65 void PopulateFromSyncData(const syncer::SyncData& sync_data); 66 67 ExtensionSyncData extension_sync_data_; 68 syncer::StringOrdinal app_launch_ordinal_; 69 syncer::StringOrdinal page_ordinal_; 70 }; 71 72 } // namespace extensions 73 74 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_DATA_H_ 75 76