Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: chrome/browser/ui/webui/cookies_tree_model_util.cc

Issue 7387007: Adding usage and quota entry to chrome://settings/cookies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Omit column header Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 dict->SetString(kKeyOrigin, quota_info.host);
205 dict->SetString(kKeyTotalUsage,
Mike Mammarella 2011/07/29 17:59:26 In the example screenshot you have some data that'
tzik 2011/08/01 02:46:26 Done.
206 UTF16ToUTF8(ui::FormatBytes(
207 quota_info.temporary_usage +
208 quota_info.persistent_usage)));
209 dict->SetString(kKeyTemporaryUsage,
210 UTF16ToUTF8(ui::FormatBytes(
211 quota_info.temporary_usage)));
212 dict->SetString(kKeyPersistentUsage,
213 UTF16ToUTF8(ui::FormatBytes(
214 quota_info.persistent_usage)));
215 break;
216 }
193 default: 217 default:
194 #if defined(OS_MACOSX) 218 #if defined(OS_MACOSX)
195 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER"); 219 dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER");
196 #endif 220 #endif
197 break; 221 break;
198 } 222 }
199 } 223 }
200 224
201 void GetChildNodeList(CookieTreeNode* parent, int start, int count, 225 void GetChildNodeList(CookieTreeNode* parent, int start, int count,
202 ListValue* nodes) { 226 ListValue* nodes) {
(...skipping 23 matching lines...) Expand all
226 if (child_index == -1) 250 if (child_index == -1)
227 break; 251 break;
228 252
229 parent = child; 253 parent = child;
230 } 254 }
231 255
232 return child_index >= 0 ? child : NULL; 256 return child_index >= 0 ? child : NULL;
233 } 257 }
234 258
235 } // namespace cookies_tree_model_util 259 } // namespace cookies_tree_model_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698