Chromium Code Reviews| Index: chrome/browser/supervised_user/supervised_user_bookmarks_handler.h |
| diff --git a/chrome/browser/supervised_user/supervised_user_bookmarks_handler.h b/chrome/browser/supervised_user/supervised_user_bookmarks_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..48ca9087c1fbbd536c287dc0ce9c9ab9ba7ba3a6 |
| --- /dev/null |
| +++ b/chrome/browser/supervised_user/supervised_user_bookmarks_handler.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
noyau (Ping after 24h)
2015/01/23 12:14:52
2015 on new files :)
Marc Treib
2015/01/26 12:27:42
Thanks, done!
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_BOOKMARKS_HANDLER_H_ |
| +#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_BOOKMARKS_HANDLER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +class ListValue; |
| +} |
| + |
| +// This class converts bookmarks from supervised user settings into a tree of |
| +// base::Values, for use in bookmarks::prefs::kSupervisedBookmarks. |
| +class SupervisedUserBookmarksHandler { |
| + public: |
| + static scoped_ptr<base::ListValue> BuildBookmarksTree( |
| + const base::DictionaryValue& settings); |
| + |
| + // Public for testing only. |
|
noyau (Ping after 24h)
2015/01/23 12:14:52
The testing class is listed as friend, does these
Marc Treib
2015/01/26 12:27:42
Yes, it's also used in the test outside of the act
|
| + struct Folder { |
| + Folder(int id, const std::string& name, int parent_id); |
| + |
| + int id; |
| + std::string name; |
| + int parent_id; |
| + }; |
| + |
| + struct Link { |
| + Link(const std::string& url, const std::string& name, int parent_id); |
| + |
| + std::string url; |
| + std::string name; |
| + int parent_id; |
| + }; |
| + |
| + private: |
| + friend class SupervisedUserBookmarksHandlerTest; |
| + |
| + SupervisedUserBookmarksHandler(); |
| + ~SupervisedUserBookmarksHandler(); |
| + |
| + void ParseSettings(const base::DictionaryValue& settings); |
| + void ParseFolders(const base::DictionaryValue& folders); |
| + void ParseLinks(const base::DictionaryValue& links); |
| + scoped_ptr<base::ListValue> BuildTree(); |
| + void AddFoldersToTree(); |
| + void AddLinksToTree(); |
| + bool AddNodeToTree(int parent_id, scoped_ptr<base::DictionaryValue> node); |
| + |
| + const std::vector<Folder>& folders_for_testing() const { return folders_; } |
| + const std::vector<Link>& links_for_testing() const { return links_; } |
| + |
| + std::vector<Folder> folders_; |
| + std::vector<Link> links_; |
| + |
| + scoped_ptr<base::ListValue> root_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SupervisedUserBookmarksHandler); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_BOOKMARKS_HANDLER_H_ |