electron/brightray/common/content_client.cc

62 lines
1.8 KiB
C++
Raw Normal View History

// Copyright (c) 2012 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-CHROMIUM file.
#include "brightray/common/content_client.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "brightray/common/application_info.h"
#include "content/public/common/user_agent.h"
2014-10-31 11:42:06 +00:00
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
namespace brightray {
std::string GetProductInternal() {
auto name = GetApplicationName();
base::RemoveChars(name, base::kWhitespaceASCII, &name);
2018-04-18 01:56:12 +00:00
return base::StringPrintf("%s/%s", name.c_str(),
GetApplicationVersion().c_str());
}
std::string GetBrightrayUserAgent() {
return content::BuildUserAgentFromProduct(GetProductInternal());
}
2018-04-18 01:56:12 +00:00
ContentClient::ContentClient() {}
2018-04-18 01:56:12 +00:00
ContentClient::~ContentClient() {}
std::string ContentClient::GetProduct() const {
return GetProductInternal();
}
std::string ContentClient::GetUserAgent() const {
return GetBrightrayUserAgent();
}
2014-10-31 11:42:06 +00:00
base::string16 ContentClient::GetLocalizedString(int message_id) const {
return l10n_util::GetStringUTF16(message_id);
}
base::StringPiece ContentClient::GetDataResource(
2018-04-18 01:56:12 +00:00
int resource_id,
ui::ScaleFactor scale_factor) const {
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}
gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const {
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
resource_id);
}
2016-09-06 08:22:52 +00:00
base::RefCountedMemory* ContentClient::GetDataResourceBytes(
int resource_id) const {
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
resource_id);
}
} // namespace brightray