blob: d726ba251f6348e9482f606c4806e959f9ec429c (
plain)
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
52
53
54
55
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "headless/lib/headless_content_client.h"
#include "components/embedder_support/origin_trials/origin_trial_policy_impl.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
namespace headless {
HeadlessContentClient::HeadlessContentClient() = default;
HeadlessContentClient::~HeadlessContentClient() = default;
std::u16string HeadlessContentClient::GetLocalizedString(int message_id) {
return l10n_util::GetStringUTF16(message_id);
}
base::StringPiece HeadlessContentClient::GetDataResource(
int resource_id,
ui::ResourceScaleFactor scale_factor) {
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}
base::RefCountedMemory* HeadlessContentClient::GetDataResourceBytes(
int resource_id) {
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
resource_id);
}
std::string HeadlessContentClient::GetDataResourceString(int resource_id) {
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
resource_id);
}
gfx::Image& HeadlessContentClient::GetNativeImageNamed(int resource_id) {
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
resource_id);
}
blink::OriginTrialPolicy* HeadlessContentClient::GetOriginTrialPolicy() {
// Prevent initialization race (see crbug.com/721144). There may be a
// race when the policy is needed for worker startup (which happens on a
// separate worker thread).
base::AutoLock auto_lock(origin_trial_policy_lock_);
if (!origin_trial_policy_)
origin_trial_policy_ =
std::make_unique<embedder_support::OriginTrialPolicyImpl>();
return origin_trial_policy_.get();
}
} // namespace headless
|