Chromium Code Reviews| Index: chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service_factory.cc |
| diff --git a/chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service_factory.cc b/chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2195464d45343272af7bf147e104293ed83564c3 |
| --- /dev/null |
| +++ b/chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service_factory.cc |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service_factory.h" |
| + |
| +#include "base/memory/singleton.h" |
| +#include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| +#include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| +#include "chrome/browser/signin/signin_manager_factory.h" |
| +#include "chrome/browser/sync/profile_sync_service_factory.h" |
| +#include "components/keyed_service/content/browser_context_dependency_manager.h" |
| +#include "components/signin/core/browser/signin_manager.h" |
| + |
| +namespace enhanced_bookmarks { |
| + |
| +ChromeBookmarkServerClusterServiceFactory* |
| +ChromeBookmarkServerClusterServiceFactory::GetInstance() { |
|
Yaron
2014/09/05 05:18:00
Any reason you included the factory here but not f
noyau (Ping after 24h)
2014/09/10 08:53:57
Because the other one doesn't keep state, so doesn
|
| + return Singleton<ChromeBookmarkServerClusterServiceFactory>::get(); |
| +} |
| + |
| +// static |
| +ChromeBookmarkServerClusterService* |
| +ChromeBookmarkServerClusterServiceFactory::GetForBrowserContext( |
| + content::BrowserContext* context) { |
| + DCHECK(!context->IsOffTheRecord()); |
| + return static_cast<ChromeBookmarkServerClusterService*>( |
| + GetInstance()->GetServiceForBrowserContext(context, true)); |
| +} |
| + |
| +KeyedService* |
| +ChromeBookmarkServerClusterServiceFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* browser_context) const { |
| + DCHECK(!browser_context->IsOffTheRecord()); |
| + Profile* profile = Profile::FromBrowserContext(browser_context); |
| + |
| + return new ChromeBookmarkServerClusterService( |
| + g_browser_process->GetApplicationLocale(), |
| + browser_context->GetRequestContext(), |
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| + SigninManagerFactory::GetForProfile(profile), |
| + BookmarkModelFactory::GetForProfile(profile), |
| + profile->GetPrefs(), |
| + ProfileSyncServiceFactory::GetForProfile(profile)); |
| +} |
| + |
| +ChromeBookmarkServerClusterServiceFactory:: |
| + ChromeBookmarkServerClusterServiceFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "ChromeBookmarkServerClusterService", |
| + BrowserContextDependencyManager::GetInstance()) { |
| + DependsOn(ProfileSyncServiceFactory::GetInstance()); |
| + DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| + DependsOn(SigninManagerFactory::GetInstance()); |
| + DependsOn(BookmarkModelFactory::GetInstance()); |
| +} |
| + |
| +ChromeBookmarkServerClusterServiceFactory:: |
| + ~ChromeBookmarkServerClusterServiceFactory() { |
| +} |
| + |
| +content::BrowserContext* |
| +ChromeBookmarkServerClusterServiceFactory::GetBrowserContextToUse( |
| + content::BrowserContext* context) const { |
| + return context; |
| +} |
| +} // namespace enhanced_bookmarks |