1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_BOOKMARKS_HANDLER_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_BOOKMARKS_HANDLER_H_
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
15 class DictionaryValue
;
19 // This class converts bookmarks from supervised user settings into a tree of
20 // base::Values, for use in bookmarks::prefs::kSupervisedBookmarks.
21 class SupervisedUserBookmarksHandler
{
23 static scoped_ptr
<base::ListValue
> BuildBookmarksTree(
24 const base::DictionaryValue
& settings
);
26 // Public for testing only.
28 Folder(int id
, const std::string
& name
, int parent_id
);
36 Link(const std::string
& url
, const std::string
& name
, int parent_id
);
44 friend class SupervisedUserBookmarksHandlerTest
;
46 SupervisedUserBookmarksHandler();
47 ~SupervisedUserBookmarksHandler();
49 void ParseSettings(const base::DictionaryValue
& settings
);
50 void ParseFolders(const base::DictionaryValue
& folders
);
51 void ParseLinks(const base::DictionaryValue
& links
);
52 scoped_ptr
<base::ListValue
> BuildTree();
53 void AddFoldersToTree();
54 void AddLinksToTree();
55 bool AddNodeToTree(int parent_id
, scoped_ptr
<base::DictionaryValue
> node
);
57 const std::vector
<Folder
>& folders_for_testing() const { return folders_
; }
58 const std::vector
<Link
>& links_for_testing() const { return links_
; }
60 std::vector
<Folder
> folders_
;
61 std::vector
<Link
> links_
;
63 scoped_ptr
<base::ListValue
> root_
;
65 DISALLOW_COPY_AND_ASSIGN(SupervisedUserBookmarksHandler
);
68 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_BOOKMARKS_HANDLER_H_