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

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

Issue 7941008: Cosmetic cleanups in chrome/browser/policy/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload was broken? Created 9 years, 3 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>
9 #include <string> 8 #include <string>
10 #include <vector> 9 #include <vector>
11 10
12 #include "base/command_line.h"
13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 11 #include "base/logging.h"
15 #include "base/stl_util.h" 12 #include "base/stl_util.h"
16 #include "base/string16.h" 13 #include "base/string16.h"
17 #include "base/string_util.h" 14 #include "base/string_util.h"
18 #include "base/utf_string_conversions.h"
19 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/download/download_util.h" 16 #include "chrome/browser/download/download_util.h"
22 #include "chrome/browser/policy/browser_policy_connector.h" 17 #include "chrome/browser/policy/browser_policy_connector.h"
23 #include "chrome/browser/policy/configuration_policy_provider.h" 18 #include "chrome/browser/policy/policy_map.h"
24 #include "chrome/browser/policy/policy_path_parser.h" 19 #include "chrome/browser/policy/policy_path_parser.h"
25 #include "chrome/browser/prefs/incognito_mode_prefs.h" 20 #include "chrome/browser/prefs/incognito_mode_prefs.h"
26 #include "chrome/browser/prefs/pref_value_map.h" 21 #include "chrome/browser/prefs/pref_value_map.h"
27 #include "chrome/browser/prefs/proxy_config_dictionary.h" 22 #include "chrome/browser/prefs/proxy_config_dictionary.h"
28 #include "chrome/browser/search_engines/search_terms_data.h" 23 #include "chrome/browser/search_engines/search_terms_data.h"
29 #include "chrome/browser/search_engines/template_url.h" 24 #include "chrome/browser/search_engines/template_url.h"
30 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
31 #include "content/common/notification_service.h"
32 #include "policy/policy_constants.h" 26 #include "policy/policy_constants.h"
33 27
34 namespace policy { 28 namespace policy {
35 29
36 // Accepts policy settings from a ConfigurationPolicyProvider, converts them 30 // Accepts policy settings from a ConfigurationPolicyProvider, converts them
37 // to preferences and caches the result. 31 // to preferences and caches the result.
38 class ConfigurationPolicyPrefKeeper { 32 class ConfigurationPolicyPrefKeeper {
39 public: 33 public:
40 explicit ConfigurationPolicyPrefKeeper(ConfigurationPolicyProvider* provider); 34 explicit ConfigurationPolicyPrefKeeper(ConfigurationPolicyProvider* provider);
41 virtual ~ConfigurationPolicyPrefKeeper(); 35 virtual ~ConfigurationPolicyPrefKeeper();
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 PolicyMap::const_iterator current = policies->begin(); 385 PolicyMap::const_iterator current = policies->begin();
392 for ( ; current != policies->end(); ++current) { 386 for ( ; current != policies->end(); ++current) {
393 // TODO(simo) Use a separate ConfigurationPolicyHandler class to apply 387 // TODO(simo) Use a separate ConfigurationPolicyHandler class to apply
394 // policy settings. 388 // policy settings.
395 Value* value = current->second->DeepCopy(); 389 Value* value = current->second->DeepCopy();
396 if (ApplyProxyPolicy(current->first, value) || 390 if (ApplyProxyPolicy(current->first, value) ||
397 ApplySyncPolicy(current->first, value) || 391 ApplySyncPolicy(current->first, value) ||
398 ApplyAutofillPolicy(current->first, value) || 392 ApplyAutofillPolicy(current->first, value) ||
399 ApplyDownloadDirPolicy(current->first, value) || 393 ApplyDownloadDirPolicy(current->first, value) ||
400 ApplyDiskCacheDirPolicy(current->first, value) || 394 ApplyDiskCacheDirPolicy(current->first, value) ||
401 ApplyFileSelectionDialogsPolicy(current->first, 395 ApplyFileSelectionDialogsPolicy(current->first, value) ||
402 value) ||
403 ApplyDefaultSearchPolicy(current->first, value) || 396 ApplyDefaultSearchPolicy(current->first, value) ||
404 ApplyIncognitoModePolicy(current->first, value) || 397 ApplyIncognitoModePolicy(current->first, value) ||
405 ApplyBookmarksPolicy(current->first, value) || 398 ApplyBookmarksPolicy(current->first, value) ||
406 ApplyPolicyFromMap(current->first, value, 399 ApplyPolicyFromMap(current->first, value,
407 kSimplePolicyMap, arraysize(kSimplePolicyMap))) { 400 kSimplePolicyMap, arraysize(kSimplePolicyMap))) {
408 continue; 401 continue;
409 } 402 }
410 delete value; 403 delete value;
411 404
412 // Other policy implementations should go into the conditional above. 405 // Other policy implementations should go into the conditional above.
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 1240
1248 void ConfigurationPolicyPrefStore::Refresh() { 1241 void ConfigurationPolicyPrefStore::Refresh() {
1249 if (!provider_) 1242 if (!provider_)
1250 return; 1243 return;
1251 1244
1252 // Construct a new keeper, determine what changed and swap the keeper in. 1245 // Construct a new keeper, determine what changed and swap the keeper in.
1253 scoped_ptr<ConfigurationPolicyPrefKeeper> new_keeper( 1246 scoped_ptr<ConfigurationPolicyPrefKeeper> new_keeper(
1254 new ConfigurationPolicyPrefKeeper(provider_)); 1247 new ConfigurationPolicyPrefKeeper(provider_));
1255 std::vector<std::string> changed_prefs; 1248 std::vector<std::string> changed_prefs;
1256 new_keeper->GetDifferingPrefPaths(policy_keeper_.get(), &changed_prefs); 1249 new_keeper->GetDifferingPrefPaths(policy_keeper_.get(), &changed_prefs);
1257 policy_keeper_.reset(new_keeper.release()); 1250 policy_keeper_.swap(new_keeper);
1258 1251
1259 // Send out change notifications. 1252 // Send out change notifications.
1260 for (std::vector<std::string>::const_iterator pref(changed_prefs.begin()); 1253 for (std::vector<std::string>::const_iterator pref(changed_prefs.begin());
1261 pref != changed_prefs.end(); 1254 pref != changed_prefs.end();
1262 ++pref) { 1255 ++pref) {
1263 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 1256 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
1264 OnPrefValueChanged(*pref)); 1257 OnPrefValueChanged(*pref));
1265 } 1258 }
1266 1259
1267 // Update the initialization flag. 1260 // Update the initialization flag.
1268 if (!initialization_complete_ && 1261 if (!initialization_complete_ &&
1269 provider_->IsInitializationComplete()) { 1262 provider_->IsInitializationComplete()) {
1270 initialization_complete_ = true; 1263 initialization_complete_ = true;
1271 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 1264 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
1272 OnInitializationCompleted(true)); 1265 OnInitializationCompleted(true));
1273 } 1266 }
1274 } 1267 }
1275 1268
1276 } // namespace policy 1269 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/configuration_policy_pref_store.h ('k') | chrome/browser/policy/configuration_policy_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698