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