| 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/enhanced_bookmarks/enhanced_bookmark_model_factory.h" | 5 #include "chrome/browser/enhanced_bookmarks/enhanced_bookmark_model_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/profiles/incognito_helpers.h" | 9 #include "chrome/browser/profiles/incognito_helpers.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" | 11 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "components/version_info/version_info.h" | 13 #include "components/version_info/version_info.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 const char kVersionPrefix[] = "chrome."; | 16 const char kVersionPrefix[] = "chrome."; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace enhanced_bookmarks { | 19 namespace enhanced_bookmarks { |
| 20 | 20 |
| 21 EnhancedBookmarkModelFactory::EnhancedBookmarkModelFactory() | 21 EnhancedBookmarkModelFactory::EnhancedBookmarkModelFactory() |
| 22 : BrowserContextKeyedServiceFactory( | 22 : BrowserContextKeyedServiceFactory( |
| 23 "EnhancedBookmarkModel", | 23 "EnhancedBookmarkModel", |
| 24 BrowserContextDependencyManager::GetInstance()) { | 24 BrowserContextDependencyManager::GetInstance()) { |
| 25 DependsOn(BookmarkModelFactory::GetInstance()); | 25 DependsOn(BookmarkModelFactory::GetInstance()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 EnhancedBookmarkModelFactory* EnhancedBookmarkModelFactory::GetInstance() { | 29 EnhancedBookmarkModelFactory* EnhancedBookmarkModelFactory::GetInstance() { |
| 30 return Singleton<EnhancedBookmarkModelFactory>::get(); | 30 return base::Singleton<EnhancedBookmarkModelFactory>::get(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 EnhancedBookmarkModel* EnhancedBookmarkModelFactory::GetForBrowserContext( | 34 EnhancedBookmarkModel* EnhancedBookmarkModelFactory::GetForBrowserContext( |
| 35 content::BrowserContext* context) { | 35 content::BrowserContext* context) { |
| 36 DCHECK(!context->IsOffTheRecord()); | 36 DCHECK(!context->IsOffTheRecord()); |
| 37 return static_cast<EnhancedBookmarkModel*>( | 37 return static_cast<EnhancedBookmarkModel*>( |
| 38 GetInstance()->GetServiceForBrowserContext(context, true)); | 38 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 KeyedService* EnhancedBookmarkModelFactory::BuildServiceInstanceFor( | 41 KeyedService* EnhancedBookmarkModelFactory::BuildServiceInstanceFor( |
| 42 content::BrowserContext* browser_context) const { | 42 content::BrowserContext* browser_context) const { |
| 43 DCHECK(!browser_context->IsOffTheRecord()); | 43 DCHECK(!browser_context->IsOffTheRecord()); |
| 44 Profile* profile = Profile::FromBrowserContext(browser_context); | 44 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 45 | 45 |
| 46 return new EnhancedBookmarkModel( | 46 return new EnhancedBookmarkModel( |
| 47 BookmarkModelFactory::GetForProfile(profile), | 47 BookmarkModelFactory::GetForProfile(profile), |
| 48 kVersionPrefix + version_info::GetVersionNumber()); | 48 kVersionPrefix + version_info::GetVersionNumber()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 content::BrowserContext* EnhancedBookmarkModelFactory::GetBrowserContextToUse( | 51 content::BrowserContext* EnhancedBookmarkModelFactory::GetBrowserContextToUse( |
| 52 content::BrowserContext* context) const { | 52 content::BrowserContext* context) const { |
| 53 return chrome::GetBrowserContextRedirectedInIncognito(context); | 53 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace enhanced_bookmarks | 56 } // namespace enhanced_bookmarks |
| OLD | NEW |