| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/version.h" | 11 #include "base/version.h" |
| 12 #include "chrome/browser/sync/api/sync_change.h" | 12 #include "chrome/browser/sync/api/sync_change.h" |
| 13 #include "chrome/browser/sync/api/sync_data.h" | 13 #include "chrome/browser/sync/api/sync_data.h" |
| 14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 | 16 |
| 17 class ExtensionService; | 17 class ExtensionService; |
| 18 class SyncData; | 18 class SyncData; |
| 19 namespace sync_pb { class ExtensionSpecifics; } | 19 namespace sync_pb { |
| 20 class AppSpecifics; |
| 21 class ExtensionSpecifics; |
| 22 } |
| 20 | 23 |
| 21 // A class that encapsulates the synced properties of an Extension. | 24 // A class that encapsulates the synced properties of an Extension. |
| 22 class ExtensionSyncData { | 25 class ExtensionSyncData { |
| 23 public: | 26 public: |
| 24 ExtensionSyncData(); | 27 ExtensionSyncData(); |
| 25 explicit ExtensionSyncData(const SyncData& sync_data); | 28 explicit ExtensionSyncData(const SyncData& sync_data); |
| 26 explicit ExtensionSyncData(const SyncChange& sync_change); | 29 explicit ExtensionSyncData(const SyncChange& sync_change); |
| 27 ExtensionSyncData(const Extension& extension, | 30 ExtensionSyncData(const Extension& extension, |
| 28 bool enabled, | 31 bool enabled, |
| 29 bool incognito_enabled); | 32 bool incognito_enabled, |
| 33 int32 app_launch_index, |
| 34 int32 page_index); |
| 30 ~ExtensionSyncData(); | 35 ~ExtensionSyncData(); |
| 31 | 36 |
| 32 // Convert an ExtensionSyncData back out to a sync structure. | 37 // Convert an ExtensionSyncData back out to a sync structure. |
| 33 void PopulateSyncSpecifics(sync_pb::ExtensionSpecifics* specifics) const; | 38 void PopulateExtensionSyncSpecifics( |
| 39 sync_pb::ExtensionSpecifics* specifics) const; |
| 40 void PopulateAppSyncSpecifics(sync_pb::AppSpecifics* specifics) const; |
| 34 SyncData GetSyncData() const; | 41 SyncData GetSyncData() const; |
| 35 SyncChange GetSyncChange(SyncChange::SyncChangeType change_type) const; | 42 SyncChange GetSyncChange(SyncChange::SyncChangeType change_type) const; |
| 36 | 43 |
| 37 const std::string& id() const { return id_; } | 44 const std::string& id() const { return id_; } |
| 38 | 45 |
| 39 // Version-independent properties (i.e., used even when the | 46 // Version-independent properties (i.e., used even when the |
| 40 // version of the currently-installed extension doesn't match | 47 // version of the currently-installed extension doesn't match |
| 41 // |version|). | 48 // |version|). |
| 42 bool uninstalled() const { return uninstalled_; } | 49 bool uninstalled() const { return uninstalled_; } |
| 43 bool enabled() const { return enabled_; } | 50 bool enabled() const { return enabled_; } |
| 44 bool incognito_enabled() const { return incognito_enabled_; } | 51 bool incognito_enabled() const { return incognito_enabled_; } |
| 45 Extension::SyncType type() const { return type_; } | 52 Extension::SyncType type() const { return type_; } |
| 53 int32 app_launch_index() const { return app_launch_index_; } |
| 54 int32 page_index() const {return page_index_; } |
| 46 | 55 |
| 47 // Version-dependent properties (i.e., should be used only when the | 56 // Version-dependent properties (i.e., should be used only when the |
| 48 // version of the currenty-installed extension matches |version|). | 57 // version of the currenty-installed extension matches |version|). |
| 49 const Version& version() const { return version_; } | 58 const Version& version() const { return version_; } |
| 50 const GURL& update_url() const { return update_url_; } | 59 const GURL& update_url() const { return update_url_; } |
| 51 // Used only for debugging. | 60 // Used only for debugging. |
| 52 const std::string& name() const { return name_; } | 61 const std::string& name() const { return name_; } |
| 53 | 62 |
| 54 private: | 63 private: |
| 55 void PopulateFromExtensionSpecifics( | 64 void PopulateFromExtensionSpecifics( |
| 56 const sync_pb::ExtensionSpecifics& specifics); | 65 const sync_pb::ExtensionSpecifics& specifics); |
| 66 void PopulateFromAppSpecifics( |
| 67 const sync_pb::AppSpecifics& specifics); |
| 57 void PopulateFromSyncData(const SyncData& sync_data); | 68 void PopulateFromSyncData(const SyncData& sync_data); |
| 58 | 69 |
| 59 std::string id_; | 70 std::string id_; |
| 60 bool uninstalled_; | 71 bool uninstalled_; |
| 61 bool enabled_; | 72 bool enabled_; |
| 62 bool incognito_enabled_; | 73 bool incognito_enabled_; |
| 63 Extension::SyncType type_; | 74 Extension::SyncType type_; |
| 64 Version version_; | 75 Version version_; |
| 65 GURL update_url_; | 76 GURL update_url_; |
| 66 std::string name_; | 77 std::string name_; |
| 78 int32 app_launch_index_; |
| 79 int32 page_index_; |
| 67 }; | 80 }; |
| 68 | 81 |
| 69 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ | 82 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYNC_DATA_H_ |
| OLD | NEW |