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> |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 return true; | 436 return true; |
437 } | 437 } |
438 return false; | 438 return false; |
439 } | 439 } |
440 | 440 |
441 bool ConfigurationPolicyPrefKeeper::ApplyAutofillPolicy( | 441 bool ConfigurationPolicyPrefKeeper::ApplyAutofillPolicy( |
442 ConfigurationPolicyType policy, Value* value) { | 442 ConfigurationPolicyType policy, Value* value) { |
443 if (policy == kPolicyAutoFillEnabled) { | 443 if (policy == kPolicyAutoFillEnabled) { |
444 bool auto_fill_enabled; | 444 bool auto_fill_enabled; |
445 if (value->GetAsBoolean(&auto_fill_enabled) && !auto_fill_enabled) | 445 if (value->GetAsBoolean(&auto_fill_enabled) && !auto_fill_enabled) |
446 prefs_.SetValue(prefs::kAutofillEnabled, | 446 prefs_.SetValue(prefs::kAutofillEnabled, base::FalseValue()); |
447 Value::CreateBooleanValue(false)); | |
448 delete value; | 447 delete value; |
449 return true; | 448 return true; |
450 } | 449 } |
451 return false; | 450 return false; |
452 } | 451 } |
453 | 452 |
454 bool ConfigurationPolicyPrefKeeper::ApplyDownloadDirPolicy( | 453 bool ConfigurationPolicyPrefKeeper::ApplyDownloadDirPolicy( |
455 ConfigurationPolicyType policy, | 454 ConfigurationPolicyType policy, |
456 Value* value) { | 455 Value* value) { |
457 // Replace the policy string which might contain some user variables to an | 456 // Replace the policy string which might contain some user variables to an |
458 // expanded string. | 457 // expanded string. |
459 if (policy == kPolicyDownloadDirectory) { | 458 if (policy == kPolicyDownloadDirectory) { |
460 // This policy is ignored on ChromeOS because the download path there is | 459 // This policy is ignored on ChromeOS because the download path there is |
461 // fixed and can not be configured by the user. | 460 // fixed and can not be configured by the user. |
462 #if !defined(OS_CHROMEOS) | 461 #if !defined(OS_CHROMEOS) |
463 FilePath::StringType string_value; | 462 FilePath::StringType string_value; |
464 bool result = value->GetAsString(&string_value); | 463 bool result = value->GetAsString(&string_value); |
465 DCHECK(result); | 464 DCHECK(result); |
466 FilePath::StringType expanded_value = | 465 FilePath::StringType expanded_value = |
467 policy::path_parser::ExpandPathVariables(string_value); | 466 policy::path_parser::ExpandPathVariables(string_value); |
468 prefs_.SetValue(prefs::kDownloadDefaultDirectory, | 467 prefs_.SetValue(prefs::kDownloadDefaultDirectory, |
469 Value::CreateStringValue(expanded_value)); | 468 Value::CreateStringValue(expanded_value)); |
470 prefs_.SetValue(prefs::kPromptForDownload, | 469 prefs_.SetValue(prefs::kPromptForDownload, base::FalseValue()); |
471 Value::CreateBooleanValue(false)); | |
472 #endif // !defined(OS_CHROMEOS) | 470 #endif // !defined(OS_CHROMEOS) |
473 delete value; | 471 delete value; |
474 return true; | 472 return true; |
475 } | 473 } |
476 // We are not interested in this policy. | 474 // We are not interested in this policy. |
477 return false; | 475 return false; |
478 } | 476 } |
479 | 477 |
480 bool ConfigurationPolicyPrefKeeper::ApplyDiskCacheDirPolicy( | 478 bool ConfigurationPolicyPrefKeeper::ApplyDiskCacheDirPolicy( |
481 ConfigurationPolicyType policy, | 479 ConfigurationPolicyType policy, |
(...skipping 20 matching lines...) Expand all Loading... |
502 Value* value) { | 500 Value* value) { |
503 if (policy == kPolicyAllowFileSelectionDialogs) { | 501 if (policy == kPolicyAllowFileSelectionDialogs) { |
504 prefs_.SetValue(prefs::kAllowFileSelectionDialogs, value); | 502 prefs_.SetValue(prefs::kAllowFileSelectionDialogs, value); |
505 // If file-selection dialogs are not allowed we forbid the user to be | 503 // If file-selection dialogs are not allowed we forbid the user to be |
506 // prompted for the download location, since this would end up in an Infobar | 504 // prompted for the download location, since this would end up in an Infobar |
507 // explaining that file-selection dialogs are forbidden anyways. | 505 // explaining that file-selection dialogs are forbidden anyways. |
508 bool allow_file_selection_dialogs = true; | 506 bool allow_file_selection_dialogs = true; |
509 bool result = value->GetAsBoolean(&allow_file_selection_dialogs); | 507 bool result = value->GetAsBoolean(&allow_file_selection_dialogs); |
510 DCHECK(result); | 508 DCHECK(result); |
511 if (!allow_file_selection_dialogs) { | 509 if (!allow_file_selection_dialogs) { |
512 prefs_.SetValue(prefs::kPromptForDownload, | 510 prefs_.SetValue(prefs::kPromptForDownload, base::FalseValue()); |
513 Value::CreateBooleanValue(false)); | |
514 } | 511 } |
515 return true; | 512 return true; |
516 } | 513 } |
517 // We are not interested in this policy. | 514 // We are not interested in this policy. |
518 return false; | 515 return false; |
519 } | 516 } |
520 | 517 |
521 bool ConfigurationPolicyPrefKeeper::ApplyDefaultSearchPolicy( | 518 bool ConfigurationPolicyPrefKeeper::ApplyDefaultSearchPolicy( |
522 ConfigurationPolicyType policy, | 519 ConfigurationPolicyType policy, |
523 Value* value) { | 520 Value* value) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 ConfigurationPolicyType policy, | 592 ConfigurationPolicyType policy, |
596 Value* value) { | 593 Value* value) { |
597 if (policy != kPolicyBookmarkBarEnabled) | 594 if (policy != kPolicyBookmarkBarEnabled) |
598 return false; | 595 return false; |
599 DCHECK_EQ(Value::TYPE_BOOLEAN, value->GetType()); | 596 DCHECK_EQ(Value::TYPE_BOOLEAN, value->GetType()); |
600 prefs_.SetValue(prefs::kEnableBookmarkBar, value); | 597 prefs_.SetValue(prefs::kEnableBookmarkBar, value); |
601 // kShowBookmarkBar is not managed directly by a policy, but when | 598 // kShowBookmarkBar is not managed directly by a policy, but when |
602 // kEnableBookmarkBar is managed, kShowBookmarkBar should be false so that | 599 // kEnableBookmarkBar is managed, kShowBookmarkBar should be false so that |
603 // the bookmarks bar either is completely disabled or only shows on the NTP. | 600 // the bookmarks bar either is completely disabled or only shows on the NTP. |
604 // This also disables the checkbox for this preference in the prefs UI. | 601 // This also disables the checkbox for this preference in the prefs UI. |
605 prefs_.SetValue(prefs::kShowBookmarkBar, Value::CreateBooleanValue(false)); | 602 prefs_.SetValue(prefs::kShowBookmarkBar, base::FalseValue()); |
606 return true; | 603 return true; |
607 } | 604 } |
608 | 605 |
609 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists( | 606 void ConfigurationPolicyPrefKeeper::EnsureStringPrefExists( |
610 const std::string& path) { | 607 const std::string& path) { |
611 std::string value; | 608 std::string value; |
612 if (!prefs_.GetString(path, &value)) | 609 if (!prefs_.GetString(path, &value)) |
613 prefs_.SetString(path, value); | 610 prefs_.SetString(path, value); |
614 } | 611 } |
615 | 612 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 // Update the initialization flag. | 1207 // Update the initialization flag. |
1211 if (!initialization_complete_ && | 1208 if (!initialization_complete_ && |
1212 provider_->IsInitializationComplete()) { | 1209 provider_->IsInitializationComplete()) { |
1213 initialization_complete_ = true; | 1210 initialization_complete_ = true; |
1214 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 1211 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
1215 OnInitializationCompleted(true)); | 1212 OnInitializationCompleted(true)); |
1216 } | 1213 } |
1217 } | 1214 } |
1218 | 1215 |
1219 } // namespace policy | 1216 } // namespace policy |
OLD | NEW |