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

Side by Side Diff: chrome/browser/extensions/api/discovery/suggested_links_registry.h

Issue 10391034: Scaffolding for an experimental discovery API letting users inject links in the recommended pane of… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Answered review comments from PatchSet 4. Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698