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

Unified Diff: chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc

Issue 2676393002: Extensions: Only display host name for the overridden home and start-up pages. (Closed)
Patch Set: Address review Created 3 years, 10 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 | « no previous file | chrome/common/extensions/permissions/settings_override_permission_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
diff --git a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
index 0e50db9d3f208301b89290be6cfcf5cda89540f9..4f05e007fea643379bc806366c5ff154f3372b32 100644
--- a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
+++ b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc
@@ -101,12 +101,15 @@ std::unique_ptr<ChromeSettingsOverrides::Search_provider> ParseSearchEngine(
return std::move(overrides->search_provider);
}
-// A www. prefix is not informative and thus not worth the limited real estate
-// in the permissions UI.
-std::string RemoveWwwPrefix(const std::string& url) {
- if (base::StartsWith(url, kWwwPrefix, base::CompareCase::INSENSITIVE_ASCII))
- return url.substr(strlen(kWwwPrefix));
- return url;
+std::string FormatUrlForDisplay(const GURL& url) {
+ base::StringPiece host = url.host_piece();
+ // A www. prefix is not informative and thus not worth the limited real estate
+ // in the permissions UI.
+ base::StringPiece formatted_host =
+ base::StartsWith(host, kWwwPrefix, base::CompareCase::INSENSITIVE_ASCII)
+ ? host.substr(strlen(kWwwPrefix))
+ : host;
+ return formatted_host.as_string();
}
} // namespace
@@ -148,13 +151,11 @@ bool SettingsOverridesHandler::Parse(Extension* extension,
if (info->search_engine) {
PermissionsParser::AddAPIPermission(
- extension,
- new SettingsOverrideAPIPermission(
- PermissionsInfo::GetInstance()->GetByID(
- APIPermission::kSearchProvider),
- RemoveWwwPrefix(CreateManifestURL(info->search_engine->search_url)
- ->GetOrigin()
- .host())));
+ extension, new SettingsOverrideAPIPermission(
+ PermissionsInfo::GetInstance()->GetByID(
+ APIPermission::kSearchProvider),
+ FormatUrlForDisplay(*CreateManifestURL(
+ info->search_engine->search_url))));
}
if (!info->startup_pages.empty()) {
PermissionsParser::AddAPIPermission(
@@ -163,16 +164,15 @@ bool SettingsOverridesHandler::Parse(Extension* extension,
PermissionsInfo::GetInstance()->GetByID(
APIPermission::kStartupPages),
// We only support one startup page even though the type of the
- // manifest
- // property is a list, only the first one is used.
- RemoveWwwPrefix(info->startup_pages[0].GetContent())));
+ // manifest property is a list, only the first one is used.
+ FormatUrlForDisplay(info->startup_pages[0])));
}
if (info->homepage) {
PermissionsParser::AddAPIPermission(
extension,
new SettingsOverrideAPIPermission(
PermissionsInfo::GetInstance()->GetByID(APIPermission::kHomepage),
- RemoveWwwPrefix(info->homepage->GetContent())));
+ FormatUrlForDisplay(*(info->homepage))));
}
extension->SetManifestData(manifest_keys::kSettingsOverride,
info.release());
« no previous file with comments | « no previous file | chrome/common/extensions/permissions/settings_override_permission_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698