Chromium Code Reviews| Index: chrome/browser/ui/app_list/app_list_syncable_service.h |
| diff --git a/chrome/browser/ui/app_list/app_list_syncable_service.h b/chrome/browser/ui/app_list/app_list_syncable_service.h |
| index 5b25ef88311263c26cf0068a893aec9ddfa50d82..2b69ba14fa7ddb9d8d0574a8ac6101db67d88ba0 100644 |
| --- a/chrome/browser/ui/app_list/app_list_syncable_service.h |
| +++ b/chrome/browser/ui/app_list/app_list_syncable_service.h |
| @@ -11,6 +11,7 @@ |
| #include <memory> |
| #include "base/macros.h" |
| +#include "base/observer_list.h" |
| #include "build/build_config.h" |
| #include "chrome/browser/apps/drive/drive_app_uninstall_sync_service.h" |
| #include "chrome/browser/sync/glue/sync_start_util.h" |
| @@ -59,16 +60,31 @@ class AppListSyncableService : public syncer::SyncableService, |
| std::string item_name; |
| std::string parent_id; |
| syncer::StringOrdinal item_ordinal; |
| + syncer::StringOrdinal item_pin_ordinal; |
| + bool item_pin_by_policy; |
|
stevenjb
2016/06/10 18:00:40
item_pinned_by_policy
khmel
2016/06/10 22:08:10
Done.
|
| std::string ToString() const; |
| }; |
| + class Observer { |
| + public: |
| + // Notifies that sync model was updated. |
| + virtual void OnSyncModelUpdated() = 0; |
| + |
| + protected: |
| + virtual ~Observer() = default; |
| + }; |
| + |
| + using SyncItemMap = std::map<std::string, SyncItem*>; |
| + |
| // Populates the model when |extension_system| is ready. |
| AppListSyncableService(Profile* profile, |
| extensions::ExtensionSystem* extension_system); |
| ~AppListSyncableService() override; |
| + static AppListSyncableService* Get(Profile* profile); |
| + |
| // Adds |item| to |sync_items_| and |model_|. If a sync item already exists, |
| // updates the existing sync item instead. |
| void AddItem(std::unique_ptr<AppListItem> app_item); |
| @@ -88,9 +104,28 @@ class AppListSyncableService : public syncer::SyncableService, |
| // Sets the name of the folder for OEM apps. |
| void SetOemFolderName(const std::string& name); |
| + // Returns true if app specified by |app_id| is synced and marked as pinned |
| + // by policy. |
| + bool GetPinByPolicy(const std::string& app_id); |
|
stevenjb
2016/06/10 18:00:40
GetPinnedByPolicy
khmel
2016/06/10 22:08:10
Done.
|
| + |
| + // Returns optional pin position for the app specified by |app_id|. If app is |
| + // not synced or does not have associated pin position then empty ordinal is |
| + // returned. |
| + syncer::StringOrdinal GetPinPosition(const std::string& app_id); |
| + |
| + // Sets pin position and how it is pinned for the app specified by |app_id|. |
| + // Empty |item_pin_ordinal| indicates that the app has no pin. |
| + void SetPinPosition(const std::string& app_id, |
| + const syncer::StringOrdinal& item_pin_ordinal, |
| + bool pinned_by_policy); |
| + |
| // Gets the app list model, building it if it doesn't yet exist. |
| AppListModel* GetModel(); |
| + // Registers new observers and makes sure that service is started. |
| + void AddObserverAndStart(Observer* observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| Profile* profile() { return profile_; } |
| size_t GetNumSyncItemsForTest(); |
| const std::string& GetOemFolderNameForTest() const { |
| @@ -98,6 +133,8 @@ class AppListSyncableService : public syncer::SyncableService, |
| } |
| void ResetDriveAppProviderForTest(); |
| + const SyncItemMap& sync_items() const { return sync_items_; } |
| + |
| // syncer::SyncableService |
| syncer::SyncMergeResult MergeDataAndStartSyncing( |
| syncer::ModelType type, |
| @@ -112,7 +149,6 @@ class AppListSyncableService : public syncer::SyncableService, |
| private: |
| class ModelObserver; |
| - typedef std::map<std::string, SyncItem*> SyncItemMap; |
| // KeyedService |
| void Shutdown() override; |
| @@ -202,6 +238,9 @@ class AppListSyncableService : public syncer::SyncableService, |
| // an OEM (extension->was_installed_by_oem() is true). |
| bool AppIsOem(const std::string& id); |
| + // Helper that notifies observers that sync model has been updated. |
| + void NotifyObserversSyncUpdated(); |
| + |
| Profile* profile_; |
| extensions::ExtensionSystem* extension_system_; |
| std::unique_ptr<AppListModel> model_; |
| @@ -219,6 +258,9 @@ class AppListSyncableService : public syncer::SyncableService, |
| bool first_app_list_sync_; |
| std::string oem_folder_name_; |
| + // List of observers. |
| + base::ObserverList<Observer> observer_list_; |
| + |
| // Provides integration with Drive apps. |
| std::unique_ptr<DriveAppProvider> drive_app_provider_; |