summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-01 21:19:15 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-01 21:19:15 +0000
commita1d906f9a26ee9b56be0bc78210cb5526f01ee2e (patch)
tree46df778f9d93b09970ebf895bc99b87e63d1b367
parentc5f9f1854f1cac2a4e7c459e86bc46a44365f7cf (diff)
downloadchromium_src-a1d906f9a26ee9b56be0bc78210cb5526f01ee2e.zip
chromium_src-a1d906f9a26ee9b56be0bc78210cb5526f01ee2e.tar.gz
chromium_src-a1d906f9a26ee9b56be0bc78210cb5526f01ee2e.tar.bz2
Don't create the default download directory just because we ask for its location. This is a first step toward not creating _any_ directories when we merely ask for their locations. Patch by Marc-André Decoste, r=cpu. See http://codereview.chromium.org/11586 .
Bug=4575 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6164 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/chrome_paths.cc25
1 files changed, 11 insertions, 14 deletions
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index ead0884..1ffaaf4 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -68,15 +68,16 @@ bool PathProvider(int key, FilePath* result) {
return PathService::Get(base::FILE_MODULE, result);
}
- // Assume that we will need to create the directory if it does not already
- // exist. This flag can be set to true to prevent checking.
- bool exists = false;
+ // Assume that we will not need to create the directory if it does not exist.
+ // This flag can be set to true for the cases where we want to create it.
+ bool create_dir = false;
std::wstring cur;
switch (key) {
case chrome::DIR_USER_DATA:
if (!GetDefaultUserDataDirectory(&cur))
return false;
+ create_dir = true;
break;
case chrome::DIR_USER_DOCUMENTS:
#if defined(OS_WIN)
@@ -93,6 +94,7 @@ bool PathProvider(int key, FilePath* result) {
NOTIMPLEMENTED();
return false;
#endif
+ create_dir = true;
break;
case chrome::DIR_DEFAULT_DOWNLOADS:
// On Vista, we can get the download path using a Win API
@@ -116,6 +118,7 @@ bool PathProvider(int key, FilePath* result) {
if (!GetDefaultUserDataDirectory(&cur))
return false;
file_util::AppendToPath(&cur, L"Crash Reports");
+ create_dir = true;
break;
case chrome::DIR_USER_DESKTOP:
#if defined(OS_WIN)
@@ -138,34 +141,36 @@ bool PathProvider(int key, FilePath* result) {
NOTIMPLEMENTED();
return false;
#endif
- exists = true;
break;
case chrome::DIR_RESOURCES:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
file_util::AppendToPath(&cur, L"resources");
+ create_dir = true;
break;
case chrome::DIR_INSPECTOR:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
file_util::AppendToPath(&cur, L"Resources");
file_util::AppendToPath(&cur, L"Inspector");
- exists = true;
break;
case chrome::DIR_THEMES:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
file_util::AppendToPath(&cur, L"themes");
+ create_dir = true;
break;
case chrome::DIR_LOCALES:
if (!PathService::Get(chrome::DIR_APP, &cur))
return false;
file_util::AppendToPath(&cur, L"locales");
+ create_dir = true;
break;
case chrome::DIR_APP_DICTIONARIES:
if (!PathService::Get(base::DIR_EXE, &cur))
return false;
file_util::AppendToPath(&cur, L"Dictionaries");
+ create_dir = true;
break;
case chrome::DIR_USER_SCRIPTS:
// TODO(aa): Figure out where the script directory should live.
@@ -175,19 +180,16 @@ bool PathProvider(int key, FilePath* result) {
NOTIMPLEMENTED();
return false;
#endif
- exists = true; // don't trigger directory creation code
break;
case chrome::FILE_LOCAL_STATE:
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
return false;
file_util::AppendToPath(&cur, chrome::kLocalStateFilename);
- exists = true; // don't trigger directory creation code
break;
case chrome::FILE_RECORDED_SCRIPT:
if (!PathService::Get(chrome::DIR_USER_DATA, &cur))
return false;
file_util::AppendToPath(&cur, L"script.log");
- exists = true;
break;
case chrome::FILE_GEARS_PLUGIN:
if (!GetGearsPluginPathFromCommandLine(&cur)) {
@@ -206,7 +208,6 @@ bool PathProvider(int key, FilePath* result) {
file_util::AppendToPath(&cur, L"gears.dll");
}
}
- exists = true;
break;
// The following are only valid in the development environment, and
// will fail if executed from an installed executable (because the
@@ -219,7 +220,6 @@ bool PathProvider(int key, FilePath* result) {
file_util::AppendToPath(&cur, L"data");
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
- exists = true;
break;
case chrome::DIR_TEST_TOOLS:
if (!PathService::Get(chrome::DIR_APP, &cur))
@@ -229,7 +229,6 @@ bool PathProvider(int key, FilePath* result) {
file_util::AppendToPath(&cur, L"test");
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
- exists = true;
break;
case chrome::FILE_PYTHON_RUNTIME:
if (!PathService::Get(chrome::DIR_APP, &cur))
@@ -241,7 +240,6 @@ bool PathProvider(int key, FilePath* result) {
file_util::AppendToPath(&cur, L"python.exe");
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
- exists = true;
break;
case chrome::FILE_TEST_SERVER:
if (!PathService::Get(chrome::DIR_APP, &cur))
@@ -253,13 +251,12 @@ bool PathProvider(int key, FilePath* result) {
file_util::AppendToPath(&cur, L"testserver.py");
if (!file_util::PathExists(cur)) // we don't want to create this
return false;
- exists = true;
break;
default:
return false;
}
- if (!exists && !file_util::PathExists(cur) && !file_util::CreateDirectory(cur))
+ if (create_dir && !file_util::PathExists(cur) && !file_util::CreateDirectory(cur))
return false;
*result = FilePath::FromWStringHack(cur);