Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / translate / content / browser / browser_cld_data_provider_factory.cc
blobdb72ac1d23f1adbceb695a47aa68eb27d641b06b
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 "components/translate/content/browser/browser_cld_data_provider_factory.h"
7 #include "base/lazy_instance.h"
8 #include "components/translate/content/browser/browser_cld_data_provider.h"
10 namespace {
12 // The global instance, alive for the entire lifetime of the process.
13 translate::BrowserCldDataProviderFactory* g_instance = NULL;
15 // The default factory, which produces no-op instances of BrowserCldDataProvider
16 // suitable for use when CLD data is statically-linked.
17 base::LazyInstance<translate::BrowserCldDataProviderFactory>::Leaky
18 g_wrapped_default = LAZY_INSTANCE_INITIALIZER;
20 } // namespace
23 namespace translate {
25 scoped_ptr<BrowserCldDataProvider>
26 BrowserCldDataProviderFactory::CreateBrowserCldDataProvider(
27 content::WebContents* web_contents) {
28 return scoped_ptr<BrowserCldDataProvider>(new BrowserCldDataProvider());
31 // static
32 bool BrowserCldDataProviderFactory::IsInitialized() {
33 return g_instance != NULL;
36 // static
37 void BrowserCldDataProviderFactory::SetDefault(
38 BrowserCldDataProviderFactory* instance) {
39 if (!IsInitialized()) Set(instance);
42 // static
43 void BrowserCldDataProviderFactory::Set(
44 BrowserCldDataProviderFactory* instance) {
45 g_instance = instance;
48 // static
49 BrowserCldDataProviderFactory* BrowserCldDataProviderFactory::Get() {
50 if (IsInitialized()) return g_instance;
51 return &g_wrapped_default.Get();
54 } // namespace translate