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

Unified Diff: chrome/browser/ui/webui/options/website_settings_handler.cc

Issue 505073002: Fix a bug where the resource manager displays Chrome Apps with non-human readable names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a clarifying comment. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/website_settings_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/website_settings_handler.cc
diff --git a/chrome/browser/ui/webui/options/website_settings_handler.cc b/chrome/browser/ui/webui/options/website_settings_handler.cc
index 8999398729c5b6544fce9b9304da7b763dc23797..7729ce695ecb28a317e7b9cddc610e6fb8c80536 100644
--- a/chrome/browser/ui/webui/options/website_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/website_settings_handler.cc
@@ -7,6 +7,7 @@
#include "apps/app_window_registry.h"
#include "chrome/browser/content_settings/content_settings_utils.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_iterator.h"
@@ -16,6 +17,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "grit/generated_resources.h"
@@ -261,6 +263,8 @@ void WebsiteSettingsHandler::UpdateOrigins() {
base::Time::Now() - last_usage);
}
origin_entry->SetStringWithoutPathExpansion("usageString", usage_string);
+ origin_entry->SetStringWithoutPathExpansion("readableName",
+ GetReadableName(origin_url));
origins.SetWithoutPathExpansion(origin, origin_entry);
}
@@ -451,6 +455,8 @@ void WebsiteSettingsHandler::UpdateLocalStorage() {
"usage", new base::FundamentalValue(static_cast<double>(it->size)));
origin_entry->SetWithoutPathExpansion(
"usageString", new base::StringValue(ui::FormatBytes(it->size)));
+ origin_entry->SetStringWithoutPathExpansion(
+ "readableName", GetReadableName(it->origin_url));
local_storage_map.SetWithoutPathExpansion(origin, origin_entry);
}
web_ui()->CallJavascriptFunction("WebsiteSettingsManager.populateOrigins",
@@ -505,4 +511,22 @@ void WebsiteSettingsHandler::DeleteLocalStorage(const GURL& site_url) {
weak_ptr_factory_.GetWeakPtr()));
}
+const std::string& WebsiteSettingsHandler::GetReadableName(
+ const GURL& site_url) {
+ if (site_url.SchemeIs(extensions::kExtensionScheme)) {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
+
+ const extensions::Extension* extension =
+ extension_service->extensions()->GetExtensionOrAppByURL(site_url);
+ // If extension is NULL, it was removed and we cannot look up its name.
+ if (!extension)
+ return site_url.spec();
+
+ return extension->name();
+ }
+ return site_url.spec();
+}
+
} // namespace options
« no previous file with comments | « chrome/browser/ui/webui/options/website_settings_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698