Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: chrome/browser/supervised_user/supervised_user_bookmarks_handler.h

Issue 769153007: Managed bookmarks for supervised users (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.
+// 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.
+ 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_

Powered by Google App Engine
This is Rietveld 408576698