-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
ppd_provider_factory.cc
51 lines (41 loc) · 1.89 KB
/
ppd_provider_factory.cc
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
// Copyright 2016 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/chromeos/printing/ppd_provider_factory.h"
#include "base/files/file_path.h"
#include "base/time/default_clock.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/printing/ppd_cache.h"
#include "chromeos/printing/ppd_metadata_manager.h"
#include "chromeos/printing/ppd_provider.h"
#include "chromeos/printing/printer_config_cache.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/google_api_keys.h"
namespace chromeos {
namespace {
network::mojom::URLLoaderFactory* GetURLLoaderFactory() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return g_browser_process->system_network_context_manager()
->GetURLLoaderFactory();
}
} // namespace
scoped_refptr<PpdProvider> CreatePpdProvider(Profile* profile) {
base::FilePath ppd_cache_path =
profile->GetPath().Append(FILE_PATH_LITERAL("PPDCache"));
auto provider_config_cache =
PrinterConfigCache::Create(base::DefaultClock::GetInstance(),
base::BindRepeating(&GetURLLoaderFactory));
auto manager_config_cache =
PrinterConfigCache::Create(base::DefaultClock::GetInstance(),
base::BindRepeating(&GetURLLoaderFactory));
auto metadata_manager = PpdMetadataManager::Create(
g_browser_process->GetApplicationLocale(),
base::DefaultClock::GetInstance(), std::move(manager_config_cache));
return PpdProvider::Create(
version_info::GetVersion(), PpdCache::Create(ppd_cache_path),
std::move(metadata_manager), std::move(provider_config_cache));
}
} // namespace chromeos