| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" | 5 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" | 
| 6 | 6 | 
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" | 
| 8 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 8 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 
|  | 9 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 
| 9 #include "chrome/browser/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" | 
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" | 
|  | 12 #include "components/bookmarks/managed/managed_bookmark_service.h" | 
| 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 
| 12 | 14 | 
|  | 15 namespace { | 
|  | 16 | 
|  | 17 scoped_ptr<KeyedService> BuildChromeBookmarkClient( | 
|  | 18     content::BrowserContext* context) { | 
|  | 19   Profile* profile = Profile::FromBrowserContext(context); | 
|  | 20   return make_scoped_ptr(new ChromeBookmarkClient( | 
|  | 21       profile, ManagedBookmarkServiceFactory::GetForProfile(profile))); | 
|  | 22 } | 
|  | 23 | 
|  | 24 }  // namespace | 
|  | 25 | 
| 13 // static | 26 // static | 
| 14 ChromeBookmarkClient* ChromeBookmarkClientFactory::GetForProfile( | 27 ChromeBookmarkClient* ChromeBookmarkClientFactory::GetForProfile( | 
| 15     Profile* profile) { | 28     Profile* profile) { | 
| 16   return static_cast<ChromeBookmarkClient*>( | 29   return static_cast<ChromeBookmarkClient*>( | 
| 17       GetInstance()->GetServiceForBrowserContext(profile, true)); | 30       GetInstance()->GetServiceForBrowserContext(profile, true)); | 
| 18 } | 31 } | 
| 19 | 32 | 
| 20 // static | 33 // static | 
| 21 ChromeBookmarkClientFactory* ChromeBookmarkClientFactory::GetInstance() { | 34 ChromeBookmarkClientFactory* ChromeBookmarkClientFactory::GetInstance() { | 
| 22   return Singleton<ChromeBookmarkClientFactory>::get(); | 35   return Singleton<ChromeBookmarkClientFactory>::get(); | 
| 23 } | 36 } | 
| 24 | 37 | 
|  | 38 // static | 
|  | 39 BrowserContextKeyedServiceFactory::TestingFactoryFunction | 
|  | 40 ChromeBookmarkClientFactory::GetDefaultFactory() { | 
|  | 41   return &BuildChromeBookmarkClient; | 
|  | 42 } | 
|  | 43 | 
| 25 ChromeBookmarkClientFactory::ChromeBookmarkClientFactory() | 44 ChromeBookmarkClientFactory::ChromeBookmarkClientFactory() | 
| 26     : BrowserContextKeyedServiceFactory( | 45     : BrowserContextKeyedServiceFactory( | 
| 27           "ChromeBookmarkClient", | 46           "ChromeBookmarkClient", | 
| 28           BrowserContextDependencyManager::GetInstance()) { | 47           BrowserContextDependencyManager::GetInstance()) { | 
|  | 48   DependsOn(ManagedBookmarkServiceFactory::GetInstance()); | 
| 29 } | 49 } | 
| 30 | 50 | 
| 31 ChromeBookmarkClientFactory::~ChromeBookmarkClientFactory() { | 51 ChromeBookmarkClientFactory::~ChromeBookmarkClientFactory() { | 
| 32 } | 52 } | 
| 33 | 53 | 
| 34 KeyedService* ChromeBookmarkClientFactory::BuildServiceInstanceFor( | 54 KeyedService* ChromeBookmarkClientFactory::BuildServiceInstanceFor( | 
| 35     content::BrowserContext* context) const { | 55     content::BrowserContext* context) const { | 
| 36   return new ChromeBookmarkClient(static_cast<Profile*>(context)); | 56   return BuildChromeBookmarkClient(context).release(); | 
| 37 } | 57 } | 
| 38 | 58 | 
| 39 content::BrowserContext* ChromeBookmarkClientFactory::GetBrowserContextToUse( | 59 content::BrowserContext* ChromeBookmarkClientFactory::GetBrowserContextToUse( | 
| 40     content::BrowserContext* context) const { | 60     content::BrowserContext* context) const { | 
| 41   return chrome::GetBrowserContextRedirectedInIncognito(context); | 61   return chrome::GetBrowserContextRedirectedInIncognito(context); | 
| 42 } | 62 } | 
| 43 | 63 | 
| 44 bool ChromeBookmarkClientFactory::ServiceIsNULLWhileTesting() const { | 64 bool ChromeBookmarkClientFactory::ServiceIsNULLWhileTesting() const { | 
| 45   return true; | 65   return true; | 
| 46 } | 66 } | 
| OLD | NEW | 
|---|