summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/webui/cookies_tree_model_util.cc39
-rw-r--r--chrome/browser/ui/webui/cookies_tree_model_util.h3
-rw-r--r--chrome/browser/ui/webui/options/cookies_view_handler.cc4
3 files changed, 41 insertions, 5 deletions
diff --git a/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chrome/browser/ui/webui/cookies_tree_model_util.cc
index ac744b49..05dc69c 100644
--- a/chrome/browser/ui/webui/cookies_tree_model_util.cc
+++ b/chrome/browser/ui/webui/cookies_tree_model_util.cc
@@ -41,6 +41,13 @@ static const char kKeyModified[] = "modified";
static const char kKeyPersistent[] = "persistent";
static const char kKeyTemporary[] = "temporary";
+static const char kKeyTotalUsage[] = "totalUsage";
+static const char kKeyTemporaryUsage[] = "temporaryUsage";
+static const char kKeyPersistentUsage[] = "persistentUsage";
+static const char kKeyPersistentQuota[] = "persistentQuota";
+
+static const int64 kNegligibleUsage = 1024; // 1KiB
+
// Encodes a pointer value into a hex string.
std::string PointerToHexString(const void* pointer) {
return base::HexEncode(&pointer, sizeof(pointer));
@@ -65,7 +72,7 @@ std::string GetTreeNodeId(CookieTreeNode* node) {
return PointerToHexString(node);
}
-void GetCookieTreeNodeDictionary(const CookieTreeNode& node,
+bool GetCookieTreeNodeDictionary(const CookieTreeNode& node,
DictionaryValue* dict) {
// Use node's address as an id for WebUI to look it up.
dict->SetString(kKeyId, PointerToHexString(&node));
@@ -190,12 +197,36 @@ void GetCookieTreeNodeDictionary(const CookieTreeNode& node,
IDS_COOKIES_FILE_SYSTEM_USAGE_NONE));
break;
}
+ case CookieTreeNode::DetailedInfo::TYPE_QUOTA: {
+ dict->SetString(kKeyType, "quota");
+ dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
+
+ const BrowsingDataQuotaHelper::QuotaInfo& quota_info =
+ *node.GetDetailedInfo().quota_info;
+ if (quota_info.temporary_usage + quota_info.persistent_usage <=
+ kNegligibleUsage)
+ return false;
+
+ dict->SetString(kKeyOrigin, quota_info.host);
+ dict->SetString(kKeyTotalUsage,
+ UTF16ToUTF8(ui::FormatBytes(
+ quota_info.temporary_usage +
+ quota_info.persistent_usage)));
+ dict->SetString(kKeyTemporaryUsage,
+ UTF16ToUTF8(ui::FormatBytes(
+ quota_info.temporary_usage)));
+ dict->SetString(kKeyPersistentUsage,
+ UTF16ToUTF8(ui::FormatBytes(
+ quota_info.persistent_usage)));
+ break;
+ }
default:
#if defined(OS_MACOSX)
dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER");
#endif
break;
}
+ return true;
}
void GetChildNodeList(CookieTreeNode* parent, int start, int count,
@@ -203,8 +234,10 @@ void GetChildNodeList(CookieTreeNode* parent, int start, int count,
for (int i = 0; i < count; ++i) {
DictionaryValue* dict = new DictionaryValue;
CookieTreeNode* child = parent->GetChild(start + i);
- GetCookieTreeNodeDictionary(*child, dict);
- nodes->Append(dict);
+ if (GetCookieTreeNodeDictionary(*child, dict))
+ nodes->Append(dict);
+ else
+ delete dict;
}
}
diff --git a/chrome/browser/ui/webui/cookies_tree_model_util.h b/chrome/browser/ui/webui/cookies_tree_model_util.h
index 2b27b65..2331292 100644
--- a/chrome/browser/ui/webui/cookies_tree_model_util.h
+++ b/chrome/browser/ui/webui/cookies_tree_model_util.h
@@ -21,7 +21,8 @@ namespace cookies_tree_model_util {
std::string GetTreeNodeId(CookieTreeNode* node);
// Populate given |dict| with cookie tree node properties.
-void GetCookieTreeNodeDictionary(const CookieTreeNode& node,
+// Returns false if the |node| does not need to be shown.
+bool GetCookieTreeNodeDictionary(const CookieTreeNode& node,
base::DictionaryValue* dict);
// Append the children nodes of |parent| in specified range to |nodes| list.
diff --git a/chrome/browser/ui/webui/options/cookies_view_handler.cc b/chrome/browser/ui/webui/options/cookies_view_handler.cc
index b2c1c7c..b046077 100644
--- a/chrome/browser/ui/webui/options/cookies_view_handler.cc
+++ b/chrome/browser/ui/webui/options/cookies_view_handler.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/browsing_data_database_helper.h"
#include "chrome/browser/browsing_data_file_system_helper.h"
#include "chrome/browser/browsing_data_indexed_db_helper.h"
+#include "chrome/browser/browsing_data_quota_helper.h"
#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/cookies_tree_model_util.h"
@@ -66,7 +67,7 @@ void CookiesViewHandler::GetLocalizedValues(
{ "label_file_system_temporary_usage",
IDS_COOKIES_FILE_SYSTEM_TEMPORARY_USAGE_LABEL },
{ "label_file_system_persistent_usage",
- IDS_COOKIES_FILE_SYSTEM_PERSISTENT_USAGE_LABEL }
+ IDS_COOKIES_FILE_SYSTEM_PERSISTENT_USAGE_LABEL },
};
RegisterStrings(localized_strings, resources, arraysize(resources));
@@ -151,6 +152,7 @@ void CookiesViewHandler::EnsureCookiesTreeModelCreated() {
new BrowsingDataAppCacheHelper(profile),
BrowsingDataIndexedDBHelper::Create(profile),
BrowsingDataFileSystemHelper::Create(profile),
+ BrowsingDataQuotaHelper::Create(profile),
false));
cookies_tree_model_->AddCookiesTreeObserver(this);
}