Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/browser/bookmarks/bookmark_model_factory.cc

Issue 1198963014: Change ownership of BookmarkClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_managed_and_supervised_nodes
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bookmark_model_factory.h" 5 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/deferred_sequenced_task_runner.h" 8 #include "base/deferred_sequenced_task_runner.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 12 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
13 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
14 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" 13 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h"
15 #include "chrome/browser/profiles/incognito_helpers.h" 14 #include "chrome/browser/profiles/incognito_helpers.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/undo/bookmark_undo_service_factory.h" 16 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
18 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
20 #include "components/bookmarks/browser/bookmark_model.h" 19 #include "components/bookmarks/browser/bookmark_model.h"
21 #include "components/bookmarks/browser/startup_task_runner_service.h" 20 #include "components/bookmarks/browser/startup_task_runner_service.h"
22 #include "components/bookmarks/common/bookmark_pref_names.h" 21 #include "components/bookmarks/common/bookmark_pref_names.h"
23 #include "components/keyed_service/content/browser_context_dependency_manager.h" 22 #include "components/keyed_service/content/browser_context_dependency_manager.h"
(...skipping 18 matching lines...) Expand all
42 // static 41 // static
43 BookmarkModelFactory* BookmarkModelFactory::GetInstance() { 42 BookmarkModelFactory* BookmarkModelFactory::GetInstance() {
44 return Singleton<BookmarkModelFactory>::get(); 43 return Singleton<BookmarkModelFactory>::get();
45 } 44 }
46 45
47 BookmarkModelFactory::BookmarkModelFactory() 46 BookmarkModelFactory::BookmarkModelFactory()
48 : BrowserContextKeyedServiceFactory( 47 : BrowserContextKeyedServiceFactory(
49 "BookmarkModel", 48 "BookmarkModel",
50 BrowserContextDependencyManager::GetInstance()) { 49 BrowserContextDependencyManager::GetInstance()) {
51 DependsOn(BookmarkUndoServiceFactory::GetInstance()); 50 DependsOn(BookmarkUndoServiceFactory::GetInstance());
52 DependsOn(ChromeBookmarkClientFactory::GetInstance());
53 DependsOn(StartupTaskRunnerServiceFactory::GetInstance()); 51 DependsOn(StartupTaskRunnerServiceFactory::GetInstance());
54 } 52 }
55 53
56 BookmarkModelFactory::~BookmarkModelFactory() { 54 BookmarkModelFactory::~BookmarkModelFactory() {
57 } 55 }
58 56
59 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor( 57 KeyedService* BookmarkModelFactory::BuildServiceInstanceFor(
60 content::BrowserContext* context) const { 58 content::BrowserContext* context) const {
61 Profile* profile = Profile::FromBrowserContext(context); 59 Profile* profile = Profile::FromBrowserContext(context);
62 ChromeBookmarkClient* bookmark_client = 60 BookmarkModel* bookmark_model =
63 ChromeBookmarkClientFactory::GetForProfile(profile); 61 new BookmarkModel(make_scoped_ptr(new ChromeBookmarkClient(profile)));
64 BookmarkModel* bookmark_model = new BookmarkModel(bookmark_client);
65 bookmark_client->Init(bookmark_model);
66 bookmark_model->Load(profile->GetPrefs(), 62 bookmark_model->Load(profile->GetPrefs(),
67 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), 63 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
68 profile->GetPath(), 64 profile->GetPath(),
69 StartupTaskRunnerServiceFactory::GetForProfile(profile) 65 StartupTaskRunnerServiceFactory::GetForProfile(profile)
70 ->GetBookmarkTaskRunner(), 66 ->GetBookmarkTaskRunner(),
71 content::BrowserThread::GetMessageLoopProxyForThread( 67 content::BrowserThread::GetMessageLoopProxyForThread(
72 content::BrowserThread::UI)); 68 content::BrowserThread::UI));
73 bool register_bookmark_undo_service_as_observer = true; 69 bool register_bookmark_undo_service_as_observer = true;
74 #if !defined(OS_IOS) && !defined(OS_ANDROID) 70 #if !defined(OS_IOS) && !defined(OS_ANDROID)
75 register_bookmark_undo_service_as_observer = 71 register_bookmark_undo_service_as_observer =
(...skipping 18 matching lines...) Expand all
94 } 90 }
95 91
96 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse( 92 content::BrowserContext* BookmarkModelFactory::GetBrowserContextToUse(
97 content::BrowserContext* context) const { 93 content::BrowserContext* context) const {
98 return chrome::GetBrowserContextRedirectedInIncognito(context); 94 return chrome::GetBrowserContextRedirectedInIncognito(context);
99 } 95 }
100 96
101 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const { 97 bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const {
102 return true; 98 return true;
103 } 99 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/bookmark_provider_unittest.cc ('k') | chrome/browser/bookmarks/chrome_bookmark_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698