blob: 1f63b6dc6a770abc587c5f3ab2be4fca353972a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "base/memory/singleton.h"
#include "base/values.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/common/pref_names.h"
#include "components/user_prefs/pref_registry_syncable.h"
// static
BookmarkModel* BookmarkModelFactory::GetForProfile(Profile* profile) {
return static_cast<BookmarkModel*>(
GetInstance()->GetServiceForProfile(profile, true));
}
BookmarkModel* BookmarkModelFactory::GetForProfileIfExists(Profile* profile) {
return static_cast<BookmarkModel*>(
GetInstance()->GetServiceForProfile(profile, false));
}
// static
BookmarkModelFactory* BookmarkModelFactory::GetInstance() {
return Singleton<BookmarkModelFactory>::get();
}
BookmarkModelFactory::BookmarkModelFactory()
: ProfileKeyedServiceFactory("BookmarkModel",
ProfileDependencyManager::GetInstance()) {
}
BookmarkModelFactory::~BookmarkModelFactory() {}
ProfileKeyedService* BookmarkModelFactory::BuildServiceInstanceFor(
Profile* profile) const {
BookmarkModel* bookmark_model = new BookmarkModel(profile);
bookmark_model->Load();
return bookmark_model;
}
void BookmarkModelFactory::RegisterUserPrefs(PrefRegistrySyncable* registry) {
// Don't sync this, as otherwise, due to a limitation in sync, it
// will cause a deadlock (see http://crbug.com/97955). If we truly
// want to sync the expanded state of folders, it should be part of
// bookmark sync itself (i.e., a property of the sync folder nodes).
registry->RegisterListPref(prefs::kBookmarkEditorExpandedNodes,
new base::ListValue,
PrefRegistrySyncable::UNSYNCABLE_PREF);
}
bool BookmarkModelFactory::ServiceRedirectedInIncognito() const {
return true;
}
bool BookmarkModelFactory::ServiceIsNULLWhileTesting() const {
return true;
}
|