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

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: Gab's feedback. 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/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/json/json_file_value_serializer.h" 11 #include "base/json/json_file_value_serializer.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/prefs/default_pref_store.h" 14 #include "base/prefs/default_pref_store.h"
15 #include "base/prefs/json_pref_store.h" 15 #include "base/prefs/json_pref_store.h"
16 #include "base/prefs/pref_filter.h" 16 #include "base/prefs/pref_filter.h"
17 #include "base/prefs/pref_notifier_impl.h" 17 #include "base/prefs/pref_notifier_impl.h"
18 #include "base/prefs/pref_registry.h" 18 #include "base/prefs/pref_registry.h"
19 #include "base/prefs/pref_registry_simple.h"
19 #include "base/prefs/pref_service.h" 20 #include "base/prefs/pref_service.h"
20 #include "base/prefs/pref_store.h" 21 #include "base/prefs/pref_store.h"
21 #include "base/prefs/pref_value_store.h" 22 #include "base/prefs/pref_value_store.h"
22 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/prefs/command_line_pref_store.h" 26 #include "chrome/browser/prefs/command_line_pref_store.h"
26 #include "chrome/browser/prefs/pref_hash_filter.h" 27 #include "chrome/browser/prefs/pref_hash_filter.h"
28 #include "chrome/browser/prefs/pref_hash_store.h"
27 #include "chrome/browser/prefs/pref_hash_store_impl.h" 29 #include "chrome/browser/prefs/pref_hash_store_impl.h"
28 #include "chrome/browser/prefs/pref_model_associator.h" 30 #include "chrome/browser/prefs/pref_model_associator.h"
29 #include "chrome/browser/prefs/pref_service_syncable.h" 31 #include "chrome/browser/prefs/pref_service_syncable.h"
30 #include "chrome/browser/prefs/pref_service_syncable_factory.h" 32 #include "chrome/browser/prefs/pref_service_syncable_factory.h"
31 #include "chrome/browser/profiles/file_path_verifier_win.h" 33 #include "chrome/browser/profiles/file_path_verifier_win.h"
32 #include "chrome/browser/ui/profile_error_dialog.h" 34 #include "chrome/browser/ui/profile_error_dialog.h"
33 #include "chrome/common/chrome_constants.h" 35 #include "chrome/common/chrome_constants.h"
34 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
35 #include "components/user_prefs/pref_registry_syncable.h" 37 #include "components/user_prefs/pref_registry_syncable.h"
36 #include "content/public/browser/browser_context.h" 38 #include "content/public/browser/browser_context.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 #endif 237 #endif
236 238
237 return make_scoped_ptr(new PrefHashStoreImpl( 239 return make_scoped_ptr(new PrefHashStoreImpl(
238 profile_path.AsUTF8Unsafe(), 240 profile_path.AsUTF8Unsafe(),
239 seed, 241 seed,
240 device_id, 242 device_id,
241 g_browser_process->local_state())); 243 g_browser_process->local_state()));
242 #endif 244 #endif
243 } 245 }
244 246
247 void HandleResetEvent() {
248 g_browser_process->local_state()->SetInt64(
249 prefs::kProfilePreferenceResetTime,
250 base::Time::Now().ToInternalValue());
251 }
252
245 scoped_ptr<PrefHashFilter> CreatePrefHashFilter( 253 scoped_ptr<PrefHashFilter> CreatePrefHashFilter(
246 scoped_ptr<PrefHashStore> pref_hash_store) { 254 scoped_ptr<PrefHashStore> pref_hash_store) {
247 return make_scoped_ptr(new PrefHashFilter(pref_hash_store.Pass(), 255 return make_scoped_ptr(new PrefHashFilter(pref_hash_store.Pass(),
248 kTrackedPrefs, 256 kTrackedPrefs,
249 arraysize(kTrackedPrefs), 257 arraysize(kTrackedPrefs),
250 kTrackedPrefsReportingIDsCount, 258 kTrackedPrefsReportingIDsCount,
251 GetSettingsEnforcementLevel())); 259 GetSettingsEnforcementLevel(),
260 base::Bind(&HandleResetEvent)));
252 } 261 }
253 262
254 void PrepareBuilder( 263 void PrepareBuilder(
255 PrefServiceSyncableFactory* factory, 264 PrefServiceSyncableFactory* factory,
256 const base::FilePath& pref_filename, 265 const base::FilePath& pref_filename,
257 base::SequencedTaskRunner* pref_io_task_runner, 266 base::SequencedTaskRunner* pref_io_task_runner,
258 policy::PolicyService* policy_service, 267 policy::PolicyService* policy_service,
259 ManagedUserSettingsService* managed_user_settings, 268 ManagedUserSettingsService* managed_user_settings,
260 scoped_ptr<PrefHashStore> pref_hash_store, 269 scoped_ptr<PrefHashStore> pref_hash_store,
261 const scoped_refptr<PrefStore>& extension_prefs, 270 const scoped_refptr<PrefStore>& extension_prefs,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 new InitializeHashStoreObserver( 414 new InitializeHashStoreObserver(
406 pref_store, pref_hash_store.PassAs<PrefHashStore>())); 415 pref_store, pref_hash_store.PassAs<PrefHashStore>()));
407 pref_store->ReadPrefsAsync(NULL); 416 pref_store->ReadPrefsAsync(NULL);
408 } 417 }
409 } 418 }
410 419
411 void ResetPrefHashStore(const base::FilePath& profile_path) { 420 void ResetPrefHashStore(const base::FilePath& profile_path) {
412 GetPrefHashStoreImpl(profile_path)->Reset(); 421 GetPrefHashStoreImpl(profile_path)->Reset();
413 } 422 }
414 423
424 void RegisterPrefs(PrefRegistrySimple* registry) {
425 // Register the pref that maintains state about the last time a PrefHashFilter
426 // reset event occurred. Used to decide whether to show UI.
gab 2014/02/07 22:00:19 I don't think a comment about what the pref does i
robertshield 2014/02/10 02:30:53 Done.
427 registry->RegisterInt64Pref(prefs::kProfilePreferenceResetTime, 0L);
428
429 PrefHashStoreImpl::RegisterPrefs(registry);
430 }
431
415 } // namespace chrome_prefs 432 } // namespace chrome_prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698