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