BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / bookmarks / chrome_bookmark_client_factory.cc
blobc84a3744921fc20ae093708544764534b0898f12
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/bookmarks/chrome_bookmark_client_factory.h"
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
9 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/bookmarks/managed/managed_bookmark_service.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 namespace {
17 scoped_ptr<KeyedService> BuildChromeBookmarkClient(
18 content::BrowserContext* context) {
19 Profile* profile = Profile::FromBrowserContext(context);
20 return make_scoped_ptr(new ChromeBookmarkClient(
21 profile, ManagedBookmarkServiceFactory::GetForProfile(profile)));
24 } // namespace
26 // static
27 ChromeBookmarkClient* ChromeBookmarkClientFactory::GetForProfile(
28 Profile* profile) {
29 return static_cast<ChromeBookmarkClient*>(
30 GetInstance()->GetServiceForBrowserContext(profile, true));
33 // static
34 ChromeBookmarkClientFactory* ChromeBookmarkClientFactory::GetInstance() {
35 return base::Singleton<ChromeBookmarkClientFactory>::get();
38 // static
39 BrowserContextKeyedServiceFactory::TestingFactoryFunction
40 ChromeBookmarkClientFactory::GetDefaultFactory() {
41 return &BuildChromeBookmarkClient;
44 ChromeBookmarkClientFactory::ChromeBookmarkClientFactory()
45 : BrowserContextKeyedServiceFactory(
46 "ChromeBookmarkClient",
47 BrowserContextDependencyManager::GetInstance()) {
48 DependsOn(ManagedBookmarkServiceFactory::GetInstance());
51 ChromeBookmarkClientFactory::~ChromeBookmarkClientFactory() {
54 KeyedService* ChromeBookmarkClientFactory::BuildServiceInstanceFor(
55 content::BrowserContext* context) const {
56 return BuildChromeBookmarkClient(context).release();
59 content::BrowserContext* ChromeBookmarkClientFactory::GetBrowserContextToUse(
60 content::BrowserContext* context) const {
61 return chrome::GetBrowserContextRedirectedInIncognito(context);
64 bool ChromeBookmarkClientFactory::ServiceIsNULLWhileTesting() const {
65 return true;