OLD | NEW |
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 "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" | 5 #include "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 8 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
9 #include "components/user_prefs/pref_registry_syncable.h" | 9 #include "components/user_prefs/pref_registry_syncable.h" |
10 #include "components/user_prefs/user_prefs.h" | 10 #include "components/user_prefs/user_prefs.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // invoking RegisterProfilePrefs() on the appropriate | 61 // invoking RegisterProfilePrefs() on the appropriate |
62 // BrowserContextKeyedServiceFactory associated with the prefs they need, | 62 // BrowserContextKeyedServiceFactory associated with the prefs they need, |
63 // or they can use SetTestingFactory() and create a service (since service | 63 // or they can use SetTestingFactory() and create a service (since service |
64 // creation with a factory method causes registration to happen at service | 64 // creation with a factory method causes registration to happen at service |
65 // creation time). | 65 // creation time). |
66 // | 66 // |
67 // Now that services are responsible for declaring their preferences, we have | 67 // Now that services are responsible for declaring their preferences, we have |
68 // to enforce a uniquenes check here because some tests create one context and | 68 // to enforce a uniquenes check here because some tests create one context and |
69 // multiple services of the same type attached to that context (serially, not | 69 // multiple services of the same type attached to that context (serially, not |
70 // parallel) and we don't want to register multiple times on the same context. | 70 // parallel) and we don't want to register multiple times on the same context. |
71 DCHECK(!context->IsOffTheRecord()); | |
72 | 71 |
73 std::set<content::BrowserContext*>::iterator it = | 72 std::set<content::BrowserContext*>::iterator it = |
74 registered_preferences_.find(context); | 73 registered_preferences_.find(context); |
75 if (it == registered_preferences_.end()) { | 74 if (it == registered_preferences_.end()) { |
76 PrefService* prefs = user_prefs::UserPrefs::Get(context); | 75 PrefService* prefs = user_prefs::UserPrefs::Get(context); |
77 user_prefs::PrefRegistrySyncable* registry = | 76 user_prefs::PrefRegistrySyncable* registry = |
78 static_cast<user_prefs::PrefRegistrySyncable*>( | 77 static_cast<user_prefs::PrefRegistrySyncable*>( |
79 prefs->DeprecatedGetPrefRegistry()); | 78 prefs->DeprecatedGetPrefRegistry()); |
80 RegisterProfilePrefs(registry); | 79 RegisterProfilePrefs(registry); |
81 registered_preferences_.insert(context); | 80 registered_preferences_.insert(context); |
(...skipping 22 matching lines...) Expand all Loading... |
104 content::BrowserContext* context) const { | 103 content::BrowserContext* context) const { |
105 return registered_preferences_.find(context) != | 104 return registered_preferences_.find(context) != |
106 registered_preferences_.end(); | 105 registered_preferences_.end(); |
107 } | 106 } |
108 | 107 |
109 void BrowserContextKeyedBaseFactory::MarkPreferencesSetOn( | 108 void BrowserContextKeyedBaseFactory::MarkPreferencesSetOn( |
110 content::BrowserContext* context) { | 109 content::BrowserContext* context) { |
111 DCHECK(!ArePreferencesSetOn(context)); | 110 DCHECK(!ArePreferencesSetOn(context)); |
112 registered_preferences_.insert(context); | 111 registered_preferences_.insert(context); |
113 } | 112 } |
OLD | NEW |