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

Side by Side Diff: chrome/browser/extensions/extension_prefs.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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/extensions/extension_prefs.h" 5 #include "chrome/browser/extensions/extension_prefs.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_notifier.h" 8 #include "base/prefs/pref_notifier.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 base::Time ExtensionPrefs::TimeProvider::GetCurrentTime() const { 364 base::Time ExtensionPrefs::TimeProvider::GetCurrentTime() const {
365 return base::Time::Now(); 365 return base::Time::Now();
366 } 366 }
367 367
368 // 368 //
369 // ExtensionPrefs 369 // ExtensionPrefs
370 // 370 //
371 371
372 // static 372 // static
373 scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create( 373 scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create(
374 PrefService* prefs, 374 PrefServiceSyncable* prefs,
375 const FilePath& root_dir, 375 const FilePath& root_dir,
376 ExtensionPrefValueMap* extension_pref_value_map, 376 ExtensionPrefValueMap* extension_pref_value_map,
377 bool extensions_disabled) { 377 bool extensions_disabled) {
378 return ExtensionPrefs::Create(prefs, 378 return ExtensionPrefs::Create(prefs,
379 root_dir, 379 root_dir,
380 extension_pref_value_map, 380 extension_pref_value_map,
381 extensions_disabled, 381 extensions_disabled,
382 make_scoped_ptr(new TimeProvider())); 382 make_scoped_ptr(new TimeProvider()));
383 } 383 }
384 384
385 // static 385 // static
386 scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create( 386 scoped_ptr<ExtensionPrefs> ExtensionPrefs::Create(
387 PrefService* pref_service, 387 PrefServiceSyncable* pref_service,
388 const FilePath& root_dir, 388 const FilePath& root_dir,
389 ExtensionPrefValueMap* extension_pref_value_map, 389 ExtensionPrefValueMap* extension_pref_value_map,
390 bool extensions_disabled, 390 bool extensions_disabled,
391 scoped_ptr<TimeProvider> time_provider) { 391 scoped_ptr<TimeProvider> time_provider) {
392 scoped_ptr<ExtensionPrefs> prefs( 392 scoped_ptr<ExtensionPrefs> prefs(
393 new ExtensionPrefs(pref_service, 393 new ExtensionPrefs(pref_service,
394 root_dir, 394 root_dir,
395 extension_pref_value_map, 395 extension_pref_value_map,
396 time_provider.Pass())); 396 time_provider.Pass()));
397 prefs->Init(extensions_disabled); 397 prefs->Init(extensions_disabled);
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 return ext; 2198 return ext;
2199 } 2199 }
2200 2200
2201 void ExtensionPrefs::SetGeometryCache( 2201 void ExtensionPrefs::SetGeometryCache(
2202 const std::string& extension_id, 2202 const std::string& extension_id,
2203 scoped_ptr<base::DictionaryValue> cache) { 2203 scoped_ptr<base::DictionaryValue> cache) {
2204 UpdateExtensionPref(extension_id, kPrefGeometryCache, cache.release()); 2204 UpdateExtensionPref(extension_id, kPrefGeometryCache, cache.release());
2205 } 2205 }
2206 2206
2207 ExtensionPrefs::ExtensionPrefs( 2207 ExtensionPrefs::ExtensionPrefs(
2208 PrefService* prefs, 2208 PrefServiceSyncable* prefs,
2209 const FilePath& root_dir, 2209 const FilePath& root_dir,
2210 ExtensionPrefValueMap* extension_pref_value_map, 2210 ExtensionPrefValueMap* extension_pref_value_map,
2211 scoped_ptr<TimeProvider> time_provider) 2211 scoped_ptr<TimeProvider> time_provider)
2212 : prefs_(prefs), 2212 : prefs_(prefs),
2213 install_directory_(root_dir), 2213 install_directory_(root_dir),
2214 extension_pref_value_map_(extension_pref_value_map), 2214 extension_pref_value_map_(extension_pref_value_map),
2215 ALLOW_THIS_IN_INITIALIZER_LIST(extension_sorting_( 2215 ALLOW_THIS_IN_INITIALIZER_LIST(extension_sorting_(
2216 new ExtensionSorting(this, prefs))), 2216 new ExtensionSorting(this, prefs))),
2217 content_settings_store_(new ContentSettingsStore()), 2217 content_settings_store_(new ContentSettingsStore()),
2218 time_provider_(time_provider.Pass()) { 2218 time_provider_(time_provider.Pass()) {
2219 } 2219 }
2220 2220
2221 void ExtensionPrefs::Init(bool extensions_disabled) { 2221 void ExtensionPrefs::Init(bool extensions_disabled) {
2222 MakePathsRelative(); 2222 MakePathsRelative();
2223 2223
2224 InitPrefStore(extensions_disabled); 2224 InitPrefStore(extensions_disabled);
2225 2225
2226 content_settings_store_->AddObserver(this); 2226 content_settings_store_->AddObserver(this);
2227 } 2227 }
2228 2228
2229 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) { 2229 void ExtensionPrefs::SetNeedsStorageGarbageCollection(bool value) {
2230 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value); 2230 prefs_->SetBoolean(prefs::kExtensionStorageGarbageCollect, value);
2231 } 2231 }
2232 2232
2233 bool ExtensionPrefs::NeedsStorageGarbageCollection() { 2233 bool ExtensionPrefs::NeedsStorageGarbageCollection() {
2234 return prefs_->GetBoolean(prefs::kExtensionStorageGarbageCollect); 2234 return prefs_->GetBoolean(prefs::kExtensionStorageGarbageCollect);
2235 } 2235 }
2236 2236
2237 // static 2237 // static
2238 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { 2238 void ExtensionPrefs::RegisterUserPrefs(PrefServiceSyncable* prefs) {
2239 prefs->RegisterDictionaryPref(kExtensionsPref, PrefService::UNSYNCABLE_PREF); 2239 prefs->RegisterDictionaryPref(kExtensionsPref,
2240 prefs->RegisterListPref(kExtensionToolbar, PrefService::UNSYNCABLE_PREF); 2240 PrefServiceSyncable::UNSYNCABLE_PREF);
2241 prefs->RegisterListPref(kExtensionActionBox, PrefService::UNSYNCABLE_PREF); 2241 prefs->RegisterListPref(kExtensionToolbar,
2242 prefs->RegisterListPref(kExtensionActionBoxBar, PrefService::UNSYNCABLE_PREF); 2242 PrefServiceSyncable::UNSYNCABLE_PREF);
2243 prefs->RegisterListPref(kExtensionActionBox,
2244 PrefServiceSyncable::UNSYNCABLE_PREF);
2245 prefs->RegisterListPref(kExtensionActionBoxBar,
2246 PrefServiceSyncable::UNSYNCABLE_PREF);
2243 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, 2247 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize,
2244 -1, // default value 2248 -1, // default value
2245 PrefService::UNSYNCABLE_PREF); 2249 PrefServiceSyncable::UNSYNCABLE_PREF);
2246 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate, 2250 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate,
2247 PrefService::UNSYNCABLE_PREF); 2251 PrefServiceSyncable::UNSYNCABLE_PREF);
2248 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, 2252 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
2249 PrefService::UNSYNCABLE_PREF); 2253 PrefServiceSyncable::UNSYNCABLE_PREF);
2250 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 2254 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
2251 PrefService::UNSYNCABLE_PREF); 2255 PrefServiceSyncable::UNSYNCABLE_PREF);
2252 prefs->RegisterDictionaryPref(prefs::kExtensionInstallForceList, 2256 prefs->RegisterDictionaryPref(prefs::kExtensionInstallForceList,
2253 PrefService::UNSYNCABLE_PREF); 2257 PrefServiceSyncable::UNSYNCABLE_PREF);
2254 prefs->RegisterListPref(prefs::kExtensionAllowedTypes, 2258 prefs->RegisterListPref(prefs::kExtensionAllowedTypes,
2255 PrefService::UNSYNCABLE_PREF); 2259 PrefServiceSyncable::UNSYNCABLE_PREF);
2256 prefs->RegisterStringPref(kWebStoreLogin, 2260 prefs->RegisterStringPref(kWebStoreLogin,
2257 std::string(), // default value 2261 std::string(), // default value
2258 PrefService::UNSYNCABLE_PREF); 2262 PrefServiceSyncable::UNSYNCABLE_PREF);
2259 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion, 2263 prefs->RegisterStringPref(prefs::kExtensionBlacklistUpdateVersion,
2260 "0", // default value 2264 "0", // default value
2261 PrefService::UNSYNCABLE_PREF); 2265 PrefServiceSyncable::UNSYNCABLE_PREF);
2262 prefs->RegisterBooleanPref(prefs::kExtensionStorageGarbageCollect, 2266 prefs->RegisterBooleanPref(prefs::kExtensionStorageGarbageCollect,
2263 false, // default value 2267 false, // default value
2264 PrefService::UNSYNCABLE_PREF); 2268 PrefServiceSyncable::UNSYNCABLE_PREF);
2265 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, 2269 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck,
2266 0, // default value 2270 0, // default value
2267 PrefService::UNSYNCABLE_PREF); 2271 PrefServiceSyncable::UNSYNCABLE_PREF);
2268 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, 2272 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck,
2269 0, // default value 2273 0, // default value
2270 PrefService::UNSYNCABLE_PREF); 2274 PrefServiceSyncable::UNSYNCABLE_PREF);
2271 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, 2275 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites,
2272 PrefService::UNSYNCABLE_PREF); 2276 PrefServiceSyncable::UNSYNCABLE_PREF);
2273 prefs->RegisterStringPref(kExtensionsLastChromeVersion, 2277 prefs->RegisterStringPref(kExtensionsLastChromeVersion,
2274 std::string(), // default value 2278 std::string(), // default value
2275 PrefService::UNSYNCABLE_PREF); 2279 PrefServiceSyncable::UNSYNCABLE_PREF);
2276 prefs->RegisterBooleanPref(kSideloadWipeoutDone, 2280 prefs->RegisterBooleanPref(kSideloadWipeoutDone,
2277 false, 2281 false,
2278 PrefService::UNSYNCABLE_PREF); 2282 PrefServiceSyncable::UNSYNCABLE_PREF);
2279 } 2283 }
2280 2284
2281 ExtensionIdList ExtensionPrefs::GetExtensionPrefAsVector( 2285 ExtensionIdList ExtensionPrefs::GetExtensionPrefAsVector(
2282 const char* pref) { 2286 const char* pref) {
2283 ExtensionIdList extension_ids; 2287 ExtensionIdList extension_ids;
2284 const ListValue* list_of_values = prefs_->GetList(pref); 2288 const ListValue* list_of_values = prefs_->GetList(pref);
2285 if (!list_of_values) 2289 if (!list_of_values)
2286 return extension_ids; 2290 return extension_ids;
2287 2291
2288 std::string extension_id; 2292 std::string extension_id;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 is_enabled = initial_state == Extension::ENABLED; 2380 is_enabled = initial_state == Extension::ENABLED;
2377 } 2381 }
2378 2382
2379 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 2383 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
2380 is_enabled); 2384 is_enabled);
2381 content_settings_store_->RegisterExtension(extension_id, install_time, 2385 content_settings_store_->RegisterExtension(extension_id, install_time,
2382 is_enabled); 2386 is_enabled);
2383 } 2387 }
2384 2388
2385 } // namespace extensions 2389 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698