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

Side by Side Diff: extensions/shell/browser/shell_prefs.cc

Issue 1662523004: Delete base/prefs and update callers to use components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/shell/browser/shell_prefs.h" 5 #include "extensions/shell/browser/shell_prefs.h"
6 6
7 #include "base/prefs/json_pref_store.h"
8 #include "base/prefs/pref_filter.h"
9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/prefs/pref_service_factory.h"
12 #include "build/build_config.h" 7 #include "build/build_config.h"
13 #include "components/pref_registry/pref_registry_syncable.h" 8 #include "components/pref_registry/pref_registry_syncable.h"
9 #include "components/prefs/json_pref_store.h"
10 #include "components/prefs/pref_filter.h"
11 #include "components/prefs/pref_registry_simple.h"
12 #include "components/prefs/pref_service.h"
13 #include "components/prefs/pref_service_factory.h"
14 #include "components/user_prefs/user_prefs.h" 14 #include "components/user_prefs/user_prefs.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "extensions/browser/extension_prefs.h" 17 #include "extensions/browser/extension_prefs.h"
18 18
19 #if defined(OS_CHROMEOS) 19 #if defined(OS_CHROMEOS)
20 #include "chromeos/audio/audio_devices_pref_handler_impl.h" 20 #include "chromeos/audio/audio_devices_pref_handler_impl.h"
21 #endif 21 #endif
22 22
23 using base::FilePath; 23 using base::FilePath;
(...skipping 22 matching lines...) Expand all
46 46
47 } // namespace 47 } // namespace
48 48
49 namespace shell_prefs { 49 namespace shell_prefs {
50 50
51 scoped_ptr<PrefService> CreateLocalState(const FilePath& data_dir) { 51 scoped_ptr<PrefService> CreateLocalState(const FilePath& data_dir) {
52 FilePath filepath = data_dir.AppendASCII("local_state.json"); 52 FilePath filepath = data_dir.AppendASCII("local_state.json");
53 scoped_refptr<JsonPrefStore> pref_store = CreateAndLoadPrefStore(filepath); 53 scoped_refptr<JsonPrefStore> pref_store = CreateAndLoadPrefStore(filepath);
54 54
55 // Local state is considered "user prefs" from the factory's perspective. 55 // Local state is considered "user prefs" from the factory's perspective.
56 base::PrefServiceFactory factory; 56 PrefServiceFactory factory;
57 factory.set_user_prefs(pref_store); 57 factory.set_user_prefs(pref_store);
58 58
59 // Local state preferences are not syncable. 59 // Local state preferences are not syncable.
60 PrefRegistrySimple* registry = new PrefRegistrySimple; 60 PrefRegistrySimple* registry = new PrefRegistrySimple;
61 RegisterLocalStatePrefs(registry); 61 RegisterLocalStatePrefs(registry);
62 62
63 return factory.Create(registry); 63 return factory.Create(registry);
64 } 64 }
65 65
66 scoped_ptr<PrefService> CreateUserPrefService( 66 scoped_ptr<PrefService> CreateUserPrefService(
67 content::BrowserContext* browser_context) { 67 content::BrowserContext* browser_context) {
68 FilePath filepath = browser_context->GetPath().AppendASCII("user_prefs.json"); 68 FilePath filepath = browser_context->GetPath().AppendASCII("user_prefs.json");
69 scoped_refptr<JsonPrefStore> pref_store = CreateAndLoadPrefStore(filepath); 69 scoped_refptr<JsonPrefStore> pref_store = CreateAndLoadPrefStore(filepath);
70 70
71 base::PrefServiceFactory factory; 71 PrefServiceFactory factory;
72 factory.set_user_prefs(pref_store); 72 factory.set_user_prefs(pref_store);
73 73
74 // TODO(jamescook): If we want to support prefs that are set by extensions 74 // TODO(jamescook): If we want to support prefs that are set by extensions
75 // via ChromeSettings properties (e.g. chrome.accessibilityFeatures or 75 // via ChromeSettings properties (e.g. chrome.accessibilityFeatures or
76 // chrome.proxy) then this should create an ExtensionPrefStore and attach it 76 // chrome.proxy) then this should create an ExtensionPrefStore and attach it
77 // with PrefServiceFactory::set_extension_prefs(). 77 // with PrefServiceFactory::set_extension_prefs().
78 // See https://developer.chrome.com/extensions/types#ChromeSetting 78 // See https://developer.chrome.com/extensions/types#ChromeSetting
79 79
80 // Prefs should be registered before the PrefService is created. 80 // Prefs should be registered before the PrefService is created.
81 PrefRegistrySyncable* pref_registry = new PrefRegistrySyncable; 81 PrefRegistrySyncable* pref_registry = new PrefRegistrySyncable;
82 ExtensionPrefs::RegisterProfilePrefs(pref_registry); 82 ExtensionPrefs::RegisterProfilePrefs(pref_registry);
83 83
84 scoped_ptr<PrefService> pref_service = factory.Create(pref_registry); 84 scoped_ptr<PrefService> pref_service = factory.Create(pref_registry);
85 user_prefs::UserPrefs::Set(browser_context, pref_service.get()); 85 user_prefs::UserPrefs::Set(browser_context, pref_service.get());
86 return pref_service; 86 return pref_service;
87 } 87 }
88 88
89 } // namespace shell_prefs 89 } // namespace shell_prefs
90 90
91 } // namespace extensions 91 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/shell/browser/shell_browser_main_parts.cc ('k') | extensions/shell/browser/shell_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698