OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/policy/configuration_policy_pref_store.h" | 5 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/string16.h" | 16 #include "base/string16.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/download/download_util.h" |
21 #include "chrome/browser/policy/browser_policy_connector.h" | 22 #include "chrome/browser/policy/browser_policy_connector.h" |
22 #include "chrome/browser/policy/configuration_policy_provider.h" | 23 #include "chrome/browser/policy/configuration_policy_provider.h" |
23 #include "chrome/browser/policy/policy_path_parser.h" | 24 #include "chrome/browser/policy/policy_path_parser.h" |
24 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 25 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
25 #include "chrome/browser/prefs/pref_value_map.h" | 26 #include "chrome/browser/prefs/pref_value_map.h" |
26 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 27 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
27 #include "chrome/browser/search_engines/search_terms_data.h" | 28 #include "chrome/browser/search_engines/search_terms_data.h" |
28 #include "chrome/browser/search_engines/template_url.h" | 29 #include "chrome/browser/search_engines/template_url.h" |
29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
30 #include "content/common/notification_service.h" | 31 #include "content/common/notification_service.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // expanded string. | 471 // expanded string. |
471 if (policy == kPolicyDownloadDirectory) { | 472 if (policy == kPolicyDownloadDirectory) { |
472 // This policy is ignored on ChromeOS because the download path there is | 473 // This policy is ignored on ChromeOS because the download path there is |
473 // fixed and can not be configured by the user. | 474 // fixed and can not be configured by the user. |
474 #if !defined(OS_CHROMEOS) | 475 #if !defined(OS_CHROMEOS) |
475 FilePath::StringType string_value; | 476 FilePath::StringType string_value; |
476 bool result = value->GetAsString(&string_value); | 477 bool result = value->GetAsString(&string_value); |
477 DCHECK(result); | 478 DCHECK(result); |
478 FilePath::StringType expanded_value = | 479 FilePath::StringType expanded_value = |
479 policy::path_parser::ExpandPathVariables(string_value); | 480 policy::path_parser::ExpandPathVariables(string_value); |
| 481 // Leaving the policy empty would revert to the default download location |
| 482 // else we would point in an undefined location. We do this after the |
| 483 // path expansion because it might lead to an empty string(e.g. for "\"\""). |
| 484 if (expanded_value.empty()) |
| 485 expanded_value = download_util::GetDefaultDownloadDirectory().value(); |
480 prefs_.SetValue(prefs::kDownloadDefaultDirectory, | 486 prefs_.SetValue(prefs::kDownloadDefaultDirectory, |
481 Value::CreateStringValue(expanded_value)); | 487 Value::CreateStringValue(expanded_value)); |
482 prefs_.SetValue(prefs::kPromptForDownload, | 488 prefs_.SetValue(prefs::kPromptForDownload, |
483 Value::CreateBooleanValue(false)); | 489 Value::CreateBooleanValue(false)); |
484 #endif // !defined(OS_CHROMEOS) | 490 #endif // !defined(OS_CHROMEOS) |
485 delete value; | 491 delete value; |
486 return true; | 492 return true; |
487 } | 493 } |
488 // We are not interested in this policy. | 494 // We are not interested in this policy. |
489 return false; | 495 return false; |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 // Update the initialization flag. | 1211 // Update the initialization flag. |
1206 if (!initialization_complete_ && | 1212 if (!initialization_complete_ && |
1207 provider_->IsInitializationComplete()) { | 1213 provider_->IsInitializationComplete()) { |
1208 initialization_complete_ = true; | 1214 initialization_complete_ = true; |
1209 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 1215 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
1210 OnInitializationCompleted(true)); | 1216 OnInitializationCompleted(true)); |
1211 } | 1217 } |
1212 } | 1218 } |
1213 | 1219 |
1214 } // namespace policy | 1220 } // namespace policy |
OLD | NEW |