Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / supervised_user / supervised_user_bookmarks_handler.h
blobd326392dd9c3bcc962b87312b8f82caed46d0479
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_
8 #include <string>
9 #include <vector>
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
14 namespace base {
15 class DictionaryValue;
16 class ListValue;
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 {
22 public:
23 static scoped_ptr<base::ListValue> BuildBookmarksTree(
24 const base::DictionaryValue& settings);
26 // Public for testing only.
27 struct Folder {
28 Folder(int id, const std::string& name, int parent_id);
30 int id;
31 std::string name;
32 int parent_id;
35 struct Link {
36 Link(const std::string& url, const std::string& name, int parent_id);
38 std::string url;
39 std::string name;
40 int parent_id;
43 private:
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_