Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / app_list / app_list_syncable_service.h
index 7ea8e1f..04ccdcc 100644 (file)
@@ -8,6 +8,7 @@
 #include <map>
 
 #include "base/memory/scoped_ptr.h"
+#include "chrome/browser/apps/drive/drive_app_uninstall_sync_service.h"
 #include "chrome/browser/sync/glue/sync_start_util.h"
 #include "components/keyed_service/core/keyed_service.h"
 #include "content/public/browser/notification_observer.h"
@@ -36,10 +37,12 @@ namespace app_list {
 class AppListFolderItem;
 class AppListItem;
 class AppListModel;
+class ModelPrefUpdater;
 
 // Keyed Service that owns, stores, and syncs an AppListModel for a profile.
 class AppListSyncableService : public syncer::SyncableService,
                                public KeyedService,
+                               public DriveAppUninstallSyncService,
                                public content::NotificationObserver {
  public:
   struct SyncItem {
@@ -50,7 +53,6 @@ class AppListSyncableService : public syncer::SyncableService,
     sync_pb::AppListSpecifics::AppListItemType item_type;
     std::string item_name;
     std::string parent_id;
-    syncer::StringOrdinal page_ordinal;
     syncer::StringOrdinal item_ordinal;
 
     std::string ToString() const;
@@ -60,7 +62,7 @@ class AppListSyncableService : public syncer::SyncableService,
   AppListSyncableService(Profile* profile,
                          extensions::ExtensionSystem* extension_system);
 
-  virtual ~AppListSyncableService();
+  ~AppListSyncableService() override;
 
   // Adds |item| to |sync_items_| and |model_|. If a sync item already exists,
   // updates the existing sync item instead.
@@ -84,31 +86,35 @@ class AppListSyncableService : public syncer::SyncableService,
   const std::string& GetOemFolderNameForTest() const {
     return oem_folder_name_;
   }
+  void ResetDriveAppProviderForTest();
 
   // syncer::SyncableService
-  virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
+  syncer::SyncMergeResult MergeDataAndStartSyncing(
       syncer::ModelType type,
       const syncer::SyncDataList& initial_sync_data,
       scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
-      scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
-  virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
-  virtual syncer::SyncDataList GetAllSyncData(
-      syncer::ModelType type) const OVERRIDE;
-  virtual syncer::SyncError ProcessSyncChanges(
+      scoped_ptr<syncer::SyncErrorFactory> error_handler) override;
+  void StopSyncing(syncer::ModelType type) override;
+  syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
+  syncer::SyncError ProcessSyncChanges(
       const tracked_objects::Location& from_here,
-      const syncer::SyncChangeList& change_list) OVERRIDE;
+      const syncer::SyncChangeList& change_list) override;
 
  private:
   class ModelObserver;
   typedef std::map<std::string, SyncItem*> SyncItemMap;
 
   // KeyedService
-  virtual void Shutdown() OVERRIDE;
+  void Shutdown() override;
+
+  // DriveAppUninstallSyncService
+  void TrackUninstalledDriveApp(const std::string& drive_app_id) override;
+  void UntrackUninstalledDriveApp(const std::string& drive_app_id) override;
 
   // content::NotificationObserver
-  virtual void Observe(int type,
-                       const content::NotificationSource& source,
-                       const content::NotificationDetails& details) OVERRIDE;
+  void Observe(int type,
+               const content::NotificationSource& source,
+               const content::NotificationDetails& details) override;
 
   // Builds the model once ExtensionService is ready.
   void BuildModel();
@@ -142,9 +148,8 @@ class AppListSyncableService : public syncer::SyncableService,
   // Removes sync item matching |id|.
   void RemoveSyncItem(const std::string& id);
 
-  // Updates folder items that may get created during initial sync. If
-  // oem_at_end is true then move any OEM folder to the end of the list.
-  void ResolveFolderPositions(bool move_oem_to_end);
+  // Updates folder items that may get created during initial sync.
+  void ResolveFolderPositions();
 
   // Removes any empty SyncItem folders and deletes them from sync. Called
   // after a sync item is removed (which may result in an empty folder).
@@ -184,6 +189,10 @@ class AppListSyncableService : public syncer::SyncableService,
   // folder id.
   std::string FindOrCreateOemFolder();
 
+  // Gets the location for the OEM folder. Called when the folder is first
+  // created.
+  syncer::StringOrdinal GetOemFolderPos();
+
   // Returns true if an extension matching |id| exists and was installed by
   // an OEM (extension->was_installed_by_oem() is true).
   bool AppIsOem(const std::string& id);
@@ -193,11 +202,14 @@ class AppListSyncableService : public syncer::SyncableService,
   content::NotificationRegistrar registrar_;
   scoped_ptr<AppListModel> model_;
   scoped_ptr<ModelObserver> model_observer_;
+  scoped_ptr<ModelPrefUpdater> model_pref_updater_;
   scoped_ptr<ExtensionAppModelBuilder> apps_builder_;
   scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
   scoped_ptr<syncer::SyncErrorFactory> sync_error_handler_;
   SyncItemMap sync_items_;
   syncer::SyncableService::StartSyncFlare flare_;
+  bool initial_sync_data_processed_;
+  bool first_app_list_sync_;
   std::string oem_folder_name_;
 
   // Provides integration with Drive apps.