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

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

Issue 151003004: Add an automatic settings reset banner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on top of transaction patch. Created 6 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_pref_service_factory.h" 5 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/json/json_file_value_serializer.h" 12 #include "base/json/json_file_value_serializer.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/prefs/default_pref_store.h" 15 #include "base/prefs/default_pref_store.h"
16 #include "base/prefs/json_pref_store.h" 16 #include "base/prefs/json_pref_store.h"
17 #include "base/prefs/pref_filter.h" 17 #include "base/prefs/pref_filter.h"
18 #include "base/prefs/pref_notifier_impl.h" 18 #include "base/prefs/pref_notifier_impl.h"
19 #include "base/prefs/pref_registry.h" 19 #include "base/prefs/pref_registry.h"
20 #include "base/prefs/pref_registry_simple.h"
20 #include "base/prefs/pref_service.h" 21 #include "base/prefs/pref_service.h"
21 #include "base/prefs/pref_store.h" 22 #include "base/prefs/pref_store.h"
22 #include "base/prefs/pref_value_store.h" 23 #include "base/prefs/pref_value_store.h"
23 #include "base/threading/sequenced_worker_pool.h" 24 #include "base/threading/sequenced_worker_pool.h"
24 #include "base/time/time.h" 25 #include "base/time/time.h"
25 #include "base/values.h" 26 #include "base/values.h"
26 #include "chrome/browser/browser_process.h" 27 #include "chrome/browser/browser_process.h"
27 #include "chrome/browser/prefs/command_line_pref_store.h" 28 #include "chrome/browser/prefs/command_line_pref_store.h"
28 #include "chrome/browser/prefs/pref_hash_filter.h" 29 #include "chrome/browser/prefs/pref_hash_filter.h"
30 #include "chrome/browser/prefs/pref_hash_store.h"
29 #include "chrome/browser/prefs/pref_hash_store_impl.h" 31 #include "chrome/browser/prefs/pref_hash_store_impl.h"
30 #include "chrome/browser/prefs/pref_model_associator.h" 32 #include "chrome/browser/prefs/pref_model_associator.h"
31 #include "chrome/browser/prefs/pref_service_syncable.h" 33 #include "chrome/browser/prefs/pref_service_syncable.h"
32 #include "chrome/browser/prefs/pref_service_syncable_factory.h" 34 #include "chrome/browser/prefs/pref_service_syncable_factory.h"
33 #include "chrome/browser/profiles/file_path_verifier_win.h" 35 #include "chrome/browser/profiles/file_path_verifier_win.h"
34 #include "chrome/browser/ui/profile_error_dialog.h" 36 #include "chrome/browser/ui/profile_error_dialog.h"
35 #include "chrome/common/chrome_constants.h" 37 #include "chrome/common/chrome_constants.h"
36 #include "chrome/common/pref_names.h" 38 #include "chrome/common/pref_names.h"
37 #include "components/user_prefs/pref_registry_syncable.h" 39 #include "components/user_prefs/pref_registry_syncable.h"
38 #include "content/public/browser/browser_context.h" 40 #include "content/public/browser/browser_context.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 #endif 259 #endif
258 260
259 return make_scoped_ptr(new PrefHashStoreImpl( 261 return make_scoped_ptr(new PrefHashStoreImpl(
260 profile_path.AsUTF8Unsafe(), 262 profile_path.AsUTF8Unsafe(),
261 seed, 263 seed,
262 device_id, 264 device_id,
263 g_browser_process->local_state())); 265 g_browser_process->local_state()));
264 #endif 266 #endif
265 } 267 }
266 268
269 void HandleResetEvent() {
270 g_browser_process->local_state()->SetInt64(
271 prefs::kProfilePreferenceResetTime,
272 base::Time::Now().ToInternalValue());
273 }
274
267 scoped_ptr<PrefHashFilter> CreatePrefHashFilter( 275 scoped_ptr<PrefHashFilter> CreatePrefHashFilter(
268 scoped_ptr<PrefHashStore> pref_hash_store) { 276 scoped_ptr<PrefHashStore> pref_hash_store) {
269 return make_scoped_ptr(new PrefHashFilter(pref_hash_store.Pass(), 277 return make_scoped_ptr(new PrefHashFilter(pref_hash_store.Pass(),
270 kTrackedPrefs, 278 kTrackedPrefs,
271 arraysize(kTrackedPrefs), 279 arraysize(kTrackedPrefs),
272 kTrackedPrefsReportingIDsCount, 280 kTrackedPrefsReportingIDsCount,
273 GetSettingsEnforcementLevel())); 281 GetSettingsEnforcementLevel(),
282 base::Bind(&HandleResetEvent)));
274 } 283 }
275 284
276 void PrepareBuilder( 285 void PrepareBuilder(
277 PrefServiceSyncableFactory* factory, 286 PrefServiceSyncableFactory* factory,
278 const base::FilePath& pref_filename, 287 const base::FilePath& pref_filename,
279 base::SequencedTaskRunner* pref_io_task_runner, 288 base::SequencedTaskRunner* pref_io_task_runner,
280 policy::PolicyService* policy_service, 289 policy::PolicyService* policy_service,
281 ManagedUserSettingsService* managed_user_settings, 290 ManagedUserSettingsService* managed_user_settings,
282 scoped_ptr<PrefHashStore> pref_hash_store, 291 scoped_ptr<PrefHashStore> pref_hash_store,
283 const scoped_refptr<PrefStore>& extension_prefs, 292 const scoped_refptr<PrefStore>& extension_prefs,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 new DictionaryPrefStore(&master_prefs)); 495 new DictionaryPrefStore(&master_prefs));
487 CreatePrefHashFilter( 496 CreatePrefHashFilter(
488 GetPrefHashStoreImpl(profile_path).PassAs<PrefHashStore>())-> 497 GetPrefHashStoreImpl(profile_path).PassAs<PrefHashStore>())->
489 Initialize(*pref_store); 498 Initialize(*pref_store);
490 } 499 }
491 500
492 UMA_HISTOGRAM_BOOLEAN("Settings.InitializedFromMasterPrefs", success); 501 UMA_HISTOGRAM_BOOLEAN("Settings.InitializedFromMasterPrefs", success);
493 return success; 502 return success;
494 } 503 }
495 504
505 void RegisterPrefs(PrefRegistrySimple* registry) {
506 registry->RegisterInt64Pref(prefs::kProfilePreferenceResetTime, 0L);
507 PrefHashStoreImpl::RegisterPrefs(registry);
508 }
509
496 } // namespace chrome_prefs 510 } // namespace chrome_prefs
OLDNEW
« no previous file with comments | « chrome/browser/prefs/chrome_pref_service_factory.h ('k') | chrome/browser/prefs/pref_hash_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698