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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/discovery/suggested_links_registry.h
diff --git a/chrome/browser/extensions/api/discovery/suggested_links_registry.h b/chrome/browser/extensions/api/discovery/suggested_links_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..df850d83ba7e9193149bbae9cc22852d114350ce
--- /dev/null
+++ b/chrome/browser/extensions/api/discovery/suggested_links_registry.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 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_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_
+#define CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_
+#pragma once
+
+#include <map>
+
+#include "chrome/browser/extensions/api/discovery/suggested_link.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace extensions {
+
+// This class keeps track of links suggested by an extension using the discovery
+// API.
+class SuggestedLinksRegistry : public ProfileKeyedService {
+ public:
+ // A list of ExtensionSuggestedLink's.
+ typedef std::vector<linked_ptr<extensions::SuggestedLink> > SuggestedLinkList;
+
+ SuggestedLinksRegistry();
+
+ // Adds a suggested link from |extension_id|. Takes ownership of |item| in all
+ // cases.
+ void Add(const std::string& extension_id,
+ scoped_ptr<extensions::SuggestedLink> item);
+
+ // Returns all the links suggested by |extension_id|.
+ const SuggestedLinkList* GetAll(const std::string& extension_id) const;
+
+ // Remove a specific link suggested by |extension_id|.
+ void Remove(const std::string& extension_id, const std::string& link_url);
+
+ // Clears all suggested links for |extension_id|.
+ void ClearAll(const std::string& extension_id);
+
+ private:
+ // Maps extension id to a list of notifications for that extension.
+ typedef std::map<std::string, SuggestedLinkList> SuggestedLinksMap;
+
+ virtual ~SuggestedLinksRegistry();
+
+ // Gets suggested links for a given extension id.
+ SuggestedLinkList& GetAllInternal(const std::string& extension_id);
+
+ SuggestedLinksMap suggested_links_;
+
+ DISALLOW_COPY_AND_ASSIGN(SuggestedLinksRegistry);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_DISCOVERY_SUGGESTED_LINKS_REGISTRY_H_

Powered by Google App Engine
This is Rietveld 408576698