| Index: chrome/browser/extensions/extension_ordering.h
|
| diff --git a/chrome/browser/extensions/extension_ordering.h b/chrome/browser/extensions/extension_ordering.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7c267f2670d9c68205db305c92fd7d0b32886c78
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/extension_ordering.h
|
| @@ -0,0 +1,66 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ORDERING_H_
|
| +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_ORDERING_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "chrome/common/extensions/extension.h"
|
| +
|
| +class ExtensionScopedPrefs;
|
| +class ExtensionServiceInterface;
|
| +class PrefService;
|
| +
|
| +// An synced ordering of apps located in extension prefs.
|
| +class ExtensionOrdering {
|
| + public:
|
| + explicit ExtensionOrdering(ExtensionScopedPrefs* extension_scoped_prefs);
|
| + ~ExtensionOrdering();
|
| +
|
| + // Set the ExtensionService to syncs order changes.
|
| + void SetExtensionService(ExtensionServiceInterface* extension_service);
|
| +
|
| + // Properly initialize ExtensionOrdering internal values that require
|
| + // |extension_ids|.
|
| + virtual void Initialize(const extensions::ExtensionIdList& extension_ids) = 0;
|
| +
|
| + // Resolves any conflicts that might be created as a result of syncing that
|
| + // results in two extensions having the same position in the ordering. After
|
| + // this is called, it is guaranteed that there will be no collisions.
|
| + virtual void FixSyncCollisions() = 0;
|
| +
|
| + // Add an extension so that it precedes all other extensions in the ordering.
|
| + virtual void InsertAtFront(const std::string& extension_id) = 0;
|
| +
|
| + // Add an extension so that all other extensions precede it in the ordering.
|
| + virtual void InsertAtBack(const std::string& extension_id) = 0;
|
| +
|
| + // Add to the next available position as determined by the implementation of
|
| + // this ordering.
|
| + virtual void InsertAtNextAvailable(const std::string& extension_id) = 0;
|
| +
|
| + // Updates the moved extension in the ordering so that it is now located after
|
| + // the given predecessor and before the successor. Empty strings are used to
|
| + // indicate no successor or predecessor.
|
| + virtual void OnExtensionMoved(const std::string& moved_extension_id,
|
| + const std::string& predecessor_extension_id,
|
| + const std::string& successor_extension_id) = 0;
|
| +
|
| + // Removes an app from the ordering.
|
| + virtual void Erase(const std::string& extension_id) = 0;
|
| +
|
| + // Returns true if |extension1| appears before |extension2| in the ordering.
|
| + virtual bool ExtensionPrecedes(const std::string& extension1,
|
| + const std::string& extension2) = 0;
|
| + protected:
|
| + // Syncs the extension if needed. It is an error to call this if the
|
| + // extension is not an application.
|
| + void SyncIfNeeded(const std::string& extension_id);
|
| +
|
| + ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance.
|
| + ExtensionServiceInterface* extension_service_; // Weak.
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ORDERING_H_
|
|
|