aw_browser_dependency_factory_impl.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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.
4
5#include "android_webview/lib/aw_browser_dependency_factory_impl.h"
6
7#include "android_webview/browser/aw_browser_context.h"
8#include "android_webview/browser/aw_content_browser_client.h"
9#include "base/lazy_instance.h"
10#include "content/public/browser/content_browser_client.h"
11#include "content/public/browser/web_contents.h"
12#include "content/public/common/content_client.h"
13
14using content::BrowserContext;
15using content::WebContents;
16
17namespace android_webview {
18
19namespace {
20
21base::LazyInstance<AwBrowserDependencyFactoryImpl>::Leaky g_lazy_instance;
22
23}  // namespace
24
25AwBrowserDependencyFactoryImpl::AwBrowserDependencyFactoryImpl() {}
26
27AwBrowserDependencyFactoryImpl::~AwBrowserDependencyFactoryImpl() {}
28
29// static
30void AwBrowserDependencyFactoryImpl::InstallInstance() {
31  SetInstance(g_lazy_instance.Pointer());
32}
33
34content::BrowserContext* AwBrowserDependencyFactoryImpl::GetBrowserContext() {
35  return static_cast<AwContentBrowserClient*>(
36      content::GetContentClient()->browser())->GetAwBrowserContext();
37}
38
39WebContents* AwBrowserDependencyFactoryImpl::CreateWebContents() {
40  return content::WebContents::Create(
41      content::WebContents::CreateParams(GetBrowserContext()));
42}
43
44}  // namespace android_webview
45