Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ios / chrome / browser / enhanced_bookmarks / enhanced_bookmark_model_factory.cc
blobd5c26cd0d6cc95faf77adcc004c5b3f04b4cf99b
1 // Copyright 2015 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 "ios/chrome/browser/enhanced_bookmarks/enhanced_bookmark_model_factory.h"
7 #include "base/memory/singleton.h"
8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
9 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
10 #include "components/version_info/version_info.h"
11 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h"
13 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
15 namespace enhanced_bookmarks {
17 // static
18 EnhancedBookmarkModelFactory* EnhancedBookmarkModelFactory::GetInstance() {
19 return Singleton<EnhancedBookmarkModelFactory>::get();
22 // static
23 EnhancedBookmarkModel* EnhancedBookmarkModelFactory::GetForBrowserState(
24 ios::ChromeBrowserState* browser_state) {
25 return static_cast<EnhancedBookmarkModel*>(
26 GetInstance()->GetServiceForBrowserState(browser_state, true));
29 EnhancedBookmarkModelFactory::EnhancedBookmarkModelFactory()
30 : BrowserStateKeyedServiceFactory(
31 "EnhancedBookmarkModel",
32 BrowserStateDependencyManager::GetInstance()) {
33 DependsOn(ios::BookmarkModelFactory::GetInstance());
36 EnhancedBookmarkModelFactory::~EnhancedBookmarkModelFactory() {
39 scoped_ptr<KeyedService> EnhancedBookmarkModelFactory::BuildServiceInstanceFor(
40 web::BrowserState* context) const {
41 DCHECK(!context->IsOffTheRecord());
42 ios::ChromeBrowserState* browser_state =
43 ios::ChromeBrowserState::FromBrowserState(context);
44 return make_scoped_ptr(new EnhancedBookmarkModel(
45 ios::BookmarkModelFactory::GetForBrowserState(browser_state),
46 "chrome." + version_info::GetVersionNumber()));
49 web::BrowserState* EnhancedBookmarkModelFactory::GetBrowserStateToUse(
50 web::BrowserState* context) const {
51 return GetBrowserStateRedirectedInIncognito(context);
54 } // namespace enhanced_bookmarks