Chromium Code Reviews| Index: chrome/browser/extensions/extension_suggested_links_manager.h |
| diff --git a/chrome/browser/extensions/extension_suggested_links_manager.h b/chrome/browser/extensions/extension_suggested_links_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4fb06a5ea3bf5b91e9e8bb7eaeecf685e614a129 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/extension_suggested_links_manager.h |
| @@ -0,0 +1,53 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SUGGESTED_LINKS_MANAGER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SUGGESTED_LINKS_MANAGER_H_ |
| +#pragma once |
| + |
| +#include <map> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/browser/extensions/extension_suggested_link.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +// 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.
|
| +// API. |
| +class ExtensionSuggestedLinksManager |
| + : public base::RefCountedThreadSafe< |
| + ExtensionSuggestedLinksManager, |
| + content::BrowserThread::DeleteOnUIThread> { |
| + public: |
| + ExtensionSuggestedLinksManager(); |
| + |
| + // Takes ownership of |item| in all cases. |
| + void Add(const std::string& extension_id, ExtensionSuggestedLink* item); |
| + |
| + const ExtensionSuggestedLinkList* GetAll( |
| + const std::string& extension_id) const; |
| + |
| + void Clear(const std::string& extension_id, const std::string& linkUrl); |
| + |
| + // Clears all suggested links for |extension_id|. |
| + void ClearAll(const std::string& extension_id); |
| + |
| + private: |
| + friend class base::DeleteHelper<ExtensionSuggestedLinksManager>; |
| + friend struct content::BrowserThread::DeleteOnThread< |
| + content::BrowserThread::UI>; |
| + |
| + // Maps extension id to a list of notifications for that extension. |
| + typedef std::map<std::string, ExtensionSuggestedLinkList> SuggestedLinksMap; |
| + |
| + virtual ~ExtensionSuggestedLinksManager(); |
| + |
| + // Gets suggested links for a given extension id. |
| + ExtensionSuggestedLinkList& GetAllInternal(const std::string& extension_id); |
| + |
| + SuggestedLinksMap suggested_links_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ExtensionSuggestedLinksManager); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SUGGESTED_LINKS_MANAGER_H_ |