| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/download/download_dir_policy_handler.h" | 5 #include "chrome/browser/download/download_dir_policy_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 #else | 98 #else |
| 99 expanded_value = policy::path_parser::ExpandPathVariables(string_value); | 99 expanded_value = policy::path_parser::ExpandPathVariables(string_value); |
| 100 #endif | 100 #endif |
| 101 // Make sure the path isn't empty, since that will point to an undefined | 101 // Make sure the path isn't empty, since that will point to an undefined |
| 102 // location; the default location is used instead in that case. | 102 // location; the default location is used instead in that case. |
| 103 // This is checked after path expansion because a non-empty policy value can | 103 // This is checked after path expansion because a non-empty policy value can |
| 104 // lead to an empty path value after expansion (e.g. "\"\""). | 104 // lead to an empty path value after expansion (e.g. "\"\""). |
| 105 if (expanded_value.empty()) | 105 if (expanded_value.empty()) |
| 106 expanded_value = DownloadPrefs::GetDefaultDownloadDirectory().value(); | 106 expanded_value = DownloadPrefs::GetDefaultDownloadDirectory().value(); |
| 107 prefs->SetValue(prefs::kDownloadDefaultDirectory, | 107 prefs->SetValue(prefs::kDownloadDefaultDirectory, |
| 108 base::WrapUnique(new base::StringValue(expanded_value))); | 108 base::MakeUnique<base::StringValue>(expanded_value)); |
| 109 | 109 |
| 110 // If the policy is mandatory, prompt for download should be disabled. | 110 // If the policy is mandatory, prompt for download should be disabled. |
| 111 // Otherwise, it would enable a user to bypass the mandatory policy. | 111 // Otherwise, it would enable a user to bypass the mandatory policy. |
| 112 if (policies.Get(policy_name())->level == policy::POLICY_LEVEL_MANDATORY) { | 112 if (policies.Get(policy_name())->level == policy::POLICY_LEVEL_MANDATORY) { |
| 113 prefs->SetBoolean(prefs::kPromptForDownload, false); | 113 prefs->SetBoolean(prefs::kPromptForDownload, false); |
| 114 #if defined(OS_CHROMEOS) | 114 #if defined(OS_CHROMEOS) |
| 115 if (download_to_drive) { | 115 if (download_to_drive) { |
| 116 prefs->SetBoolean(drive::prefs::kDisableDrive, false); | 116 prefs->SetBoolean(drive::prefs::kDisableDrive, false); |
| 117 } | 117 } |
| 118 #endif | 118 #endif |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 void DownloadDirPolicyHandler::ApplyPolicySettings( | 122 void DownloadDirPolicyHandler::ApplyPolicySettings( |
| 123 const policy::PolicyMap& /* policies */, | 123 const policy::PolicyMap& /* policies */, |
| 124 PrefValueMap* /* prefs */) { | 124 PrefValueMap* /* prefs */) { |
| 125 NOTREACHED(); | 125 NOTREACHED(); |
| 126 } | 126 } |
| OLD | NEW |