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

Side by Side Diff: chrome/browser/prefs/pref_service.cc

Issue 6074003: Handle policy refresh internally in ConfigurationPolicyPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 9 years, 12 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/prefs/pref_service.h" 5 #include "chrome/browser/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/stl_util-inl.h" 17 #include "base/stl_util-inl.h"
18 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/sys_string_conversions.h" 20 #include "base/sys_string_conversions.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "chrome/browser/browser_thread.h" 23 #include "chrome/browser/browser_thread.h"
24 #include "chrome/browser/policy/configuration_policy_pref_store.h" 24 #include "chrome/browser/policy/configuration_policy_pref_store.h"
25 #include "chrome/browser/prefs/command_line_pref_store.h" 25 #include "chrome/browser/prefs/command_line_pref_store.h"
26 #include "chrome/browser/prefs/default_pref_store.h" 26 #include "chrome/browser/prefs/default_pref_store.h"
27 #include "chrome/browser/prefs/pref_notifier_impl.h" 27 #include "chrome/browser/prefs/pref_notifier_impl.h"
28 #include "chrome/browser/prefs/pref_value_store.h" 28 #include "chrome/browser/prefs/pref_value_store.h"
29 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/common/json_pref_store.h" 29 #include "chrome/common/json_pref_store.h"
31 #include "chrome/common/notification_service.h" 30 #include "chrome/common/notification_service.h"
32 #include "grit/chromium_strings.h" 31 #include "grit/chromium_strings.h"
33 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
34 33
35 namespace { 34 namespace {
36 35
37 // A helper function for RegisterLocalized*Pref that creates a Value* based on 36 // A helper function for RegisterLocalized*Pref that creates a Value* based on
38 // the string value in the locale dll. Because we control the values in a 37 // the string value in the locale dll. Because we control the values in a
39 // locale dll, this should always return a Value of the appropriate type. 38 // locale dll, this should always return a Value of the appropriate type.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 profile); 109 profile);
111 CommandLinePrefStore* command_line = 110 CommandLinePrefStore* command_line =
112 new CommandLinePrefStore(CommandLine::ForCurrentProcess()); 111 new CommandLinePrefStore(CommandLine::ForCurrentProcess());
113 JsonPrefStore* user = new JsonPrefStore( 112 JsonPrefStore* user = new JsonPrefStore(
114 pref_filename, 113 pref_filename,
115 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); 114 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
116 ConfigurationPolicyPrefStore* recommended = 115 ConfigurationPolicyPrefStore* recommended =
117 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore(); 116 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore();
118 117
119 return new PrefService(managed, device_management, extension_prefs, 118 return new PrefService(managed, device_management, extension_prefs,
120 command_line, user, recommended, profile); 119 command_line, user, recommended);
121 } 120 }
122 121
123 PrefService::PrefService(PrefStore* managed_platform_prefs, 122 PrefService::PrefService(PrefStore* managed_platform_prefs,
124 PrefStore* device_management_prefs, 123 PrefStore* device_management_prefs,
125 PrefStore* extension_prefs, 124 PrefStore* extension_prefs,
126 PrefStore* command_line_prefs, 125 PrefStore* command_line_prefs,
127 PersistentPrefStore* user_prefs, 126 PersistentPrefStore* user_prefs,
128 PrefStore* recommended_prefs, 127 PrefStore* recommended_prefs)
129 Profile* profile)
130 : user_pref_store_(user_prefs) { 128 : user_pref_store_(user_prefs) {
131 pref_notifier_.reset(new PrefNotifierImpl(this)); 129 pref_notifier_.reset(new PrefNotifierImpl(this));
132 default_store_ = new DefaultPrefStore(); 130 default_store_ = new DefaultPrefStore();
133 pref_value_store_ = 131 pref_value_store_ =
134 new PrefValueStore(managed_platform_prefs, 132 new PrefValueStore(managed_platform_prefs,
135 device_management_prefs, 133 device_management_prefs,
136 extension_prefs, 134 extension_prefs,
137 command_line_prefs, 135 command_line_prefs,
138 user_pref_store_, 136 user_pref_store_,
139 recommended_prefs, 137 recommended_prefs,
140 default_store_, 138 default_store_,
141 pref_notifier_.get(), 139 pref_notifier_.get());
142 profile);
143 InitFromStorage(); 140 InitFromStorage();
144 } 141 }
145 142
146 PrefService::~PrefService() { 143 PrefService::~PrefService() {
147 DCHECK(CalledOnValidThread()); 144 DCHECK(CalledOnValidThread());
148 STLDeleteContainerPointers(prefs_.begin(), prefs_.end()); 145 STLDeleteContainerPointers(prefs_.begin(), prefs_.end());
149 prefs_.clear(); 146 prefs_.clear();
150 } 147 }
151 148
152 void PrefService::InitFromStorage() { 149 void PrefService::InitFromStorage() {
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 639
643 bool PrefService::Preference::IsDefaultValue() const { 640 bool PrefService::Preference::IsDefaultValue() const {
644 return pref_service_->pref_value_store_-> 641 return pref_service_->pref_value_store_->
645 PrefValueFromDefaultStore(name_.c_str()); 642 PrefValueFromDefaultStore(name_.c_str());
646 } 643 }
647 644
648 bool PrefService::Preference::IsUserModifiable() const { 645 bool PrefService::Preference::IsUserModifiable() const {
649 return pref_service_->pref_value_store_-> 646 return pref_service_->pref_value_store_->
650 PrefValueUserModifiable(name_.c_str()); 647 PrefValueUserModifiable(name_.c_str());
651 } 648 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698