Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
Aaron Boodman
2012/05/11 21:06:46
You should unit test this middle-level code.
| |
| 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_EXTENSION_SUGGESTED_LINKS_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SUGGESTED_LINKS_MANAGER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <map> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "chrome/browser/extensions/extension_suggested_link.h" | |
| 13 #include "content/public/browser/browser_thread.h" | |
| 14 | |
| 15 // This class keeps track of links suggested by an extension using the discovery | |
|
Aaron Boodman
2012/05/11 21:06:46
Are the suggestions not saved anywhere? I think th
beaudoin
2012/05/12 03:16:29
The expected usage is for the links to be dynamica
beaudoin
2012/05/14 23:28:02
Discussed in side thread.
| |
| 16 // API. | |
| 17 class ExtensionSuggestedLinksManager | |
| 18 : public base::RefCountedThreadSafe< | |
| 19 ExtensionSuggestedLinksManager, | |
| 20 content::BrowserThread::DeleteOnUIThread> { | |
| 21 public: | |
| 22 ExtensionSuggestedLinksManager(); | |
| 23 | |
| 24 // Takes ownership of |item| in all cases. | |
| 25 void Add(const std::string& extension_id, ExtensionSuggestedLink* item); | |
| 26 | |
| 27 const ExtensionSuggestedLinkList* GetAll( | |
| 28 const std::string& extension_id) const; | |
| 29 | |
| 30 void Clear(const std::string& extension_id, const std::string& linkUrl); | |
| 31 | |
| 32 // Clears all suggested links for |extension_id|. | |
| 33 void ClearAll(const std::string& extension_id); | |
| 34 | |
| 35 private: | |
| 36 friend class base::DeleteHelper<ExtensionSuggestedLinksManager>; | |
| 37 friend struct content::BrowserThread::DeleteOnThread< | |
| 38 content::BrowserThread::UI>; | |
| 39 | |
| 40 // Maps extension id to a list of notifications for that extension. | |
| 41 typedef std::map<std::string, ExtensionSuggestedLinkList> SuggestedLinksMap; | |
| 42 | |
| 43 virtual ~ExtensionSuggestedLinksManager(); | |
| 44 | |
| 45 // Gets suggested links for a given extension id. | |
| 46 ExtensionSuggestedLinkList& GetAllInternal(const std::string& extension_id); | |
| 47 | |
| 48 SuggestedLinksMap suggested_links_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(ExtensionSuggestedLinksManager); | |
| 51 }; | |
| 52 | |
| 53 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SUGGESTED_LINKS_MANAGER_H_ | |
| OLD | NEW |