1 // Copyright (c) 2012 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_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_
6 #define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_
11 #include "base/basictypes.h"
12 #include "base/id_map.h"
17 class DictionaryValue
;
21 class CookiesTreeModelUtil
{
23 CookiesTreeModelUtil();
24 ~CookiesTreeModelUtil();
26 // Finds or creates an ID for given |node| and returns it as string.
27 std::string
GetTreeNodeId(const CookieTreeNode
* node
);
29 // Append the children nodes of |parent| in specified range to |nodes| list.
30 void GetChildNodeList(const CookieTreeNode
* parent
,
33 base::ListValue
* nodes
);
35 // Gets tree node from |path| under |root|. |path| is comma separated list of
36 // ids. |id_map| translates ids into object pointers. Return NULL if |path|
38 const CookieTreeNode
* GetTreeNodeFromPath(const CookieTreeNode
* root
,
39 const std::string
& path
);
42 typedef IDMap
<const CookieTreeNode
> CookiesTreeNodeIdMap
;
43 typedef std::map
<const CookieTreeNode
*, int32
> CookieTreeNodeMap
;
45 // Populate given |dict| with cookie tree node properties. |id_map| maps
46 // a CookieTreeNode to an ID and creates a new ID if |node| is not in the
47 // maps. Returns false if the |node| does not need to be shown.
48 bool GetCookieTreeNodeDictionary(const CookieTreeNode
& node
,
49 base::DictionaryValue
* dict
);
51 // IDMap to create unique ID and look up the object for an ID.
52 CookiesTreeNodeIdMap id_map_
;
54 // Reverse look up map to find the ID for a node.
55 CookieTreeNodeMap node_map_
;
57 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModelUtil
);
60 #endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_