1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service_factory.h"
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.h"
11 #include "chrome/browser/enhanced_bookmarks/enhanced_bookmark_model_factory.h"
12 #include "chrome/browser/profiles/incognito_helpers.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
15 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "components/keyed_service/content/browser_context_dependency_manager.h"
18 #include "components/signin/core/browser/signin_manager.h"
20 namespace enhanced_bookmarks
{
22 ChromeBookmarkServerClusterServiceFactory::
23 ChromeBookmarkServerClusterServiceFactory()
24 : BrowserContextKeyedServiceFactory(
25 "ChromeBookmarkServerClusterService",
26 BrowserContextDependencyManager::GetInstance()) {
27 DependsOn(ProfileSyncServiceFactory::GetInstance());
28 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
29 DependsOn(SigninManagerFactory::GetInstance());
30 DependsOn(BookmarkModelFactory::GetInstance());
34 ChromeBookmarkServerClusterServiceFactory
*
35 ChromeBookmarkServerClusterServiceFactory::GetInstance() {
36 return Singleton
<ChromeBookmarkServerClusterServiceFactory
>::get();
40 ChromeBookmarkServerClusterService
*
41 ChromeBookmarkServerClusterServiceFactory::GetForBrowserContext(
42 content::BrowserContext
* context
) {
43 DCHECK(!context
->IsOffTheRecord());
44 return static_cast<ChromeBookmarkServerClusterService
*>(
45 GetInstance()->GetServiceForBrowserContext(context
, true));
49 ChromeBookmarkServerClusterServiceFactory::BuildServiceInstanceFor(
50 content::BrowserContext
* browser_context
) const {
51 DCHECK(!browser_context
->IsOffTheRecord());
52 Profile
* profile
= Profile::FromBrowserContext(browser_context
);
54 return new ChromeBookmarkServerClusterService(
55 g_browser_process
->GetApplicationLocale(),
56 browser_context
->GetRequestContext(),
57 ProfileOAuth2TokenServiceFactory::GetForProfile(profile
),
58 SigninManagerFactory::GetForProfile(profile
),
59 EnhancedBookmarkModelFactory::GetForBrowserContext(profile
),
61 ProfileSyncServiceFactory::GetForProfile(profile
));
64 content::BrowserContext
*
65 ChromeBookmarkServerClusterServiceFactory::GetBrowserContextToUse(
66 content::BrowserContext
* context
) const {
67 return chrome::GetBrowserContextRedirectedInIncognito(context
);
70 } // namespace enhanced_bookmarks