1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/extensions/api/discovery/suggested_link.h"
12 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
14 namespace extensions {
16 // This class keeps track of links suggested by an extension using the discovery
18 class SuggestedLinksRegistry : public BrowserContextKeyedService {
20 // A list of ExtensionSuggestedLink's.
21 typedef std::vector<linked_ptr<extensions::SuggestedLink> > SuggestedLinkList;
23 SuggestedLinksRegistry();
25 // Adds a suggested link from |extension_id|. Takes ownership of |item| in all
27 void Add(const std::string& extension_id,
28 scoped_ptr<extensions::SuggestedLink> item);
30 // Returns all the extension ids that have at least one suggestion.
31 scoped_ptr<std::vector<std::string> > GetExtensionIds() const;
33 // Returns all the links suggested by |extension_id|.
34 const SuggestedLinkList* GetAll(const std::string& extension_id) const;
36 // Remove a specific link suggested by |extension_id|.
37 void Remove(const std::string& extension_id, const std::string& link_url);
39 // Clears all suggested links for |extension_id|.
40 void ClearAll(const std::string& extension_id);
43 // Maps extension id to a list of notifications for that extension.
44 typedef std::map<std::string, SuggestedLinkList> SuggestedLinksMap;
46 virtual ~SuggestedLinksRegistry();
48 // Gets suggested links for a given extension id.
49 SuggestedLinkList& GetAllInternal(const std::string& extension_id);
51 SuggestedLinksMap suggested_links_;
53 // An empty list of suggestions that can be returned for non-existing
55 SuggestedLinkList empty_list_;
57 DISALLOW_COPY_AND_ASSIGN(SuggestedLinksRegistry);
60 } // namespace extensions
62 #endif // CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_