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
3 // found in the LICENSE file.
5 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
7 #include "chrome/browser/prerender/prerender_link_manager.h"
8 #include "chrome/browser/prerender/prerender_manager.h"
9 #include "chrome/browser/prerender/prerender_manager_factory.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
17 PrerenderLinkManager
* PrerenderLinkManagerFactory::GetForProfile(
19 return static_cast<PrerenderLinkManager
*>(
20 GetInstance()->GetServiceForBrowserContext(profile
, true));
24 PrerenderLinkManagerFactory
* PrerenderLinkManagerFactory::GetInstance() {
25 return Singleton
<PrerenderLinkManagerFactory
>::get();
28 PrerenderLinkManagerFactory::PrerenderLinkManagerFactory()
29 : BrowserContextKeyedServiceFactory(
30 "PrerenderLinkmanager",
31 BrowserContextDependencyManager::GetInstance()) {
32 DependsOn(prerender::PrerenderManagerFactory::GetInstance());
35 KeyedService
* PrerenderLinkManagerFactory::BuildServiceInstanceFor(
36 content::BrowserContext
* profile
) const {
37 PrerenderManager
* prerender_manager
=
38 PrerenderManagerFactory::GetForProfile(static_cast<Profile
*>(profile
));
39 if (!prerender_manager
)
41 PrerenderLinkManager
* prerender_link_manager
=
42 new PrerenderLinkManager(prerender_manager
);
43 return prerender_link_manager
;
46 content::BrowserContext
* PrerenderLinkManagerFactory::GetBrowserContextToUse(
47 content::BrowserContext
* context
) const {
48 return chrome::GetBrowserContextOwnInstanceInIncognito(context
);
51 } // namespace prerender