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

Unified Diff: chrome/browser/extensions/api/discovery/suggested_links_registry.cc

Issue 10438004: Hooking the discovery API to the NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added OWNERS for experimental discovery api. 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.cc
diff --git a/chrome/browser/extensions/api/discovery/suggested_links_registry.cc b/chrome/browser/extensions/api/discovery/suggested_links_registry.cc
index 0265690f79ead8c0eccd3050907ca1a431961929..9ade480b623cc4cf807d2ff8c8060588499ea5aa 100644
--- a/chrome/browser/extensions/api/discovery/suggested_links_registry.cc
+++ b/chrome/browser/extensions/api/discovery/suggested_links_registry.cc
@@ -42,6 +42,16 @@ void SuggestedLinksRegistry::Add(const std::string& extension_id,
list.push_back(new_item);
}
+scoped_ptr<std::vector<std::string> >
+ SuggestedLinksRegistry::GetExtensionIds() const {
+ scoped_ptr<std::vector<std::string> > result(new std::vector<std::string>());
+ for (SuggestedLinksMap::const_iterator it = suggested_links_.begin();
+ it != suggested_links_.end(); ++it) {
+ result->push_back((*it).first);
+ }
+ return result.Pass();
+}
+
const SuggestedLinkList* SuggestedLinksRegistry::GetAll(
const std::string& extension_id) const {
SuggestedLinksMap::const_iterator found = suggested_links_.find(extension_id);
@@ -53,8 +63,12 @@ const SuggestedLinkList* SuggestedLinksRegistry::GetAll(
void SuggestedLinksRegistry::Remove(const std::string& extension_id,
const std::string& link_url) {
SuggestedLinksMap::iterator found = suggested_links_.find(extension_id);
- if (found != suggested_links_.end())
+ if (found != suggested_links_.end()) {
RemoveLinkFromList(link_url, &found->second);
+ if (found->second.empty()) {
+ suggested_links_.erase(found);
+ }
+ }
}
void SuggestedLinksRegistry::ClearAll(const std::string& extension_id) {
« no previous file with comments | « chrome/browser/extensions/api/discovery/suggested_links_registry.h ('k') | chrome/browser/ui/webui/ntp/suggestions_combiner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698