2015-09-09 16:05:39 +02:00
|
|
|
// Copyright (c) 2015 The Chromium Embedded Framework 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 "libcef/common/resource_bundle_impl.h"
|
|
|
|
|
2020-07-21 17:55:54 +02:00
|
|
|
#include "base/memory/ref_counted_memory.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefResourceBundleImpl::CefResourceBundleImpl() {}
|
2015-09-09 16:05:39 +02:00
|
|
|
|
|
|
|
CefString CefResourceBundleImpl::GetLocalizedString(int string_id) {
|
|
|
|
if (!ui::ResourceBundle::HasSharedInstance())
|
|
|
|
return CefString();
|
|
|
|
|
|
|
|
return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(string_id);
|
|
|
|
}
|
|
|
|
|
2020-07-21 17:55:54 +02:00
|
|
|
CefRefPtr<CefBinaryValue> CefResourceBundleImpl::GetDataResource(
|
|
|
|
int resource_id) {
|
|
|
|
return GetDataResourceForScale(resource_id, SCALE_FACTOR_NONE);
|
2015-09-09 16:05:39 +02:00
|
|
|
}
|
|
|
|
|
2020-07-21 17:55:54 +02:00
|
|
|
CefRefPtr<CefBinaryValue> CefResourceBundleImpl::GetDataResourceForScale(
|
|
|
|
int resource_id,
|
|
|
|
ScaleFactor scale_factor) {
|
2015-09-09 16:05:39 +02:00
|
|
|
if (!ui::ResourceBundle::HasSharedInstance())
|
2020-07-21 17:55:54 +02:00
|
|
|
return nullptr;
|
2015-09-09 16:05:39 +02:00
|
|
|
|
2020-07-21 17:55:54 +02:00
|
|
|
base::RefCountedMemory* result =
|
|
|
|
ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
|
2015-09-09 16:05:39 +02:00
|
|
|
resource_id, static_cast<ui::ScaleFactor>(scale_factor));
|
2020-07-21 17:55:54 +02:00
|
|
|
if (!result)
|
|
|
|
return nullptr;
|
2015-09-09 16:05:39 +02:00
|
|
|
|
2020-07-21 17:55:54 +02:00
|
|
|
return CefBinaryValue::Create(result->data(), result->size());
|
2015-09-09 16:05:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
CefRefPtr<CefResourceBundle> CefResourceBundle::GetGlobal() {
|
|
|
|
return new CefResourceBundleImpl();
|
|
|
|
}
|