| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 |
| 11 #include "chrome/browser/extensions/api/discovery/suggested_link.h" |
| 12 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 13 #include "content/public/browser/browser_thread.h" |
| 14 |
| 15 namespace extensions { |
| 16 |
| 17 // This class keeps track of links suggested by an extension using the discovery |
| 18 // API. |
| 19 class SuggestedLinksRegistry : public ProfileKeyedService { |
| 20 public: |
| 21 // A list of ExtensionSuggestedLink's. |
| 22 typedef std::vector<linked_ptr<extensions::SuggestedLink> > SuggestedLinkList; |
| 23 |
| 24 SuggestedLinksRegistry(); |
| 25 |
| 26 // Adds a suggested link from |extension_id|. Takes ownership of |item| in all |
| 27 // cases. |
| 28 void Add(const std::string& extension_id, |
| 29 scoped_ptr<extensions::SuggestedLink> item); |
| 30 |
| 31 // Returns all the links suggested by |extension_id|. |
| 32 const SuggestedLinkList* GetAll(const std::string& extension_id) const; |
| 33 |
| 34 // Remove a specific link suggested by |extension_id|. |
| 35 void Remove(const std::string& extension_id, const std::string& link_url); |
| 36 |
| 37 // Clears all suggested links for |extension_id|. |
| 38 void ClearAll(const std::string& extension_id); |
| 39 |
| 40 private: |
| 41 // Maps extension id to a list of notifications for that extension. |
| 42 typedef std::map<std::string, SuggestedLinkList> SuggestedLinksMap; |
| 43 |
| 44 virtual ~SuggestedLinksRegistry(); |
| 45 |
| 46 // Gets suggested links for a given extension id. |
| 47 SuggestedLinkList& GetAllInternal(const std::string& extension_id); |
| 48 |
| 49 SuggestedLinksMap suggested_links_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(SuggestedLinksRegistry); |
| 52 }; |
| 53 |
| 54 } // namespace extensions |
| 55 |
| 56 #endif // CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_ |
| OLD | NEW |