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

Unified Diff: components/keyed_service/ios/browser_state_keyed_service_factory.cc

Issue 1090373003: Allow cross dependencies between BCKSF and BSKSF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove wrapper methods Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/keyed_service/ios/browser_state_keyed_service_factory.cc
diff --git a/components/keyed_service/ios/browser_state_keyed_service_factory.cc b/components/keyed_service/ios/browser_state_keyed_service_factory.cc
index 3d2b751fc3934c01aa8a2bc305b2ec89d2ed0044..c5279912454907fc1e9fdaf74e7abe6a3668540a 100644
--- a/components/keyed_service/ios/browser_state_keyed_service_factory.cc
+++ b/components/keyed_service/ios/browser_state_keyed_service_factory.cc
@@ -5,12 +5,9 @@
#include "components/keyed_service/ios/browser_state_keyed_service_factory.h"
#include "base/logging.h"
-#include "base/prefs/pref_service.h"
#include "components/keyed_service/core/keyed_service.h"
+#include "components/keyed_service/ios/browser_state_context_converter.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
-#include "components/keyed_service/ios/browser_state_helper.h"
-#include "components/pref_registry/pref_registry_syncable.h"
-#include "components/user_prefs/user_prefs.h"
#include "ios/web/public/browser_state.h"
void BrowserStateKeyedServiceFactory::SetTestingFactory(
@@ -79,30 +76,46 @@ void BrowserStateKeyedServiceFactory::BrowserStateDestroyed(
KeyedService* BrowserStateKeyedServiceFactory::BuildServiceInstanceFor(
base::SupportsUserData* context) const {
- return BuildServiceInstanceFor(BrowserStateFromContext(context));
+ return BuildServiceInstanceFor(static_cast<web::BrowserState*>(context));
}
bool BrowserStateKeyedServiceFactory::IsOffTheRecord(
base::SupportsUserData* context) const {
- return BrowserStateFromContext(context)->IsOffTheRecord();
+ return static_cast<web::BrowserState*>(context)->IsOffTheRecord();
}
-user_prefs::PrefRegistrySyncable*
-BrowserStateKeyedServiceFactory::GetAssociatedPrefRegistry(
+#if defined(OS_IOS)
+base::SupportsUserData* BrowserStateKeyedServiceFactory::GetTypedContext(
base::SupportsUserData* context) const {
- // TODO(droger): Move this code to KeyedServiceFactory and share it with the
- // other platforms once iOS no longer needs BrowserStateFromContext().
- PrefService* prefs =
- user_prefs::UserPrefs::Get(BrowserStateFromContext(context));
- user_prefs::PrefRegistrySyncable* registry =
- static_cast<user_prefs::PrefRegistrySyncable*>(
- prefs->DeprecatedGetPrefRegistry());
- return registry;
+ if (context) {
+ BrowserStateContextConverter* context_converter =
+ BrowserStateContextConverter::GetInstance();
+ if (context_converter) {
+ context = context_converter->GetBrowserStateForContext(context);
+ DCHECK(context);
+ }
+ }
+ return context;
+}
+
+base::SupportsUserData*
+BrowserStateKeyedServiceFactory::GetContextForDependencyManager(
+ base::SupportsUserData* context) const {
+ if (context) {
+ BrowserStateContextConverter* context_converter =
+ BrowserStateContextConverter::GetInstance();
+ if (context_converter) {
+ context = context_converter->GetBrowserContextForContext(context);
+ DCHECK(context);
+ }
+ }
+ return context;
}
+#endif // defined(OS_IOS)
base::SupportsUserData* BrowserStateKeyedServiceFactory::GetContextToUse(
base::SupportsUserData* context) const {
- return GetBrowserStateToUse(BrowserStateFromContext(context));
+ return GetBrowserStateToUse(static_cast<web::BrowserState*>(context));
}
bool BrowserStateKeyedServiceFactory::ServiceIsCreatedWithContext() const {
@@ -111,15 +124,15 @@ bool BrowserStateKeyedServiceFactory::ServiceIsCreatedWithContext() const {
void BrowserStateKeyedServiceFactory::ContextShutdown(
base::SupportsUserData* context) {
- BrowserStateShutdown(BrowserStateFromContext(context));
+ BrowserStateShutdown(static_cast<web::BrowserState*>(context));
}
void BrowserStateKeyedServiceFactory::ContextDestroyed(
base::SupportsUserData* context) {
- BrowserStateDestroyed(BrowserStateFromContext(context));
+ BrowserStateDestroyed(static_cast<web::BrowserState*>(context));
}
void BrowserStateKeyedServiceFactory::RegisterPrefs(
user_prefs::PrefRegistrySyncable* registry) {
- RegisterProfilePrefs(registry);
+ RegisterBrowserStatePrefs(registry);
}

Powered by Google App Engine
This is Rietveld 408576698