| Index: chrome/browser/ui/webui/cookies_tree_model_util.cc
|
| diff --git a/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chrome/browser/ui/webui/cookies_tree_model_util.cc
|
| index 9e237826c845bdcf0df5d736a9b3bf27b7e3b64c..51d4b6ab6071a0171a94282b397d362c2d6454ba 100644
|
| --- a/chrome/browser/ui/webui/cookies_tree_model_util.cc
|
| +++ b/chrome/browser/ui/webui/cookies_tree_model_util.cc
|
| @@ -339,6 +339,31 @@ bool CookiesTreeModelUtil::GetCookieTreeNodeDictionary(
|
| return true;
|
| }
|
|
|
| +void CookiesTreeModelUtil::GetChildNodeDetails(const CookieTreeNode* parent,
|
| + int start,
|
| + int count,
|
| + bool include_quota_nodes,
|
| + base::ListValue* list) {
|
| + std::string id_path = GetTreeNodeId(parent);
|
| + for (int i = 0; i < count; ++i) {
|
| + const CookieTreeNode* child = parent->GetChild(start + i);
|
| + int cookie_count = child->child_count();
|
| + std::string cookie_id_path = id_path + "," + GetTreeNodeId(child) + ",";
|
| + for (int k = 0; k < cookie_count; ++k) {
|
| + const CookieTreeNode* details = child->GetChild(k);
|
| + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
| + if (GetCookieTreeNodeDictionary(*details, include_quota_nodes,
|
| + dict.get())) {
|
| + // TODO(dschuyler): This ID path is an artifact from using tree nodes to
|
| + // hold the cookies. Can this be changed to a dictionary with a key
|
| + // lookup (and remove use of id_map_)?
|
| + dict->SetString("idPath", cookie_id_path + GetTreeNodeId(details));
|
| + list->Append(std::move(dict));
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent,
|
| int start,
|
| int count,
|
| @@ -376,3 +401,18 @@ const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath(
|
|
|
| return child_index >= 0 ? child : NULL;
|
| }
|
| +
|
| +const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromTitle(
|
| + const CookieTreeNode* root,
|
| + const base::string16& title) {
|
| + // TODO(dschuyler): This method reduces an old O(n^2) lookup with an O(n)
|
| + // lookup for O(1) space, but it could be further improved to O(1) lookup if
|
| + // desired (by trading O(n) space for the time improvement).
|
| + int site_count = root->child_count();
|
| + for (int i = 0; i < site_count; ++i) {
|
| + const CookieTreeNode* child = root->GetChild(i);
|
| + if (title == child->GetTitle())
|
| + return child;
|
| + }
|
| + return nullptr;
|
| +}
|
|
|