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

Side by Side Diff: components/browser_context_keyed_service/browser_context_keyed_base_factory.cc

Issue 18199003: Allow Chrome OS login profile to have different default pref values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 5 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
« no previous file with comments | « components/browser_context_keyed_service/browser_context_keyed_base_factory.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // that used BrowserContext. Now we don't and there are timing issues. 51 // that used BrowserContext. Now we don't and there are timing issues.
52 // 52 //
53 // With normal contexts, prefs can simply be registered at 53 // With normal contexts, prefs can simply be registered at
54 // BrowserContextDependencyManager::CreateBrowserContextServices time. 54 // BrowserContextDependencyManager::CreateBrowserContextServices time.
55 // With incognito contexts, we just never register since incognito contexts 55 // With incognito contexts, we just never register since incognito contexts
56 // share the same pref services with their parent contexts. 56 // share the same pref services with their parent contexts.
57 // 57 //
58 // TestingBrowserContexts throw a wrench into the mix, in that some tests will 58 // TestingBrowserContexts throw a wrench into the mix, in that some tests will
59 // swap out the PrefService after we've registered user prefs on the original 59 // swap out the PrefService after we've registered user prefs on the original
60 // PrefService. Test code that does this is responsible for either manually 60 // PrefService. Test code that does this is responsible for either manually
61 // invoking RegisterUserPrefs() 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()); 71 DCHECK(!context->IsOffTheRecord());
72 72
73 std::set<content::BrowserContext*>::iterator it = 73 std::set<content::BrowserContext*>::iterator it =
74 registered_preferences_.find(context); 74 registered_preferences_.find(context);
75 if (it == registered_preferences_.end()) { 75 if (it == registered_preferences_.end()) {
76 PrefService* prefs = user_prefs::UserPrefs::Get(context); 76 PrefService* prefs = user_prefs::UserPrefs::Get(context);
77 user_prefs::PrefRegistrySyncable* registry = 77 user_prefs::PrefRegistrySyncable* registry =
78 static_cast<user_prefs::PrefRegistrySyncable*>( 78 static_cast<user_prefs::PrefRegistrySyncable*>(
79 prefs->DeprecatedGetPrefRegistry()); 79 prefs->DeprecatedGetPrefRegistry());
80 RegisterUserPrefs(registry); 80 RegisterProfilePrefs(registry);
81 registered_preferences_.insert(context); 81 registered_preferences_.insert(context);
82 } 82 }
83 } 83 }
84 84
85 bool 85 bool
86 BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext() const { 86 BrowserContextKeyedBaseFactory::ServiceIsCreatedWithBrowserContext() const {
87 return false; 87 return false;
88 } 88 }
89 89
90 bool BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting() const { 90 bool BrowserContextKeyedBaseFactory::ServiceIsNULLWhileTesting() const {
(...skipping 13 matching lines...) Expand all
104 content::BrowserContext* context) const { 104 content::BrowserContext* context) const {
105 return registered_preferences_.find(context) != 105 return registered_preferences_.find(context) !=
106 registered_preferences_.end(); 106 registered_preferences_.end();
107 } 107 }
108 108
109 void BrowserContextKeyedBaseFactory::MarkPreferencesSetOn( 109 void BrowserContextKeyedBaseFactory::MarkPreferencesSetOn(
110 content::BrowserContext* context) { 110 content::BrowserContext* context) {
111 DCHECK(!ArePreferencesSetOn(context)); 111 DCHECK(!ArePreferencesSetOn(context));
112 registered_preferences_.insert(context); 112 registered_preferences_.insert(context);
113 } 113 }
OLDNEW
« no previous file with comments | « components/browser_context_keyed_service/browser_context_keyed_base_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698