Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / ui / webui / cookies_tree_model_util.h
blob1020885d6f36a3fc3a1ccb085b1596f4601d5678
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_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/id_map.h"
14 class CookieTreeNode;
16 namespace base {
17 class DictionaryValue;
18 class ListValue;
21 class CookiesTreeModelUtil {
22 public:
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,
31 int start,
32 int count,
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|
37 // is not valid.
38 const CookieTreeNode* GetTreeNodeFromPath(const CookieTreeNode* root,
39 const std::string& path);
41 private:
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_