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

Side by Side Diff: chrome/browser/extensions/extension_ordering.h

Issue 17038002: Separate the NTP app ordering from the app list app ordering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 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_EXTENSION_ORDERING_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ORDERING_H_
7
8 #include <string>
9
10 #include "chrome/common/extensions/extension.h"
11
12 class ExtensionScopedPrefs;
13 class ExtensionServiceInterface;
14 class PrefService;
15
16 // An synced ordering of apps located in extension prefs.
17 class ExtensionOrdering {
18 public:
19 explicit ExtensionOrdering(ExtensionScopedPrefs* extension_scoped_prefs);
20 ~ExtensionOrdering();
21
22 // Set the ExtensionService to syncs order changes.
23 void SetExtensionService(ExtensionServiceInterface* extension_service);
24
25 // Properly initialize ExtensionOrdering internal values that require
26 // |extension_ids|.
27 virtual void Initialize(const extensions::ExtensionIdList& extension_ids) = 0;
28
29 // Resolves any conflicts that might be created as a result of syncing that
30 // results in two extensions having the same position in the ordering. After
31 // this is called, it is guaranteed that there will be no collisions.
32 virtual void FixSyncCollisions() = 0;
33
34 // Add an extension so that it precedes all other extensions in the ordering.
35 virtual void InsertAtFront(const std::string& extension_id) = 0;
36
37 // Add an extension so that all other extensions precede it in the ordering.
38 virtual void InsertAtBack(const std::string& extension_id) = 0;
39
40 // Add to the next available position as determined by the implementation of
41 // this ordering.
42 virtual void InsertAtNextAvailable(const std::string& extension_id) = 0;
43
44 // Updates the moved extension in the ordering so that it is now located after
45 // the given predecessor and before the successor. Empty strings are used to
46 // indicate no successor or predecessor.
47 virtual void OnExtensionMoved(const std::string& moved_extension_id,
48 const std::string& predecessor_extension_id,
49 const std::string& successor_extension_id) = 0;
50
51 // Removes an app from the ordering.
52 virtual void Erase(const std::string& extension_id) = 0;
53
54 // Returns true if |extension1| appears before |extension2| in the ordering.
55 virtual bool ExtensionPrecedes(const std::string& extension1,
56 const std::string& extension2) = 0;
57 protected:
58 // Syncs the extension if needed. It is an error to call this if the
59 // extension is not an application.
60 void SyncIfNeeded(const std::string& extension_id);
61
62 ExtensionScopedPrefs* extension_scoped_prefs_; // Weak, owns this instance.
63 ExtensionServiceInterface* extension_service_; // Weak.
64 };
65
66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ORDERING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698