Commit 1f391d4b authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

Move GetSanitizedFileName to web_app_shortcut_win

This change moves function GetSanitizedFileName(), used to sanitize
web-app names for use as filenames on Windows, to the Windows-specific
file web_app_shortcut_win. This also removes logic for non-Windows
operating systems from the function.

GetSanitizedFileName() is only used on Windows: its only callers are in
web_app_shortcut_win.cc and web_app_handler_registration_utils_win.cc.

Change-Id: I06aff89548636c986de0eca637b5a9c54d699505
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508362Reviewed-by: default avatarGlen Robertson <glenrob@chromium.org>
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Cr-Commit-Position: refs/heads/master@{#824135}
parent b847f2eb
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/web_applications/chrome_pwa_launcher/chrome_pwa_launcher_util.h" #include "chrome/browser/web_applications/chrome_pwa_launcher/chrome_pwa_launcher_util.h"
#include "chrome/browser/web_applications/components/web_app_id.h" #include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/browser/web_applications/components/web_app_shortcut.h"
#include "chrome/browser/web_applications/components/web_app_shortcut_win.h" #include "chrome/browser/web_applications/components/web_app_shortcut_win.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/install_static/install_util.h" #include "chrome/install_static/install_util.h"
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/i18n/file_util_icu.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
...@@ -215,16 +214,6 @@ scoped_refptr<base::TaskRunner> GetShortcutIOTaskRunner() { ...@@ -215,16 +214,6 @@ scoped_refptr<base::TaskRunner> GetShortcutIOTaskRunner() {
#endif #endif
} }
base::FilePath GetSanitizedFileName(const base::string16& name) {
#if defined(OS_WIN)
base::string16 file_name = name;
#else
std::string file_name = base::UTF16ToUTF8(name);
#endif
base::i18n::ReplaceIllegalCharactersInPath(&file_name, '_');
return base::FilePath(file_name);
}
base::FilePath GetShortcutDataDir(const ShortcutInfo& shortcut_info) { base::FilePath GetShortcutDataDir(const ShortcutInfo& shortcut_info) {
return GetOsIntegrationResourcesDirectoryForApp(shortcut_info.profile_path, return GetOsIntegrationResourcesDirectoryForApp(shortcut_info.profile_path,
shortcut_info.extension_id, shortcut_info.extension_id,
......
...@@ -197,10 +197,6 @@ void PostShortcutIOTaskAndReply( ...@@ -197,10 +197,6 @@ void PostShortcutIOTaskAndReply(
// blocked so that an inconsistent shortcut state is not left on disk. // blocked so that an inconsistent shortcut state is not left on disk.
scoped_refptr<base::TaskRunner> GetShortcutIOTaskRunner(); scoped_refptr<base::TaskRunner> GetShortcutIOTaskRunner();
// Sanitizes |name| and returns a version of it that is safe to use as an
// on-disk file name.
base::FilePath GetSanitizedFileName(const base::string16& name);
base::FilePath GetShortcutDataDir(const ShortcutInfo& shortcut_info); base::FilePath GetShortcutDataDir(const ShortcutInfo& shortcut_info);
// Delete all the shortcuts for an entire profile. // Delete all the shortcuts for an entire profile.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/hash/md5.h" #include "base/hash/md5.h"
#include "base/i18n/file_util_icu.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/notreached.h" #include "base/notreached.h"
#include "base/path_service.h" #include "base/path_service.h"
...@@ -315,6 +316,12 @@ base::FilePath GetChromeProxyPath() { ...@@ -315,6 +316,12 @@ base::FilePath GetChromeProxyPath() {
namespace internals { namespace internals {
base::FilePath GetSanitizedFileName(const base::string16& name) {
base::string16 file_name = name;
base::i18n::ReplaceIllegalCharactersInPath(&file_name, '_');
return base::FilePath(file_name);
}
std::vector<base::FilePath> FindAppShortcutsByProfileAndTitle( std::vector<base::FilePath> FindAppShortcutsByProfileAndTitle(
const base::FilePath& shortcut_path, const base::FilePath& shortcut_path,
const base::FilePath& profile_path, const base::FilePath& profile_path,
......
...@@ -15,6 +15,10 @@ base::FilePath GetChromeProxyPath(); ...@@ -15,6 +15,10 @@ base::FilePath GetChromeProxyPath();
namespace internals { namespace internals {
// Sanitizes |name| and returns a version of it that is safe to use as an
// on-disk file name.
base::FilePath GetSanitizedFileName(const base::string16& name);
// Returns the Windows user-level shortcut paths that are specified in // Returns the Windows user-level shortcut paths that are specified in
// |creation_locations|. // |creation_locations|.
std::vector<base::FilePath> GetShortcutPaths( std::vector<base::FilePath> GetShortcutPaths(
......
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