Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: chrome/browser/policy/configuration_policy_pref_store.cc

Issue 7013046: Implemented a policy for centralized setting of the --disk-cache-dir flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Protected the policy from hitting ChromeOS. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 // Handles policies that affect Autofill. Returns true if the policy was 86 // Handles policies that affect Autofill. Returns true if the policy was
87 // handled and assumes ownership of |value| in that case. 87 // handled and assumes ownership of |value| in that case.
88 bool ApplyAutofillPolicy(ConfigurationPolicyType policy, Value* value); 88 bool ApplyAutofillPolicy(ConfigurationPolicyType policy, Value* value);
89 89
90 // Processes download directory policy. Returns true if the specified policy 90 // Processes download directory policy. Returns true if the specified policy
91 // is the download directory policy. ApplyDownloadDirPolicy assumes the 91 // is the download directory policy. ApplyDownloadDirPolicy assumes the
92 // ownership of |value| in the case that the policy is recognized. 92 // ownership of |value| in the case that the policy is recognized.
93 bool ApplyDownloadDirPolicy(ConfigurationPolicyType policy, Value* value); 93 bool ApplyDownloadDirPolicy(ConfigurationPolicyType policy, Value* value);
94 94
95 // Processes disk cache directory policy. Returns true if the specified policy
96 // is the right one. ApplyDiskCacheDirPolicy assumes the
97 // ownership of |value| in the case that the policy is recognized.
98 bool ApplyDiskCacheDirPolicy(ConfigurationPolicyType policy, Value* value);
99
95 // Processes file-selection dialogs policy. Returns true if the specified 100 // Processes file-selection dialogs policy. Returns true if the specified
96 // policy is the file-selection dialogs policy. 101 // policy is the file-selection dialogs policy.
97 // ApplyFileSelectionDialogsPolicy assumes the ownership of |value| in the 102 // ApplyFileSelectionDialogsPolicy assumes the ownership of |value| in the
98 // case that the policy is recognized. 103 // case that the policy is recognized.
99 bool ApplyFileSelectionDialogsPolicy(ConfigurationPolicyType policy, 104 bool ApplyFileSelectionDialogsPolicy(ConfigurationPolicyType policy,
100 Value* value); 105 Value* value);
101 106
102 // Make sure that the |path| if present in |prefs_|. If not, set it to 107 // Make sure that the |path| if present in |prefs_|. If not, set it to
103 // a blank string. 108 // a blank string.
104 void EnsureStringPrefExists(const std::string& path); 109 void EnsureStringPrefExists(const std::string& path);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 334
330 if (ApplySyncPolicy(policy, value)) 335 if (ApplySyncPolicy(policy, value))
331 return; 336 return;
332 337
333 if (ApplyAutofillPolicy(policy, value)) 338 if (ApplyAutofillPolicy(policy, value))
334 return; 339 return;
335 340
336 if (ApplyDownloadDirPolicy(policy, value)) 341 if (ApplyDownloadDirPolicy(policy, value))
337 return; 342 return;
338 343
344 if (ApplyDiskCacheDirPolicy(policy, value))
345 return;
346
339 if (ApplyFileSelectionDialogsPolicy(policy, value)) 347 if (ApplyFileSelectionDialogsPolicy(policy, value))
340 return; 348 return;
341 349
342 if (ApplyPolicyFromMap(policy, value, kDefaultSearchPolicyMap, 350 if (ApplyPolicyFromMap(policy, value, kDefaultSearchPolicyMap,
343 arraysize(kDefaultSearchPolicyMap))) 351 arraysize(kDefaultSearchPolicyMap)))
344 return; 352 return;
345 353
346 if (ApplyPolicyFromMap(policy, value, kSimplePolicyMap, 354 if (ApplyPolicyFromMap(policy, value, kSimplePolicyMap,
347 arraysize(kSimplePolicyMap))) 355 arraysize(kSimplePolicyMap)))
348 return; 356 return;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 Value::CreateStringValue(expanded_value)); 448 Value::CreateStringValue(expanded_value));
441 prefs_.SetValue(prefs::kPromptForDownload, 449 prefs_.SetValue(prefs::kPromptForDownload,
442 Value::CreateBooleanValue(false)); 450 Value::CreateBooleanValue(false));
443 delete value; 451 delete value;
444 return true; 452 return true;
445 } 453 }
446 // We are not interested in this policy. 454 // We are not interested in this policy.
447 return false; 455 return false;
448 } 456 }
449 457
458 bool ConfigurationPolicyPrefKeeper::ApplyDiskCacheDirPolicy(
459 ConfigurationPolicyType policy,
460 Value* value) {
461 // Replace the policy string which might contain some user variables to an
462 // expanded string.
463 if (policy == kPolicyDiskCacheDir) {
464 FilePath::StringType string_value;
465 bool result = value->GetAsString(&string_value);
466 DCHECK(result);
467 FilePath::StringType expanded_value =
468 policy::path_parser::ExpandPathVariables(string_value);
469 prefs_.SetValue(prefs::kDiskCacheDir,
470 Value::CreateStringValue(expanded_value));
471 delete value;
472 return true;
473 }
474 // We are not interested in this policy.
475 return false;
476 }
477
450 bool ConfigurationPolicyPrefKeeper::ApplyFileSelectionDialogsPolicy( 478 bool ConfigurationPolicyPrefKeeper::ApplyFileSelectionDialogsPolicy(
451 ConfigurationPolicyType policy, 479 ConfigurationPolicyType policy,
452 Value* value) { 480 Value* value) {
453 if (policy == kPolicyAllowFileSelectionDialogs) { 481 if (policy == kPolicyAllowFileSelectionDialogs) {
454 prefs_.SetValue(prefs::kAllowFileSelectionDialogs, value); 482 prefs_.SetValue(prefs::kAllowFileSelectionDialogs, value);
455 // If file-selection dialogs are not allowed we forbid the user to be 483 // If file-selection dialogs are not allowed we forbid the user to be
456 // prompted for the download location, since this would end up in an Infobar 484 // prompted for the download location, since this would end up in an Infobar
457 // explaining that file-selection dialogs are forbidden anyways. 485 // explaining that file-selection dialogs are forbidden anyways.
458 bool allow_file_selection_dialogs = true; 486 bool allow_file_selection_dialogs = true;
459 bool result = value->GetAsBoolean(&allow_file_selection_dialogs); 487 bool result = value->GetAsBoolean(&allow_file_selection_dialogs);
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 { kPolicyAllowOutdatedPlugins, Value::TYPE_BOOLEAN, 1032 { kPolicyAllowOutdatedPlugins, Value::TYPE_BOOLEAN,
1005 key::kAllowOutdatedPlugins }, 1033 key::kAllowOutdatedPlugins },
1006 { kPolicyAlwaysAuthorizePlugins, Value::TYPE_BOOLEAN, 1034 { kPolicyAlwaysAuthorizePlugins, Value::TYPE_BOOLEAN,
1007 key::kAlwaysAuthorizePlugins }, 1035 key::kAlwaysAuthorizePlugins },
1008 { kPolicyBookmarkBarEnabled, Value::TYPE_BOOLEAN, 1036 { kPolicyBookmarkBarEnabled, Value::TYPE_BOOLEAN,
1009 key::kBookmarkBarEnabled }, 1037 key::kBookmarkBarEnabled },
1010 { kPolicyEditBookmarksEnabled, Value::TYPE_BOOLEAN, 1038 { kPolicyEditBookmarksEnabled, Value::TYPE_BOOLEAN,
1011 key::kEditBookmarksEnabled }, 1039 key::kEditBookmarksEnabled },
1012 { kPolicyAllowFileSelectionDialogs, Value::TYPE_BOOLEAN, 1040 { kPolicyAllowFileSelectionDialogs, Value::TYPE_BOOLEAN,
1013 key::kAllowFileSelectionDialogs }, 1041 key::kAllowFileSelectionDialogs },
1042 { kPolicyDiskCacheDir, Value::TYPE_STRING,
1043 key::kDiskCacheDir },
1014 1044
1015 #if defined(OS_CHROMEOS) 1045 #if defined(OS_CHROMEOS)
1016 { kPolicyChromeOsLockOnIdleSuspend, Value::TYPE_BOOLEAN, 1046 { kPolicyChromeOsLockOnIdleSuspend, Value::TYPE_BOOLEAN,
1017 key::kChromeOsLockOnIdleSuspend }, 1047 key::kChromeOsLockOnIdleSuspend },
1018 #endif 1048 #endif
1019 }; 1049 };
1020 1050
1021 static ConfigurationPolicyProvider::PolicyDefinitionList policy_list = { 1051 static ConfigurationPolicyProvider::PolicyDefinitionList policy_list = {
1022 entries, 1052 entries,
1023 entries + arraysize(entries), 1053 entries + arraysize(entries),
(...skipping 23 matching lines...) Expand all
1047 // Update the initialization flag. 1077 // Update the initialization flag.
1048 if (!initialization_complete_ && 1078 if (!initialization_complete_ &&
1049 provider_->IsInitializationComplete()) { 1079 provider_->IsInitializationComplete()) {
1050 initialization_complete_ = true; 1080 initialization_complete_ = true;
1051 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 1081 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
1052 OnInitializationCompleted(true)); 1082 OnInitializationCompleted(true));
1053 } 1083 }
1054 } 1084 }
1055 1085
1056 } // namespace policy 1086 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698