When the download policy is specified but left empty revert to default download location.

If this is not done downloads go to crazy places like the chrome install
dir or god knows where else.

BUG=90722
TEST=Set the policy to empty string and observe downloads going to the default location instead.


Review URL: http://codereview.chromium.org/7583005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98411 0039d316-1c4b-4281-b951-d872f2087c98
parent cb289d04
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/policy/browser_policy_connector.h" #include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/policy/configuration_policy_provider.h" #include "chrome/browser/policy/configuration_policy_provider.h"
#include "chrome/browser/policy/policy_path_parser.h" #include "chrome/browser/policy/policy_path_parser.h"
...@@ -481,6 +482,11 @@ bool ConfigurationPolicyPrefKeeper::ApplyDownloadDirPolicy( ...@@ -481,6 +482,11 @@ bool ConfigurationPolicyPrefKeeper::ApplyDownloadDirPolicy(
DCHECK(result); DCHECK(result);
FilePath::StringType expanded_value = FilePath::StringType expanded_value =
policy::path_parser::ExpandPathVariables(string_value); policy::path_parser::ExpandPathVariables(string_value);
// Leaving the policy empty would revert to the default download location
// else we would point in an undefined location. We do this after the
// path expansion because it might lead to an empty string(e.g. for "\"\"").
if (expanded_value.empty())
expanded_value = download_util::GetDefaultDownloadDirectory().value();
prefs_.SetValue(prefs::kDownloadDefaultDirectory, prefs_.SetValue(prefs::kDownloadDefaultDirectory,
Value::CreateStringValue(expanded_value)); Value::CreateStringValue(expanded_value));
prefs_.SetValue(prefs::kPromptForDownload, prefs_.SetValue(prefs::kPromptForDownload,
......
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