OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 5 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
9 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
10 #include "components/bookmarks/browser/bookmark_model.h" | 11 #include "components/bookmarks/browser/bookmark_model.h" |
11 #include "components/bookmarks/browser/bookmark_utils.h" | 12 #include "components/bookmarks/browser/bookmark_utils.h" |
12 #include "components/bookmarks/browser/startup_task_runner_service.h" | 13 #include "components/bookmarks/browser/startup_task_runner_service.h" |
13 #include "components/keyed_service/ios/browser_state_dependency_manager.h" | 14 #include "components/keyed_service/ios/browser_state_dependency_manager.h" |
14 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
15 #include "components/undo/bookmark_undo_service.h" | 16 #include "components/undo/bookmark_undo_service.h" |
16 #include "ios/chrome/browser/bookmarks/bookmark_client_impl.h" | 17 #include "ios/chrome/browser/bookmarks/bookmark_client_impl.h" |
17 #include "ios/chrome/browser/bookmarks/startup_task_runner_service_factory.h" | 18 #include "ios/chrome/browser/bookmarks/startup_task_runner_service_factory.h" |
18 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" | 19 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 DependsOn(ios::StartupTaskRunnerServiceFactory::GetInstance()); | 51 DependsOn(ios::StartupTaskRunnerServiceFactory::GetInstance()); |
51 } | 52 } |
52 | 53 |
53 BookmarkModelFactory::~BookmarkModelFactory() {} | 54 BookmarkModelFactory::~BookmarkModelFactory() {} |
54 | 55 |
55 void BookmarkModelFactory::RegisterBrowserStatePrefs( | 56 void BookmarkModelFactory::RegisterBrowserStatePrefs( |
56 user_prefs::PrefRegistrySyncable* registry) { | 57 user_prefs::PrefRegistrySyncable* registry) { |
57 bookmarks::RegisterProfilePrefs(registry); | 58 bookmarks::RegisterProfilePrefs(registry); |
58 } | 59 } |
59 | 60 |
60 scoped_ptr<KeyedService> BookmarkModelFactory::BuildServiceInstanceFor( | 61 std::unique_ptr<KeyedService> BookmarkModelFactory::BuildServiceInstanceFor( |
61 web::BrowserState* context) const { | 62 web::BrowserState* context) const { |
62 ios::ChromeBrowserState* browser_state = | 63 ios::ChromeBrowserState* browser_state = |
63 ios::ChromeBrowserState::FromBrowserState(context); | 64 ios::ChromeBrowserState::FromBrowserState(context); |
64 scoped_ptr<bookmarks::BookmarkModel> bookmark_model( | 65 std::unique_ptr<bookmarks::BookmarkModel> bookmark_model( |
65 new bookmarks::BookmarkModel( | 66 new bookmarks::BookmarkModel( |
66 make_scoped_ptr(new BookmarkClientImpl(browser_state)))); | 67 base::WrapUnique(new BookmarkClientImpl(browser_state)))); |
67 bookmark_model->Load( | 68 bookmark_model->Load( |
68 browser_state->GetPrefs(), | 69 browser_state->GetPrefs(), |
69 browser_state->GetStatePath(), | 70 browser_state->GetStatePath(), |
70 ios::StartupTaskRunnerServiceFactory::GetForBrowserState(browser_state) | 71 ios::StartupTaskRunnerServiceFactory::GetForBrowserState(browser_state) |
71 ->GetBookmarkTaskRunner(), | 72 ->GetBookmarkTaskRunner(), |
72 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI)); | 73 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI)); |
73 ios::BookmarkUndoServiceFactory::GetForBrowserState(browser_state) | 74 ios::BookmarkUndoServiceFactory::GetForBrowserState(browser_state) |
74 ->Start(bookmark_model.get()); | 75 ->Start(bookmark_model.get()); |
75 return std::move(bookmark_model); | 76 return std::move(bookmark_model); |
76 } | 77 } |
77 | 78 |
78 web::BrowserState* BookmarkModelFactory::GetBrowserStateToUse( | 79 web::BrowserState* BookmarkModelFactory::GetBrowserStateToUse( |
79 web::BrowserState* context) const { | 80 web::BrowserState* context) const { |
80 return GetBrowserStateRedirectedInIncognito(context); | 81 return GetBrowserStateRedirectedInIncognito(context); |
81 } | 82 } |
82 | 83 |
83 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { | 84 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { |
84 return true; | 85 return true; |
85 } | 86 } |
86 | 87 |
87 } // namespace ios | 88 } // namespace ios |
OLD | NEW |