Commit eb08cced authored by dhnishi's avatar dhnishi Committed by Commit bot

Fix a bug where the resource manager displays Chrome Apps with non-human readable names.

i.e. "chrome-extension://<id>" instead of "Chrome Dev Editor"

BUG=407451

Review URL: https://codereview.chromium.org/505073002

Cr-Commit-Position: refs/heads/master@{#291953}
parent 64275214
......@@ -15,6 +15,7 @@ cr.define('options', function() {
el.origin_ = origin.origin;
el.usage_ = origin.usage;
el.usageString_ = origin.usageString;
el.readableName_ = origin.readableName;
el.__proto__ = OriginListItem.prototype;
el.decorate();
return el;
......@@ -33,7 +34,7 @@ cr.define('options', function() {
var titleEl = this.ownerDocument.createElement('div');
titleEl.className = 'title favicon-cell weaktrl';
titleEl.textContent = this.origin_;
titleEl.textContent = this.readableName_;
titleEl.originPattern = this.origin_;
titleEl.style.backgroundImage = getFaviconImageSet(this.origin_);
this.contentElement_.appendChild(titleEl);
......
......@@ -86,7 +86,8 @@ cr.define('options', function() {
return {
origin: origin,
usage: originDict[origin].usage,
usageString: originDict[origin].usageString
usageString: originDict[origin].usageString,
readableName: originDict[origin].readableName,
};
});
origins.sort(function(first, second) {
......
......@@ -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"
......@@ -268,6 +270,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);
}
......@@ -458,6 +462,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",
......@@ -512,4 +518,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
......@@ -102,6 +102,9 @@ class WebsiteSettingsHandler : public content_settings::Observer,
// Updates the page with the last settings used.
void Update();
// Returns the base URL for websites, or the app name for Chrome App URLs.
const std::string& GetReadableName(const GURL& site_url);
std::string last_setting_;
std::string last_filter_;
GURL last_site_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment