From 493d192f856567f441b2a8b436b9fb7ddfdbd4ad Mon Sep 17 00:00:00 2001 From: "kkanetkar@chromium.org" Date: Fri, 2 Apr 2010 01:46:54 +0000 Subject: Adding disabled appcaches information along with capability of removing appcaches with button clicks. BUG=38463 TEST=Run chrome, navigate to about:appcache-internals, add/view/remove appcaches. Review URL: http://codereview.chromium.org/1576009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43430 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/appcache/view_appcache_internals_job.cc | 133 +++++++++++++++++++++---- webkit/appcache/view_appcache_internals_job.h | 15 +-- 2 files changed, 121 insertions(+), 27 deletions(-) (limited to 'webkit') diff --git a/webkit/appcache/view_appcache_internals_job.cc b/webkit/appcache/view_appcache_internals_job.cc index 49384ac..6cd11a0 100644 --- a/webkit/appcache/view_appcache_internals_job.cc +++ b/webkit/appcache/view_appcache_internals_job.cc @@ -9,24 +9,51 @@ #include "base/utf_string_conversions.h" #include "base/i18n/time_formatting.h" #include "base/string_util.h" +#include "net/base/escape.h" +#include "net/url_request/url_request.h" +#include "webkit/appcache/appcache_policy.h" #include "webkit/appcache/appcache_service.h" namespace { -const char kErrorMessage[] = "Error in retrieving Application caches."; -const char kEmptyAppCachesMessage[] = "No available Application caches."; +const char kErrorMessage[] = "Error in retrieving Application Caches."; +const char kEmptyAppCachesMessage[] = "No available Application Caches."; +const char kRemoveAppCache[] = "Remove this AppCache"; +const char kManifest[] = "Manifest: "; +const char kSize[] = "Size: "; +const char kCreationTime[] = "Creation Time: "; +const char kLastAccessTime[] = "Last Access Time: "; +const char kLastUpdateTime[] = "Last Update Time: "; +const char kFormattedDisabledAppCacheMsg[] = + "" + "This Application Cache is disabled by policy.
"; void StartHTML(std::string* out) { DCHECK(out); out->append( "" - "AppCache Internals" + "AppCache Internals" ""); + "" + "\n" + "" + "
" + "" + "
"); } void EndHTML(std::string* out) { @@ -34,6 +61,17 @@ void EndHTML(std::string* out) { out->append(""); } +// Appends an input button to |data| with text |title| that sends the command +// string |command| back to the browser, and then refreshes the page. +void DrawCommandButton(const std::string& title, + const std::string& command, + std::string* data) { + StringAppendF(data, "", + title.c_str(), + command.c_str()); +} + void AddLiTag(const std::string& element_title, const std::string& element_data, std::string* out) { DCHECK(out); @@ -52,6 +90,7 @@ void WrapInHREF(const std::string& in, std::string* out) { } void AddHTMLFromAppCacheToOutput( + const appcache::AppCacheService& appcache_service, const appcache::AppCacheInfoVector& appcaches, std::string* out) { for (std::vector::const_iterator info = appcaches.begin(); @@ -59,23 +98,29 @@ void AddHTMLFromAppCacheToOutput( out->append("

"); std::string anchored_manifest; WrapInHREF(info->manifest_url.spec(), &anchored_manifest); - out->append("Manifest: "); + out->append(kManifest); out->append(anchored_manifest); + if (!appcache_service.appcache_policy()->CanLoadAppCache( + info->manifest_url)) { + out->append(kFormattedDisabledAppCacheMsg); + } + out->append("
"); + DrawCommandButton(kRemoveAppCache, info->manifest_url.spec(), out); out->append("