Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Unified Diff: chrome/browser/ui/app_list/app_list_syncable_service.h

Issue 2055553004: arc: Support pinned apps across Arc-enabled and Arc-disabled platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..73177e622bce043c0e19f553005a6c2ec616fd7f 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;
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,19 @@ class AppListSyncableService : public syncer::SyncableService,
// Sets the name of the folder for OEM apps.
void SetOemFolderName(const std::string& name);
+ bool GetPinByPolicy(const std::string& app_id);
+ syncer::StringOrdinal GetPinPosition(const std::string& app_id);
+ 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 +124,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 +140,6 @@ class AppListSyncableService : public syncer::SyncableService,
private:
class ModelObserver;
- typedef std::map<std::string, SyncItem*> SyncItemMap;
// KeyedService
void Shutdown() override;
@@ -202,6 +229,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 +249,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_;
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_syncable_service.cc » ('j') | chrome/browser/ui/ash/chrome_launcher_prefs.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698