OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" | 5 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/cookies_tree_model.h" | 15 #include "chrome/browser/cookies_tree_model.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/text/bytes_formatting.h" | 18 #include "ui/base/text/bytes_formatting.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 const char kKeyId[] = "id"; | 22 const char kKeyId[] = "id"; |
23 const char kKeyTitle[] = "title"; | 23 const char kKeyTitle[] = "title"; |
24 const char kKeyIcon[] = "icon"; | 24 const char kKeyIcon[] = "icon"; |
25 const char kKeyType[] = "type"; | 25 const char kKeyType[] = "type"; |
26 const char kKeyHasChildren[] = "hasChildren"; | 26 const char kKeyHasChildren[] = "hasChildren"; |
27 | 27 |
| 28 const char kKeyAppId[] = "appId"; |
| 29 |
28 const char kKeyName[] = "name"; | 30 const char kKeyName[] = "name"; |
29 const char kKeyContent[] = "content"; | 31 const char kKeyContent[] = "content"; |
30 const char kKeyDomain[] = "domain"; | 32 const char kKeyDomain[] = "domain"; |
31 const char kKeyPath[] = "path"; | 33 const char kKeyPath[] = "path"; |
32 const char kKeySendFor[] = "sendfor"; | 34 const char kKeySendFor[] = "sendfor"; |
33 const char kKeyAccessibleToScript[] = "accessibleToScript"; | 35 const char kKeyAccessibleToScript[] = "accessibleToScript"; |
34 const char kKeyDesc[] = "desc"; | 36 const char kKeyDesc[] = "desc"; |
35 const char kKeySize[] = "size"; | 37 const char kKeySize[] = "size"; |
36 const char kKeyOrigin[] = "origin"; | 38 const char kKeyOrigin[] = "origin"; |
37 const char kKeyManifest[] = "manifest"; | 39 const char kKeyManifest[] = "manifest"; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const CookieTreeNode& node, | 89 const CookieTreeNode& node, |
88 base::DictionaryValue* dict) { | 90 base::DictionaryValue* dict) { |
89 // Use node's address as an id for WebUI to look it up. | 91 // Use node's address as an id for WebUI to look it up. |
90 dict->SetString(kKeyId, GetTreeNodeId(&node)); | 92 dict->SetString(kKeyId, GetTreeNodeId(&node)); |
91 dict->SetString(kKeyTitle, node.GetTitle()); | 93 dict->SetString(kKeyTitle, node.GetTitle()); |
92 dict->SetBoolean(kKeyHasChildren, !node.empty()); | 94 dict->SetBoolean(kKeyHasChildren, !node.empty()); |
93 | 95 |
94 switch (node.GetDetailedInfo().node_type) { | 96 switch (node.GetDetailedInfo().node_type) { |
95 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: { | 97 case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: { |
96 dict->SetString(kKeyType, "origin"); | 98 dict->SetString(kKeyType, "origin"); |
| 99 dict->SetString(kKeyAppId, node.GetDetailedInfo().app_id); |
97 #if defined(OS_MACOSX) | 100 #if defined(OS_MACOSX) |
98 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); | 101 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); |
99 #endif | 102 #endif |
100 break; | 103 break; |
101 } | 104 } |
102 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: { | 105 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: { |
103 dict->SetString(kKeyType, "cookie"); | 106 dict->SetString(kKeyType, "cookie"); |
104 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON"); | 107 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON"); |
105 | 108 |
106 const net::CookieMonster::CanonicalCookie& cookie = | 109 const net::CookieMonster::CanonicalCookie& cookie = |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 child = id_map_.Lookup(node_id); | 293 child = id_map_.Lookup(node_id); |
291 child_index = parent->GetIndexOf(child); | 294 child_index = parent->GetIndexOf(child); |
292 if (child_index == -1) | 295 if (child_index == -1) |
293 break; | 296 break; |
294 | 297 |
295 parent = child; | 298 parent = child; |
296 } | 299 } |
297 | 300 |
298 return child_index >= 0 ? child : NULL; | 301 return child_index >= 0 ? child : NULL; |
299 } | 302 } |
OLD | NEW |