OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 static const char kKeyManifest[] = "manifest"; | 34 static const char kKeyManifest[] = "manifest"; |
35 | 35 |
36 static const char kKeyAccessed[] = "accessed"; | 36 static const char kKeyAccessed[] = "accessed"; |
37 static const char kKeyCreated[] = "created"; | 37 static const char kKeyCreated[] = "created"; |
38 static const char kKeyExpires[] = "expires"; | 38 static const char kKeyExpires[] = "expires"; |
39 static const char kKeyModified[] = "modified"; | 39 static const char kKeyModified[] = "modified"; |
40 | 40 |
41 static const char kKeyPersistent[] = "persistent"; | 41 static const char kKeyPersistent[] = "persistent"; |
42 static const char kKeyTemporary[] = "temporary"; | 42 static const char kKeyTemporary[] = "temporary"; |
43 | 43 |
| 44 static const char kKeyTotalUsage[] = "totalUsage"; |
| 45 static const char kKeyTemporaryUsage[] = "temporaryUsage"; |
| 46 static const char kKeyPersistentUsage[] = "persistentUsage"; |
| 47 static const char kKeyPersistentQuota[] = "persistentQuota"; |
| 48 |
44 // Encodes a pointer value into a hex string. | 49 // Encodes a pointer value into a hex string. |
45 std::string PointerToHexString(const void* pointer) { | 50 std::string PointerToHexString(const void* pointer) { |
46 return base::HexEncode(&pointer, sizeof(pointer)); | 51 return base::HexEncode(&pointer, sizeof(pointer)); |
47 } | 52 } |
48 | 53 |
49 // Decodes a pointer from a hex string. | 54 // Decodes a pointer from a hex string. |
50 void* HexStringToPointer(const std::string& str) { | 55 void* HexStringToPointer(const std::string& str) { |
51 std::vector<uint8> buffer; | 56 std::vector<uint8> buffer; |
52 if (!base::HexStringToBytes(str, &buffer) || | 57 if (!base::HexStringToBytes(str, &buffer) || |
53 buffer.size() != sizeof(void*)) { | 58 buffer.size() != sizeof(void*)) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 l10n_util::GetStringUTF8( | 188 l10n_util::GetStringUTF8( |
184 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE)); | 189 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE)); |
185 dict->SetString(kKeyTemporary, | 190 dict->SetString(kKeyTemporary, |
186 file_system_info.has_temporary ? | 191 file_system_info.has_temporary ? |
187 UTF16ToUTF8(ui::FormatBytes( | 192 UTF16ToUTF8(ui::FormatBytes( |
188 file_system_info.usage_temporary)) : | 193 file_system_info.usage_temporary)) : |
189 l10n_util::GetStringUTF8( | 194 l10n_util::GetStringUTF8( |
190 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE)); | 195 IDS_COOKIES_FILE_SYSTEM_USAGE_NONE)); |
191 break; | 196 break; |
192 } | 197 } |
| 198 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: { |
| 199 dict->SetString(kKeyType, "quota"); |
| 200 dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON"); |
| 201 |
| 202 const BrowsingDataQuotaHelper::QuotaInfo& quota_info = |
| 203 *node.GetDetailedInfo().quota_info; |
| 204 |
| 205 dict->SetString(kKeyOrigin, quota_info.host); |
| 206 |
| 207 if (quota_info.temporary_usage >= 0 && quota_info.persistent_usage >= 0) { |
| 208 dict->SetString(kKeyTotalUsage, |
| 209 UTF16ToUTF8(ui::FormatBytes( |
| 210 quota_info.temporary_usage + |
| 211 quota_info.persistent_usage))); |
| 212 } |
| 213 |
| 214 if (quota_info.temporary_usage >= 0) { |
| 215 dict->SetString(kKeyTemporaryUsage, |
| 216 UTF16ToUTF8(ui::FormatBytes( |
| 217 quota_info.temporary_usage))); |
| 218 } |
| 219 if (quota_info.persistent_usage >= 0) { |
| 220 dict->SetString(kKeyPersistentUsage, |
| 221 UTF16ToUTF8(ui::FormatBytes( |
| 222 quota_info.persistent_usage))); |
| 223 } |
| 224 if (quota_info.persistent_quota >= 0) { |
| 225 dict->SetString(kKeyPersistentQuota, |
| 226 UTF16ToUTF8(ui::FormatBytes( |
| 227 quota_info.persistent_quota))); |
| 228 } |
| 229 break; |
| 230 } |
193 default: | 231 default: |
194 #if defined(OS_MACOSX) | 232 #if defined(OS_MACOSX) |
195 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); | 233 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); |
196 #endif | 234 #endif |
197 break; | 235 break; |
198 } | 236 } |
199 } | 237 } |
200 | 238 |
201 void GetChildNodeList(CookieTreeNode* parent, int start, int count, | 239 void GetChildNodeList(CookieTreeNode* parent, int start, int count, |
202 ListValue* nodes) { | 240 ListValue* nodes) { |
(...skipping 23 matching lines...) Expand all Loading... |
226 if (child_index == -1) | 264 if (child_index == -1) |
227 break; | 265 break; |
228 | 266 |
229 parent = child; | 267 parent = child; |
230 } | 268 } |
231 | 269 |
232 return child_index >= 0 ? child : NULL; | 270 return child_index >= 0 ? child : NULL; |
233 } | 271 } |
234 | 272 |
235 } // namespace cookies_tree_model_util | 273 } // namespace cookies_tree_model_util |
OLD | NEW |