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

Unified Diff: chrome/common/extensions/extension_file_util.cc

Issue 6246036: FilePath: Remove most of ToWStringHack, adding a LossyDisplayName() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bug link Created 9 years, 11 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/common/extensions/extension.cc ('k') | chrome/common/sandbox_policy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_file_util.cc
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index 44668e8247a2ef7a5642d8f55a5468f124d63916..7aef372880ebb803cea2aa18f628ccba647a0064 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -161,7 +161,7 @@ bool ValidateExtension(Extension* extension, std::string* error) {
if (!file_util::PathExists(image_path)) {
*error =
l10n_util::GetStringFUTF8(IDS_EXTENSION_INVALID_IMAGE_PATH,
- WideToUTF16(image_path.ToWStringHack()));
+ image_path.LossyDisplayName());
return false;
}
}
@@ -203,7 +203,7 @@ bool ValidateExtension(Extension* extension, std::string* error) {
*error =
l10n_util::GetStringFUTF8(
IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED,
- WideToUTF16(plugin.path.ToWStringHack()));
+ plugin.path.LossyDisplayName());
return false;
}
}
@@ -250,7 +250,7 @@ bool ValidateExtension(Extension* extension, std::string* error) {
*error =
l10n_util::GetStringFUTF8(
IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED,
- WideToUTF16(page_path.ToWStringHack()));
+ page_path.LossyDisplayName());
return false;
}
}
@@ -265,7 +265,7 @@ bool ValidateExtension(Extension* extension, std::string* error) {
*error =
l10n_util::GetStringFUTF8(
IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED,
- WideToUTF16(options_path.ToWStringHack()));
+ options_path.LossyDisplayName());
return false;
}
}
@@ -280,7 +280,7 @@ bool ValidateExtension(Extension* extension, std::string* error) {
*error =
l10n_util::GetStringFUTF8(
IDS_EXTENSION_LOAD_SIDEBAR_PAGE_FAILED,
- WideToUTF16(page_path.ToWStringHack()));
+ page_path.LossyDisplayName());
return false;
}
}
@@ -312,15 +312,21 @@ void GarbageCollectExtensions(
FilePath extension_path;
for (extension_path = enumerator.Next(); !extension_path.value().empty();
extension_path = enumerator.Next()) {
- std::string extension_id = WideToASCII(
- extension_path.BaseName().ToWStringHack());
+ std::string extension_id;
+
+ FilePath basename = extension_path.BaseName();
+ if (IsStringASCII(basename.value())) {
+ extension_id = UTF16ToASCII(basename.LossyDisplayName());
+ if (!Extension::IdIsValid(extension_id))
+ extension_id.clear();
+ }
// Delete directories that aren't valid IDs.
- if (!Extension::IdIsValid(extension_id)) {
+ if (extension_id.empty()) {
LOG(WARNING) << "Invalid extension ID encountered in extensions "
- "directory: " << extension_id;
+ "directory: " << basename.value();
VLOG(1) << "Deleting invalid extension directory "
- << WideToASCII(extension_path.ToWStringHack()) << ".";
+ << extension_path.value() << ".";
file_util::Delete(extension_path, true); // Recursive.
continue;
}
@@ -333,7 +339,7 @@ void GarbageCollectExtensions(
// complete, for example, when a plugin is in use at uninstall time.
if (iter == extension_paths.end()) {
VLOG(1) << "Deleting unreferenced install for directory "
- << WideToASCII(extension_path.ToWStringHack()) << ".";
+ << extension_path.LossyDisplayName() << ".";
file_util::Delete(extension_path, true); // Recursive.
continue;
}
@@ -348,7 +354,7 @@ void GarbageCollectExtensions(
version_dir = versions_enumerator.Next()) {
if (version_dir.BaseName() != iter->second.BaseName()) {
VLOG(1) << "Deleting old version for directory "
- << WideToASCII(version_dir.ToWStringHack()) << ".";
+ << version_dir.LossyDisplayName() << ".";
file_util::Delete(version_dir, true); // Recursive.
}
}
@@ -428,7 +434,7 @@ static bool ValidateLocaleInfo(const Extension& extension, std::string* error) {
if (!file_util::PathExists(messages_path)) {
*error = base::StringPrintf(
"%s %s", errors::kLocalesMessagesFileMissing,
- WideToUTF8(messages_path.ToWStringHack()).c_str());
+ UTF16ToUTF8(messages_path.LossyDisplayName()).c_str());
return false;
}
@@ -454,14 +460,14 @@ static bool IsScriptValid(const FilePath& path,
!file_util::ReadFileToString(path, &content)) {
*error = l10n_util::GetStringFUTF8(
message_id,
- WideToUTF16(relative_path.ToWStringHack()));
+ relative_path.LossyDisplayName());
return false;
}
if (!IsStringUTF8(content)) {
*error = l10n_util::GetStringFUTF8(
IDS_EXTENSION_BAD_FILE_ENCODING,
- WideToUTF16(relative_path.ToWStringHack()));
+ relative_path.LossyDisplayName());
return false;
}
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/sandbox_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698